Skip to content

Commit

Permalink
test(e2e): fix jwt regression
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jun 17, 2022
1 parent d773fe0 commit 9d03440
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions cypress/integration/oauth2/jwt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prng } from '../../helpers'
import { createClient, prng } from '../../helpers'

describe('OAuth 2.0 JSON Web Token Access Tokens', () => {
before(function () {
Expand All @@ -19,30 +19,32 @@ describe('OAuth 2.0 JSON Web Token Access Tokens', () => {
})

it('should return an Access Token in JWT format and validate it and a Refresh Token in opaque format', () => {
const client = nc()
cy.authCodeFlow(client, {
consent: { scope: ['offline_access'], createClient: true }
})
createClient(nc()).then((client) => {
cy.authCodeFlow(client, {
consent: { scope: ['offline_access'], createClient: true },
createClient: false
})

cy.request(`${Cypress.env('client_url')}/oauth2/refresh`)
.its('body')
.then((body) => {
const { result, token } = body
expect(result).to.equal('success')
cy.request(`${Cypress.env('client_url')}/oauth2/refresh`)
.its('body')
.then((body) => {
const { result, token } = body
expect(result).to.equal('success')

expect(token.access_token).to.not.be.empty
expect(token.refresh_token).to.not.be.empty
expect(token.access_token.split('.').length).to.equal(3)
expect(token.refresh_token.split('.').length).to.equal(2)
})
expect(token.access_token).to.not.be.empty
expect(token.refresh_token).to.not.be.empty
expect(token.access_token.split('.').length).to.equal(3)
expect(token.refresh_token.split('.').length).to.equal(2)
})

cy.request(`${Cypress.env('client_url')}/oauth2/validate-jwt`)
.its('body')
.then((body) => {
console.log(body)
expect(body.sub).to.eq('[email protected]')
expect(body.client_id).to.eq(client.client_id)
expect(body.jti).to.not.be.empty
})
cy.request(`${Cypress.env('client_url')}/oauth2/validate-jwt`)
.its('body')
.then((body) => {
console.log(body)
expect(body.sub).to.eq('[email protected]')
expect(body.client_id).to.eq(client.client_id)
expect(body.jti).to.not.be.empty
})
})
})
})

0 comments on commit 9d03440

Please sign in to comment.