Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/end to end 1190 #1267

Merged
merged 8 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 13 additions & 151 deletions playwright/e2eTests/singleRightsDelegering.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* eslint-disable import/default */
/* eslint-disable import/no-named-as-default-member */

import { test } from './../fixture/pomFixture';

test.describe('User with DAGL/HADM role without having resource access themselves', () => {
test('User A who is DAGL/HADM for org delegates resources/Altinn 3 app/Altinn 2 services to User B', async ({
// Testscenario:
ernstjonny marked this conversation as resolved.
Show resolved Hide resolved
// Logg inn med bruker på Altinn
// Gå til enkeltdelegering på profil
// Gå til andre med rettigheter til virksomheten
// Legg til ny person eller virksomhet: 24928099071: (OPPSTEMT) ABBED
// Gi nye enkelttjenester: Velg tjeneste som ikke kan delegeres: "Altinn2 non-delegable Reporting service"
// Du skal nå få feilmelding: Du kan ikke gi fullmakt til denne tjenesten
test('Singleright delegation - Non-delegable service', async ({
login,
delegate,
delegateRights,
Expand All @@ -22,158 +27,15 @@ test.describe('User with DAGL/HADM role without having resource access themselve

//To delete rights - setup
// GIVEN user without delegated rights to ROMANTISK ESKE
await deleteRights.revokeRightsSSN('SKYFRI GATE');
Nyeng marked this conversation as resolved.
Show resolved Hide resolved
//await deleteRights.revokeRightsSSN('SKYFRI GATE');

//To delegate rights
// WHEN user delegates to ROMANTISK ESKE
await delegate.delegateToSSN('19856097121', 'GATE');
await delegateRoles.delegateRoles(
'Tilgangsstyring',
'Begrenset signeringsrettighet',
'SKYFRI GATE',
);
await delegateRights.delegateRightsToSSN('Ressurs for enkeltrettigheter testing');
await delegateRights.delegateRightsToSSN('autorisasjon-automatisert-app');
await delegateRights.delegateRightsToSSN('Altinn2 reporting service for authorization tests');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
// await context1.close();
await context.clearCookies();

//Login with covereby User

await login.loginWithUser('19856097121');
await login.chooseReportee('ULIK FLAT TIGER AS');
await coverebyRights.checkCoverebyRights();

//Instantiate app to which user had got rights
await instantiateResources.instantiateApp('ULIK FLAT TIGER AS');
// await context.close();

//To delegate rights
// WHEN user delegates to KLIPPFISK
await delegate.delegateToSSN('04880748144', 'KLIPPFISK');
await delegateRights.delegateRightsToSSN('autorisasjon-automatisert-app');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
await context.clearCookies();

//Instantiate app to which user had got rights
await login.loginWithUser('04880748144');
await login.chooseReportee('ULIK FLAT TIGER AS');
await coverebyRights.checkCoverebyRights();
await instantiateResources.instantiateApp('ULIK FLAT TIGER AS');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
});

test('User A who is DAGL/HADM for org delegates resources/Altinn 3 app/Altinn 2 services to Org B', async ({
login,
delegate,
delegateRights,
deleteRights,
logoutUser,
coverebyRights,
instantiateResources,
delegateRoles,
context,
}) => {
test.setTimeout(60000 * 3);

await login.loginWithUser('04885299593');
await login.chooseReportee('ULIK FLAT TIGER AS');

//To delete rights - setup
// GIVEN user without delegated rights to OPPKLARENDE OMKOMMEN TIGER AS
const buttonIndex = 1;
await deleteRights.revokeRightsOrg('GJESTFRI RESERVERT HUND DA', buttonIndex);

//To delegate rights
// WHEN user delegates to
await delegate.delegateToOrg('310832170', 'GJESTFRI RESERVERT HUND DA');
await delegateRoles.delegateRoles(
'Tilgangsstyring',
'Begrenset signeringsrettighet',
'GJESTFRI RESERVERT HUND DA',
);
await delegateRights.delegateRightsToSSN('Ressurs for enkeltrettigheter testing');
await delegateRights.delegateRightsToSSN('autorisasjon-automatisert-app');
await delegateRights.delegateRightsToSSN('Altinn2 reporting service for authorization tests');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
// await context1.close();
await context.clearCookies();

//Login with covereby User
await delegateRights.nonDelegatebleRightsToSSN('Altinn2 non-delegable');

await login.loginWithUser('21908498426');
await login.chooseReportee('ULIK FLAT TIGER AS');
await coverebyRights.checkCoverebyRights();

//Instantiate app to which user had got rights
await instantiateResources.instantiateApp('ULIK FLAT TIGER AS');
// await context.close();

//Delete rights
await deleteRights.revokeRightsOrg('UNDERFUNDIG TROFAST TIGER AS', buttonIndex);

//Delegate to another org
await delegate.delegateToOrg('313948579', 'UNDERFUNDIG TROFAST TIGER AS');
await delegateRights.delegateRightsToSSN('autorisasjon-automatisert-app');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
await context.clearCookies();

//Instantiate app to which user had got rights
await login.loginWithUser('20860898609');
await login.chooseReportee('ULIK FLAT TIGER AS');
await coverebyRights.checkCoverebyRights();
await instantiateResources.instantiateApp('ULIK FLAT TIGER AS');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
});

test('DAGL/HADM do not have rights to delegate Altinn2 to org Y , but has the rights to delegate same service after delegating sens role to himself', async ({
login,
delegate,
delegateRights,
deleteRights,
logoutUser,
coverebyRights,
context,
delegateRoles,
}) => {
test.setTimeout(60000 * 3);

//Login with user who has tilgangstyrring rolle
await login.loginWithUser('04885299593');
await login.chooseReportee('ULIK FLAT TIGER AS');

//To delete rights - setup
// GIVEN user without delegated rights to UINTERESSERT LØVEFLOKK
await deleteRights.revokeRightsSSN('UINTERESSERT LØVEFLOKK');

//To delegate rights
// WHEN user delegates rolls to UINTERESSERT LØVEFLOKK
await delegate.delegateToSSN('07922148605', 'LØVEFLOKK');
await delegateRoles.delegateRole('Taushetsbelagt post', 'Hovedadministrator');
await logoutUser.gotoLogoutPage('ULIK FLAT TIGER AS');
await context.clearCookies();

//Login with another user who has SENS role
await login.loginWithUser('07922148605');
await login.chooseReportee('ULIK FLAT TIGER AS');
await deleteRights.revokeRightsSSN('STORARTET KORGSTOL');
await new Promise((resolve) =>
setTimeout(() => {
resolve(null);
}, 500),
);
await delegate.delegateToSSN('07885798378', 'KORGSTOL');
await delegateRights.delegateRightsToSSN(
'Altinn2 sensitive reporting service for Authorizaion tests',
);

// await context1.close();
await context.clearCookies();

//Login with covereby User
await login.loginWithUser('07885798378');
await login.chooseReportee('ULIK FLAT TIGER AS');
await coverebyRights.checkCoverebyRights();
// Forsøk å deleger Altinn2 non-delegable Reporting service
// Lag ny metode som forsøker å delegere en enkelttjeneste (dublisere fra annen metode)
// Verifiser at det kommer opp feilmelding "Du kan ikke gi fullmakt til denne tjenesten"
});
});
16 changes: 16 additions & 0 deletions playwright/pages/profile/delegationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,23 @@ export class delegateRightsToUser {
}
}
}
ernstjonny marked this conversation as resolved.
Show resolved Hide resolved
async nonDelegatebleRightsToSSN(resourceName: string) {
await this.page.getByRole('link', { name: 'Gi tilgang til enkelttjenester' }).click();
await this.page.getByLabel('Søk etter skjema og tjeneste').click();
await this.page.getByLabel('Søk etter skjema og tjeneste').fill(resourceName);
await this.page.keyboard.press('Enter');
await new Promise((resolve) =>
setTimeout(() => {
resolve(null);
}, 500),
);

await this.page.getByRole('button', { name: 'Legg til' }).first().click();
var fullmaktsheader = this.page.getByRole('heading', { name: 'Du kan ikke gi fullmakt til' });
await expect(fullmaktsheader).toBeVisible();
}
}

export class coverebyUserRights {
constructor(public page: Page) {}

Expand Down