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

E2E tests #98

Merged
merged 27 commits into from
Sep 22, 2023
Merged

E2E tests #98

merged 27 commits into from
Sep 22, 2023

Conversation

psrpinto
Copy link
Member

@psrpinto psrpinto commented Sep 19, 2023

This PR adds end-to-end tests for the whole OIDC flow, including logging in and granting "consent".

This is intended to be executed in the developer's machine, and requires https://github.com/Automattic/matrix-oidc-playground/ to be running.

Added some documentation as well.

Output

$ composer test

> cd tests && yarn start
yarn run v1.22.19
$ ts-node-esm index.ts
Server listening at https://localhost:7443/
Discovered issuer https://localhost:8443/ {
  claim_types_supported: [ 'normal' ],
  claims_parameter_supported: false,
  grant_types_supported: [ 'authorization_code', 'implicit' ],
  request_parameter_supported: false,
  request_uri_parameter_supported: true,
  require_request_uri_registration: false,
  response_modes_supported: [ 'query', 'fragment' ],
  token_endpoint_auth_methods_supported: [ 'client_secret_basic' ],
  issuer: 'https://localhost:8443/',
  jwks_uri: 'https://localhost:8443/.well-known/jwks.json',
  authorization_endpoint: 'https://localhost:8443/wp-json/openid-connect/authorize',
  token_endpoint: 'https://localhost:8443/wp-json/openid-connect/token',
  userinfo_endpoint: 'https://localhost:8443/wp-json/openid-connect/userinfo',
  scopes_supported: [ 'openid', 'profile' ],
  response_types_supported: [ 'code' ],
  id_token_signing_alg_values_supported: [ 'RS256' ]
}

request https://localhost:8443/wp-json/openid-connect/authorize?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed

response 302 https://localhost:8443/wp-json/openid-connect/authorize?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed

request https://localhost:8443/wp-login.php?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

response 302 https://localhost:8443/wp-login.php?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

request https://localhost:8443/wp-login.php?redirect_to=https%3A%2F%2Flocalhost%3A8443%2Fwp-login.php%3Fclient_id%3Doidc-server-plugin-tests%26scope%3Dopenid%2520profile%26response_type%3Dcode%26redirect_uri%3Dhttps%253A%252F%252Flocalhost%253A7443%26state%3D73617bd67ee28358b02ab77a5c38758e%26nonce%3D7926217c4ad37e6db5cc8e6f78a421ed%26action%3Dopenid-authenticate&reauth=1

response 200 https://localhost:8443/wp-login.php?redirect_to=https%3A%2F%2Flocalhost%3A8443%2Fwp-login.php%3Fclient_id%3Doidc-server-plugin-tests%26scope%3Dopenid%2520profile%26response_type%3Dcode%26redirect_uri%3Dhttps%253A%252F%252Flocalhost%253A7443%26state%3D73617bd67ee28358b02ab77a5c38758e%26nonce%3D7926217c4ad37e6db5cc8e6f78a421ed%26action%3Dopenid-authenticate&reauth=1

request https://localhost:8443/wp-login.php FormData {
  [Symbol(state)]: [
    { name: 'testcookie', value: '1' },
    { name: 'log', value: 'admin' },
    { name: 'pwd', value: 'password' },
    {
      name: 'redirect_to',
      value: 'https://localhost:8443/wp-login.php?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate'
    }
  ]
}

response 302 https://localhost:8443/wp-login.php

request https://localhost:8443/wp-login.php?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

response 302 https://localhost:8443/wp-login.php?client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

request https://localhost:8443/wp-json/openid-connect/authorize?_wpnonce=897e20d432&client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https://localhost:7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

response 302 https://localhost:8443/wp-json/openid-connect/authorize?_wpnonce=897e20d432&client_id=oidc-server-plugin-tests&scope=openid%20profile&response_type=code&redirect_uri=https://localhost:7443&state=73617bd67ee28358b02ab77a5c38758e&nonce=7926217c4ad37e6db5cc8e6f78a421ed&action=openid-authenticate

request https://localhost:7443?code=e31f684979e728520301922fd4075a26751088a4&state=73617bd67ee28358b02ab77a5c38758e

response 200 https://localhost:7443?code=e31f684979e728520301922fd4075a26751088a4&state=73617bd67ee28358b02ab77a5c38758e

JWT token {
  iss: 'https://localhost:8443/',
  sub: 'admin',
  aud: 'oidc-server-plugin-tests',
  iat: 1695316090,
  exp: 1695319690,
  auth_time: 1695316090,
  nonce: '7926217c4ad37e6db5cc8e6f78a421ed'
}
userinfo {
  scope: 'openid profile',
  username: 'admin',
  name: 'admin',
  nickname: 'admin',
  picture: 'https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=96&d=mm&r=g',
  sub: 'admin'
}
✨  Done in 2.79s.

@psrpinto psrpinto force-pushed the integration-tests branch 2 times, most recently from 88ec958 to bcbf511 Compare September 19, 2023 17:19
@psrpinto psrpinto changed the title Integration tests E2E tests Sep 21, 2023
@psrpinto psrpinto marked this pull request as ready for review September 21, 2023 17:17
@psrpinto psrpinto merged commit fdee886 into main Sep 22, 2023
1 check passed
@psrpinto psrpinto deleted the integration-tests branch September 22, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant