Skip to content

Commit

Permalink
Merge pull request #163 from Geoportail-Luxembourg/GSLUX-748-auth-plu…
Browse files Browse the repository at this point in the history
…g-api

GSLUX-748: Auth plug api
  • Loading branch information
AlitaBernachot authored Oct 21, 2024
2 parents 565e94e + 907d9fe commit a151c5b
Show file tree
Hide file tree
Showing 17 changed files with 3,865 additions and 2,296 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ VITE_ARROW_MODEL_URL="/static-ngeo/models/arrow5.glb"
VITE_ELEVATION_URL="/raster"

# Auth
VITE_LOGIN_URL="/login"
VITE_LOGOUT_URL="/logout"
VITE_USERINFO_URL="/getuserinfo"
VITE_MYACCOUNT_URL="https://myaccount.geoportail.lu"
VITE_MYACCOUNT_RECOVER_URL="https://myaccount.geoportail.lu/recover-password"
VITE_MYACCOUNT_NEW_URL="https://myaccount.geoportail.lu/new-user"
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"

# Auth
VITE_LOGIN_URL="https://migration.geoportail.lu/login"
VITE_LOGOUT_URL="https://migration.geoportail.lu/logout"
VITE_USERINFO_URL="https://migration.geoportail.lu/getuserinfo"
VITE_MYACCOUNT_URL="https://myaccount.geoportail.lu"
VITE_MYACCOUNT_RECOVER_URL="https://myaccount.geoportail.lu/recover-password"
VITE_MYACCOUNT_NEW_URL="https://myaccount.geoportail.lu/new-user"
3 changes: 3 additions & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"

# Auth
VITE_LOGIN_URL="https://migration.geoportail.lu/login"
VITE_LOGOUT_URL="https://migration.geoportail.lu/logout"
VITE_USERINFO_URL="https://migration.geoportail.lu/getuserinfo"
VITE_MYACCOUNT_URL="https://myaccount.geoportail.lu"
VITE_MYACCOUNT_RECOVER_URL="https://myaccount.geoportail.lu/recover-password"
VITE_MYACCOUNT_NEW_URL="https://myaccount.geoportail.lu/new-user"
3 changes: 3 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ VITE_ARROW_MODEL_URL="https://migration.geoportail.lu/static-ngeo/models/arrow5.
VITE_ELEVATION_URL="https://migration.geoportail.lu/raster"

# Auth
VITE_LOGIN_URL="https://migration.geoportail.lu/login"
VITE_LOGOUT_URL="https://migration.geoportail.lu/logout"
VITE_USERINFO_URL="https://migration.geoportail.lu/getuserinfo"
VITE_MYACCOUNT_URL="https://myaccount.geoportail.lu"
VITE_MYACCOUNT_RECOVER_URL="https://myaccount.geoportail.lu/recover-password"
VITE_MYACCOUNT_NEW_URL="https://myaccount.geoportail.lu/new-user"
101 changes: 98 additions & 3 deletions cypress/e2e/auth/auth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ describe('Authentification', () => {
})

describe('When user arrives on the page', () => {
it('the authentification icon is located in the header', () => {
it('the authentication icon is located in the header', () => {
cy.get('header [data-cy="authFormIcon"]').should('exist')
})
})

describe('When user clicks on the auth icon in the header', () => {
it('displays the authentification form correctly', () => {
it('displays the authentication form correctly', () => {
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('header [data-cy="authForm"]').should('exist')
cy.get('header [data-cy="authForm"] form input[name="userName"]').should(
Expand All @@ -28,12 +28,107 @@ describe('Authentification', () => {
})

describe('When user clicks again', () => {
it('hides the authentification form', () => {
it('hides the authentication form', () => {
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('header [data-cy="authForm"]').should('exist')
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('header [data-cy="authForm"]').should('not.be.visible')
})
})

describe('When user is authenticating with success', () => {
beforeEach(() => {
cy.intercept('POST', '/login', {
statusCode: 200,
body: {
login: 'MyLogin',
mail: 'my_login@email.com',
},
})
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"] input[name="userName"]').type('MyLogin')
cy.get('[data-cy="authForm"] input[name="userPassword"]').type(
'Rand87321mdp'
)
cy.get('[data-cy="authForm"] input[type="submit"]').click()
})

it('authenticates the user, hides the form and display the success notification msg', () => {
cy.get('[data-cy="authForm"]').should('not.be.visible')
cy.get('[data-cy="notification"]').should(
'have.text',
'Vous êtes maintenant correctement connecté.'
)
})

it('displays the user login and mail', () => {
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"]').should('contain.text', 'MyLogin')
cy.get('[data-cy="authForm"]').should(
'contain.text',
'my_login@email.com'
)
})
})

describe('When user is logging out', () => {
beforeEach(() => {
cy.intercept('POST', '/login', {
statusCode: 200,
body: {
login: 'MyLogin',
mail: 'my_login@email.com',
},
})
cy.intercept('GET', '/logout', {
statusCode: 200,
body: {},
})
cy.get('[data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"] input[name="userName"]').type('MyLogin')
cy.get('[data-cy="authForm"] input[name="userPassword"]').type(
'Rand87321mdp'
)
cy.get('[data-cy="authForm"] input[type="submit"]').click()
})

it('logs out the user and display back the login form', () => {
cy.get('[data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"] button').click()
cy.get('[data-cy="authForm"]').should('be.visible')
cy.get('[data-cy="authForm"] input[name="userName"]').should(
'be.visible'
)
cy.get('[data-cy="authForm"] input[name="userPassword"]').should(
'be.visible'
)
})
})

describe('When user tries to authenticate with failure', () => {
beforeEach(() => {
cy.intercept('POST', '/login', {
statusCode: 401,
body: {},
})
cy.get('header [data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"] input[name="userName"]').type(
'incorrectLogin'
)
cy.get('[data-cy="authForm"] input[name="userPassword"]').type(
'Rand87321mdp'
)
cy.get('[data-cy="authForm"] input[type="submit"]').click()
})

it('does not close the form and displays a warning msg', () => {
cy.get('[data-cy="notification"]').should('be.visible')
cy.get('[data-cy="notification"]').should(
'contain.text',
'utilisateur ou mot de passe non valides'
)
cy.get('[data-cy="authForm"]').should('be.visible')
})
})
})
})
28 changes: 28 additions & 0 deletions cypress/e2e/header-bar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,33 @@ describe('Header bar', () => {
cy.get('[data-cy="themeGrid"]').should('be.visible')
})
})

describe('When opening the language selector', () => {
it('hides the auth form', () => {
cy.get('[data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"]').should('be.visible')

cy.get('[data-cy="langSelect"] .lux-dropdown-list').should(
'not.be.visible'
)
cy.get('[data-cy="langSelect"]').click()
cy.get('[data-cy="langSelect"] .lux-dropdown-list').should('be.visible')
cy.get('[data-cy="authForm"]').should('not.be.visible')
})
})

describe('When opening the authentication form', () => {
it('hides the language selector', () => {
cy.get('[data-cy="langSelect"]').click()
cy.get('[data-cy="langSelect"] .lux-dropdown-list').should('be.visible')

cy.get('[data-cy="authForm"]').should('not.be.visible')
cy.get('[data-cy="authFormIcon"]').click()
cy.get('[data-cy="authForm"]').should('be.visible')
cy.get('[data-cy="langSelect"] .lux-dropdown-list').should(
'not.be.visible'
)
})
})
})
})
Loading

0 comments on commit a151c5b

Please sign in to comment.