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 Sep 7, 2022
1 parent e58d3d1 commit 647822d
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions cypress/integration/oauth2/jwt.js
@@ -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 @@ -18,31 +18,33 @@ describe("OAuth 2.0 JSON Web Token Access Tokens", () => {
grant_types: ["authorization_code", "refresh_token"],
})

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 }
})
it('should return an Access Token in JWT format and validate it and a Refresh Token in opaque format', () => {
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("foo@bar.com")
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('foo@bar.com')
expect(body.client_id).to.eq(client.client_id)
expect(body.jti).to.not.be.empty
})
})
})
})

0 comments on commit 647822d

Please sign in to comment.