forked from dedis/d-voting
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up test directory, and initial add form management tests
- Loading branch information
Showing
30 changed files
with
801 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
web/frontend/src/pages/form/components/ActionButtons/AddVotersButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
web/frontend/src/pages/form/components/ActionButtons/utils.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ID } from './../../../../types/configuration'; | ||
|
||
export function isManager(formID: ID, authorization: Map<String, String[]>, isLogged: boolean) { | ||
return ( | ||
isLogged && // must be logged in | ||
authorization.has('election') && | ||
authorization.get('election').includes('create') && // must be able to create elections | ||
authorization.has(formID) && | ||
authorization.get(formID).includes('own') // must own the election | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { assertHasFooter, assertHasNavBar, initI18n, logIn, setUp } from './shared'; | ||
import { | ||
SCIPER_ADMIN, | ||
SCIPER_OTHER_ADMIN, | ||
SCIPER_USER, | ||
mockPersonalInfo, | ||
mockProxies, | ||
} from './mocks/api'; | ||
import { FORMID, mockDKGActors, mockFormsFormID } from './mocks/evoting'; | ||
|
||
initI18n(); | ||
|
||
// main elements | ||
|
||
async function setUpMocks( | ||
page: page, | ||
formStatus: number, | ||
dkgActorsStatus: number, | ||
initialized?: boolean | ||
) { | ||
// the nodes must have been initialized if they changed state | ||
initialized = initialized || dkgActorsStatus > 0; | ||
await mockFormsFormID(page, formStatus); | ||
for (const i of [0, 1, 2, 3]) { | ||
await mockProxies(page, i); | ||
} | ||
await mockDKGActors(page, dkgActorsStatus, initialized); | ||
await mockPersonalInfo(page); | ||
} | ||
|
||
test.beforeEach(async ({ page }) => { | ||
// mock empty list per default | ||
setUpMocks(page, 0, 0, false); | ||
await setUp(page, `/forms/${FORMID}`); | ||
}); | ||
|
||
test('Assert navigation bar is present', async ({ page }) => { | ||
await assertHasNavBar(page); | ||
}); | ||
|
||
test('Assert footer is present', async ({ page }) => { | ||
await assertHasFooter(page); | ||
}); | ||
|
||
async function assertIsOnlyVisibleToOwner(page: page, locator: locator) { | ||
await test.step('Assert is hidden to unauthenticated user', async () => { | ||
await expect(locator).toBeHidden(); | ||
}); | ||
await test.step('Assert is hidden to authenticated non-admin user', async () => { | ||
await logIn(page, SCIPER_USER); | ||
await expect(locator).toBeHidden(); | ||
}); | ||
await test.step('Assert is hidden to non-owner admin', async () => { | ||
await logIn(page, SCIPER_ADMIN); | ||
await expect(locator).toBeHidden(); | ||
}); | ||
await test.step('Assert is visible to owner admin', async () => { | ||
await logIn(page, SCIPER_OTHER_ADMIN); | ||
await expect(locator).toBeVisible(); | ||
}); | ||
} | ||
|
||
async function assertIsOnlyVisibleToOwnerStates(page: page, locator: locator, states: Array) { | ||
for (const i of states) { | ||
await test.step(`Assert is only visible to owner in state ${i}`, async () => { | ||
await setUpMocks(page, i, 6); | ||
await page.reload({ waitUntil: 'networkidle' }); | ||
await assertIsOnlyVisibleToOwner(page, locator); | ||
}); | ||
} | ||
} | ||
|
||
test('Assert "Add voters" button is only visible to owner', async ({ page }) => { | ||
await assertIsOnlyVisibleToOwnerStates(page, page.getByTestId('addVotersButton'), [0, 1]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"sciper": 987654, | ||
"lastName": "987654", | ||
"firstName": "sciper-#", | ||
"isLoggedIn": true, | ||
"authorization": { | ||
"roles": [ | ||
"add", | ||
"list", | ||
"remove" | ||
], | ||
"proxies": [ | ||
"post", | ||
"put", | ||
"delete" | ||
], | ||
"election": [ | ||
"create" | ||
], | ||
"fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["own"], | ||
"ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote", "own"], | ||
"9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["vote"], | ||
"b63bcb854121051f2d8cff04bf0ac9b524b534b704509a16a423448bde3321b4": ["own"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"NodeAddr": "grpc://dela-worker-0:2000", | ||
"Proxy": "http://172.19.44.254:8080" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"NodeAddr": "grpc://dela-worker-1:2000", | ||
"Proxy": "http://172.19.44.253:8080" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"NodeAddr": "grpc://dela-worker-2:2000", | ||
"Proxy": "http://172.19.44.252:8080" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"NodeAddr": "grpc://dela-worker-3:2000", | ||
"Proxy": "http://172.19.44.251:8080" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Status": 6, | ||
"Error": { | ||
"Title": "", | ||
"Code": 0, | ||
"Message": "", | ||
"Args": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Status": 0, | ||
"Error": { | ||
"Title": "", | ||
"Code": 0, | ||
"Message": "", | ||
"Args": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Status": 1, | ||
"Error": { | ||
"Title": "", | ||
"Code": 0, | ||
"Message": "", | ||
"Args": null | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
web/frontend/tests/json/evoting/dkgActors/uninitialized.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Title": "not found", | ||
"Code": 404, | ||
"Message": "A problem occurred on the proxy", | ||
"Args": { | ||
"error": "actor not found", | ||
"method": "GET", | ||
"url": "/evoting/services/dkg/actors/d3319c58a3bea17dafe61168610757b9a7bb0d922c1f2aa30b8ad537646b1c07" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"FormID": "b63bcb854121051f2d8cff04bf0ac9b524b534b704509a16a423448bde3321b4", | ||
"Configuration": { | ||
"Title": { | ||
"En": "Colours", | ||
"Fr": "", | ||
"De": "" | ||
}, | ||
"Scaffold": [ | ||
{ | ||
"ID": "yOakwFnR", | ||
"Title": { | ||
"En": "Colours", | ||
"Fr": "Couleurs", | ||
"De": "Farben" | ||
}, | ||
"Order": [ | ||
"CLgNiLbC" | ||
], | ||
"Subjects": [], | ||
"Selects": [ | ||
{ | ||
"ID": "CLgNiLbC", | ||
"Title": { | ||
"En": "RGB", | ||
"Fr": "RGB", | ||
"De": "RGB" | ||
}, | ||
"MaxN": 2, | ||
"MinN": 1, | ||
"Choices": [ | ||
"{\"en\":\"Red\",\"fr\":\"Rouge\",\"de\":\"Rot\"}", | ||
"{\"en\":\"Green\",\"fr\":\"Vert\",\"de\":\"Grün\"}", | ||
"{\"en\":\"Blue\",\"fr\":\"Bleu\",\"de\":\"Blau\"}" | ||
], | ||
"Hint": { | ||
"En": "", | ||
"Fr": "", | ||
"De": "" | ||
} | ||
} | ||
], | ||
"Ranks": [], | ||
"Texts": [] | ||
} | ||
] | ||
}, | ||
"Status": 2, | ||
"Pubkey": "612fdc867be1a5faccf16e5aed946880005840ee04aaa382fe181a2b46dc9a24", | ||
"Result": [], | ||
"Roster": [ | ||
"grpc://dela-worker-0:2000", | ||
"grpc://dela-worker-1:2000", | ||
"grpc://dela-worker-2:2000", | ||
"grpc://dela-worker-3:2000" | ||
], | ||
"ChunksPerBallot": 1, | ||
"BallotSize": 23, | ||
"Voters": [ | ||
"oUItDdhhEE", | ||
"WZyqP1gssL", | ||
"K7ZNvumBVc" | ||
] | ||
} |
Oops, something went wrong.