Skip to content

Commit

Permalink
Merge pull request #1776 from danskernesdigitalebibliotek/undo-merge-…
Browse files Browse the repository at this point in the history
…1759

Revert premature merge
  • Loading branch information
xendk authored Nov 19, 2024
2 parents eac893b + d60b905 commit 509239e
Show file tree
Hide file tree
Showing 190 changed files with 1,338 additions and 1,770 deletions.
16 changes: 0 additions & 16 deletions .prettierrc.json

This file was deleted.

3 changes: 1 addition & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ tasks:
summary: Build docker containers
# Ensure that we only rebuild if there are changes to Dockerfiles
sources:
- "{{ .LAGOON_DIR }}/**/*"
- "{{ .LAGOON_DIR }}/*"
- "{{ .LAGOON_DIR }}/*.dockerfile"
cmds:
- docker compose build

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@
},
"scripts": {
"post-drupal-scaffold-cmd": [
"[ ! -d web/sites/default/files/modules_local ] && mkdir -p web/sites/default/files/modules_local || exit 0",
"[ ! -L web/modules/local ] && ln -s web/sites/default/files/modules_local web/modules/local || exit 0"
"[[ ! -d /app/web/sites/default/files/modules_local ]] && mkdir -p /app/web/sites/default/files/modules_local || exit 0",
"[[ ! -L /app/web/modules/local ]] && ln -s /app/web/sites/default/files/modules_local /app/web/modules/local || exit 0"
]
},
"extra": {
Expand Down
1 change: 0 additions & 1 deletion config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ module:
dpl_update: 0
dpl_url_proxy: 0
dpl_webform: 0
dpl_webmaster: 0
drupal_typed: 0
dynamic_entity_reference: 0
dynamic_page_cache: 0
Expand Down
134 changes: 67 additions & 67 deletions cypress/e2e/adgangsplatformen.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe('Adgangsplatformen', () => {
describe("Adgangsplatformen", () => {
beforeEach(() => {
Cypress.session.clearAllSavedSessions();
});

it('supports login with both uniqueId and CPR attribute', () => {
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60d70030fd1';
const userGuid = '19a4ae39-be07-4db9-a8b7-8bbb29f03da6';
it("supports login with both uniqueId and CPR attribute", () => {
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60d70030fd1";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";
const userCPR = 9999999999;

cy.adgangsplatformenLogin({
Expand All @@ -15,150 +15,150 @@ describe('Adgangsplatformen', () => {
userCPR,
userGuid,
});
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
});

it('supports login for user with only CPR attribute.', () => {
it("supports login for user with only CPR attribute.", () => {
// If a user does not have uniqueId attribute, it is a user not previously related to any library.
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";
const userCPR = 9999999999;

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
userCPR,
});
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
});

it('supports login for user only with uniqueId attribute.', () => {
it("supports login for user only with uniqueId attribute.", () => {
// If a user do not have a CPR attribute, it is probably a test user.
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';
const userGuid = '19a4ae39-be07-4db9-a8b7-8bbb29f03da6';
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";
const userGuid = "19a4ae39-be07-4db9-a8b7-8bbb29f03da6";

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
userGuid,
});
cy.visit('/user');
cy.url().should('match', /user\/\d+/);
cy.visit("/user");
cy.url().should("match", /user\/\d+/);
});

// TODO: Figure out how to check failed logins when using cy.session().
it.skip('does not support login with users missing both uniqueId and CPR attribute.', () => {
it.skip("does not support login with users missing both uniqueId and CPR attribute.", () => {
// If a user do not have a CPR attribute, it is probably a test user.
const authorizationCode = '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc';
const accessToken = '447131b0a03fe0421204c54e5c21a60-new-user';
const authorizationCode = "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc";
const accessToken = "447131b0a03fe0421204c54e5c21a60-new-user";

cy.adgangsplatformenLogin({
authorizationCode,
accessToken,
});
cy.contains(
'body',
'The website encountered an unexpected error. Please try again later.',
"body",
"The website encountered an unexpected error. Please try again later."
);
});

// When a user comes back from authentication with MitID, the user should
// not be able to do anything else other than registering or cancelling.
// Check that the header and footer sections is not vissible.
it('does not show header and footer section for unregistered user', () => {
it("does not show header and footer section for unregistered user", () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit('/arrangementer');
cy.visit("/arrangementer");
// Open user menu.
cy.getBySel('header-menu-profile-button').click();
cy.getBySel("header-menu-profile-button").click();
// Click create profile.
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
.first()
.click();

cy.verifyToken({
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
});

cy.get('.header').should('not.exist');
cy.get('.footer').should('not.exist');
cy.get(".header").should("not.exist");
cy.get(".footer").should("not.exist");
});

it('can register a new user - expose the right tokens for the react apps - and force logout.', () => {
it("can register a new user - expose the right tokens for the react apps - and force logout.", () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit('/arrangementer');
cy.getBySel('header-menu-profile-button').click();
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
cy.visit("/arrangementer");
cy.getBySel("header-menu-profile-button").click();
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
.first()
.click();
cy.verifyToken({
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
});

cy.get('[data-cy="phone-input"]').type('12345678');
cy.get('[data-cy="email-address-input"]').type('[email protected]');
cy.get('[data-cy="pincode-input"]').type('1234');
cy.get('[data-cy="pincode-confirm-input"]').type('1234');
cy.get('#branches-dropdown').select('DK-775100');
cy.get('[data-cy="phone-input"]').type("12345678");
cy.get('[data-cy="email-address-input"]').type("[email protected]");
cy.get('[data-cy="pincode-input"]').type("1234");
cy.get('[data-cy="pincode-confirm-input"]').type("1234");
cy.get("#branches-dropdown").select("DK-775100");
cy.get('[data-cy="complete-user-registration-button"]').click();
cy.get('[data-cy="button"]').click();
cy.origin('login.bib.dk', () => {
cy.url().should('to.match', /^https:\/\/login.bib.dk\/logout\?.*/);
cy.origin("login.bib.dk", () => {
cy.url().should("to.match", /^https:\/\/login.bib.dk\/logout\?.*/);
cy.url().should(
'to.match',
/.*redirect_uri=.*\/login%3Fcurrent-path%3D\/velkommen.*/,
"to.match",
/.*redirect_uri=.*\/login%3Fcurrent-path%3D\/velkommen.*/
);
});
});

it('can cancel user registration from the user registration page', () => {
it("can cancel user registration from the user registration page", () => {
cy.setupAdgangsplatformenRegisterMappinngs({
authorizationCode: '7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc',
accessToken: '447131b0a03fe0421204c54e5c21a60-new-user',
authorizationCode: "7c5e3213aea6ef42ec97dfeaa6f5b1d454d856dc",
accessToken: "447131b0a03fe0421204c54e5c21a60-new-user",
userCPR: 1412749999,
});

cy.clearCookies();
cy.visit('/arrangementer');
cy.getBySel('header-menu-profile-button').click();
cy.get('.modal-login__btn-create-profile').click();
cy.get('main#main-content')
.get('.paragraphs__item--user_registration_section__link')
cy.visit("/arrangementer");
cy.getBySel("header-menu-profile-button").click();
cy.get(".modal-login__btn-create-profile").click();
cy.get("main#main-content")
.get(".paragraphs__item--user_registration_section__link")
.first()
.click();
cy.verifyToken({
tokenType: 'unregistered-user',
token: '447131b0a03fe0421204c54e5c21a60-new-user',
tokenType: "unregistered-user",
token: "447131b0a03fe0421204c54e5c21a60-new-user",
});

cy.get('[data-cy="cancel-user-registration-button"]').click();

cy.request('/dpl-react/user-tokens').then((response) => {
cy.request("/dpl-react/user-tokens").then((response) => {
expect(response.body).not.contain(
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("user", "447131b0a03fe0421204c54e5c21a60-new-user")',
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("user", "447131b0a03fe0421204c54e5c21a60-new-user")'
);
expect(response.body).not.contain(
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("unregistered-user", "447131b0a03fe0421204c54e5c21a60-new-user")',
'window.dplReact = window.dplReact || {};\nwindow.dplReact.setToken("unregistered-user", "447131b0a03fe0421204c54e5c21a60-new-user")'
);
});
});
Expand Down
Loading

0 comments on commit 509239e

Please sign in to comment.