Skip to content

Commit

Permalink
tests: add e2e test for connection from legacy and agentconnect client
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubigny committed Sep 8, 2023
1 parent 8664fd6 commit 95ac1cf
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 8 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,42 @@ jobs:
- join_with_sponsorship
- join_with_code_sent_to_official_contact_email
- signin_from_standard_client
- signin_from_agentconnect_client
- signin_from_legacy_client
runs-on: ubuntu-20.04
services:
moncomptepro-test-client:
moncomptepro-standard-client:
image: rdubigny/moncomptepro-test-client
ports:
- 4000:4000
env:
PORT: 4000
MCP_CLIENT_ID: client_id
MCP_CLIENT_SECRET: client_secret
MCP_CLIENT_ID: standard_client_id
MCP_CLIENT_SECRET: standard_client_secret
MCP_PROVIDER: ${{ env.MONCOMPTEPRO_HOST }}
MCP_SCOPES: openid,email,profile,organization
moncomptepro-agentconnect-client:
image: rdubigny/moncomptepro-test-client
ports:
- 4001:4001
env:
PORT: 4001
MCP_CLIENT_ID: agentconnect_client_id
MCP_CLIENT_SECRET: agentconnect_client_secret
MCP_PROVIDER: ${{ env.MONCOMPTEPRO_HOST }}
MCP_SCOPES: openid,uid,given_name,usual_name,email,siren,siret,organizational_unit,belonging_population,phone,chorusdt
MCP_ID_TOKEN_SIGNED_RESPONSE_ALG: ES256
MCP_USERINFO_SIGNED_RESPONSE_ALG: ES256
moncomptepro-legacy-client:
image: rdubigny/moncomptepro-test-client
ports:
- 4002:4002
env:
PORT: 4002
MCP_CLIENT_ID: legacy_client_id
MCP_CLIENT_SECRET: legacy_client_secret
MCP_PROVIDER: ${{ env.MONCOMPTEPRO_HOST }}
MCP_SCOPES: openid,email,profile,phone,organizations
redis:
image: redis
ports:
Expand Down
26 changes: 26 additions & 0 deletions cypress/e2e/signin_from_agentconnect_client.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const MONCOMPTEPRO_HOST =
Cypress.env('MONCOMPTEPRO_HOST') || 'http://localhost:3000';

describe('sign-in from agentconnect client', () => {
it('should sign-in', function () {
cy.visit(`http://localhost:4001`);
cy.get('button.moncomptepro-button').click();

cy.get('[name="login"]').type('[email protected]');
cy.get('[type="submit"]').click();

cy.get('[name="password"]').type('password123');
cy.get('[action="/users/sign-in"] [type="submit"]')
.contains('Se connecter')
.click();

cy.get('.fr-grid-row .fr-col-12:first-child .fr-tile__link').contains(
'Commune de lamalou-les-bains - Mairie'
);

cy.get('.fr-grid-row .fr-col-12:first-child .fr-tile__link').click();

cy.contains('[email protected]');
cy.contains('21340126800130');
});
});
20 changes: 20 additions & 0 deletions cypress/e2e/signin_from_legacy_client.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const MONCOMPTEPRO_HOST =
Cypress.env('MONCOMPTEPRO_HOST') || 'http://localhost:3000';

describe('sign-in from legacy client', () => {
it('should sign-in', function () {
cy.visit(`http://localhost:4002`);
cy.get('button.moncomptepro-button').click();

cy.get('[name="login"]').type('[email protected]');
cy.get('[type="submit"]').click();

cy.get('[name="password"]').type('password123');
cy.get('[action="/users/sign-in"] [type="submit"]')
.contains('Se connecter')
.click();

cy.contains('[email protected]');
cy.contains('Commune de lamalou-les-bains');
});
});
23 changes: 23 additions & 0 deletions cypress/e2e/signin_from_standard_client.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,28 @@ describe('sign-in from standard client', () => {
cy.get('.fr-grid-row .fr-col-12:first-child .fr-tile__link').click();

cy.contains('[email protected]');
cy.contains('Commune de lamalou-les-bains - Mairie');
});

it('should sign-in with org selection', function () {
cy.visit(`http://localhost:4000`);
cy.get('button.moncomptepro-button').click();

cy.get('[name="login"]').type('[email protected]');
cy.get('[type="submit"]').click();

cy.get('[name="password"]').type('password123');
cy.get('[action="/users/sign-in"] [type="submit"]')
.contains('Se connecter')
.click();

cy.get('.fr-grid-row .fr-col-12:last-child .fr-tile__link').contains(
'Commune de clamart - Mairie'
);

cy.get('.fr-grid-row .fr-col-12:last-child .fr-tile__link').click();

cy.contains('[email protected]');
cy.contains('Commune de clamart - Mairie');
});
});
1 change: 1 addition & 0 deletions cypress/env/signin_from_agentconnect_client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DO_NOT_SEND_MAIL="True"
1 change: 1 addition & 0 deletions cypress/env/signin_from_legacy_client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DO_NOT_SEND_MAIL="True"
35 changes: 35 additions & 0 deletions cypress/fixtures/signin_from_agentconnect_client.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
INSERT INTO users
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at, given_name, family_name,
phone_number, job)
VALUES
(1, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'Jean', '0123456789', 'Sbire');


INSERT INTO organizations
(id, siret, verified_email_domains, authorized_email_domains, created_at, updated_at)
VALUES
(1, '21340126800130', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

INSERT INTO users_organizations
(user_id, organization_id, is_external, verification_type, authentication_by_peers_type, has_been_greeted)
VALUES
(1, 1, false, 'verified_email_domain', 'all_members_notified', true);

INSERT INTO oidc_clients
(client_name, client_id, client_secret, redirect_uris,
post_logout_redirect_uris, scope, client_uri, client_description,
userinfo_signed_response_alg, id_token_signed_response_alg,
authorization_signed_response_alg, introspection_signed_response_alg)
VALUES
(
'AgentConnect',
'agentconnect_client_id',
'agentconnect_client_secret',
ARRAY [
'http://localhost:4001/login-callback'
],
ARRAY []::varchar[],
'openid uid given_name usual_name email phone siret',
'http://localhost:4001/',
'Dispositif d’identification des agents de la fonction publique.',
'ES256', 'ES256', 'ES256', 'ES256');
34 changes: 34 additions & 0 deletions cypress/fixtures/signin_from_legacy_client.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
INSERT INTO users
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at, given_name, family_name,
phone_number, job)
VALUES
(1, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'Jean', '0123456789', 'Sbire');


INSERT INTO organizations
(id, siret, verified_email_domains, authorized_email_domains, created_at, updated_at)
VALUES
(1, '21340126800130', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

INSERT INTO users_organizations
(user_id, organization_id, is_external, verification_type, authentication_by_peers_type, has_been_greeted)
VALUES
(1, 1, false, 'verified_email_domain', 'all_members_notified', true);

INSERT INTO oidc_clients
(client_name, client_id, client_secret, redirect_uris,
post_logout_redirect_uris, scope, client_uri, client_description,
userinfo_signed_response_alg, id_token_signed_response_alg,
authorization_signed_response_alg, introspection_signed_response_alg)
VALUES
('Oidc Test Client',
'legacy_client_id',
'legacy_client_secret',
ARRAY [
'http://localhost:4002/login-callback'
],
ARRAY []::varchar[],
'openid email profile phone organizations',
'http://localhost:4002/',
'This is a small, golang-based OIDC Client, to be used in End-to-end or other testing. More info: https://hub.docker.com/r/beryju/oidc-test-client.',
null, null, null, null);
14 changes: 9 additions & 5 deletions cypress/fixtures/signin_from_standard_client.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ INSERT INTO users
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at, given_name, family_name,
phone_number, job)
VALUES
(1, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'Jean', '0123456789', 'Sbire');
(1, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'Jean1', '0123456789', 'Sbire'),
(2, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'Jean2', '0123456789', 'Sbire');


INSERT INTO organizations
(id, siret, verified_email_domains, authorized_email_domains, created_at, updated_at)
VALUES
(1, '21340126800130', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
(1, '21340126800130', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2, '21920023500014', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

INSERT INTO users_organizations
(user_id, organization_id, is_external, verification_type, authentication_by_peers_type, has_been_greeted)
VALUES
(1, 1, false, 'verified_email_domain', 'all_members_notified', true);
(1, 1, false, 'verified_email_domain', 'all_members_notified', true),
(2, 1, false, 'verified_email_domain', 'all_members_notified', true),
(2, 2, false, 'verified_email_domain', 'all_members_notified', true);

INSERT INTO oidc_clients
(client_name, client_id, client_secret, redirect_uris,
Expand All @@ -22,8 +26,8 @@ INSERT INTO oidc_clients
authorization_signed_response_alg, introspection_signed_response_alg)
VALUES
('Oidc Test Client',
'client_id',
'client_secret',
'standard_client_id',
'standard_client_secret',
ARRAY [
'http://localhost:4000/login-callback'
],
Expand Down

0 comments on commit 95ac1cf

Please sign in to comment.