Skip to content

Commit

Permalink
test(e2e): resolve test regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Sep 7, 2022
1 parent 255b4e2 commit 30855d9
Showing 1 changed file with 82 additions and 76 deletions.
158 changes: 82 additions & 76 deletions cypress/integration/openid/prompt.js
Expand Up @@ -10,92 +10,98 @@ describe("OpenID Connect Prompt", () => {
})

it('should fail prompt=none when no session exists', function () {
const client = createClient(nc())
createClient(nc()).then((client) => {
cy.visit(
`${Cypress.env('client_url')}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&prompt=none`,
{ failOnStatusCode: false }
)

cy.visit(
`${Cypress.env("client_url")}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&prompt=none`,
{ failOnStatusCode: false },
)

cy.location().should(({ search, port }) => {
const query = qs.parse(search.substr(1))
expect(query.error).to.equal("login_required")
expect(port).to.equal(Cypress.env("client_port"))
cy.location().should(({ search, port }) => {
const query = qs.parse(search.substr(1))
expect(query.error).to.equal('login_required')
expect(port).to.equal(Cypress.env('client_port'))
})
})
})

it("should pass with prompt=none if both login and consent were remembered", function () {
const client = nc()

cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ["openid"], remember: true },
},
"openid",
)
it('should pass with prompt=none if both login and consent were remembered', function () {
createClient(nc()).then((client) => {
cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ['openid'], remember: true },
createClient: false
},
'openid'
)

cy.request(
`${Cypress.env("client_url")}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid`,
)
.its("body")
.then((body) => {
const {
result,
token: { access_token },
} = body
expect(result).to.equal("success")
expect(access_token).to.not.be.empty
})
cy.request(
`${Cypress.env('client_url')}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid`
)
.its('body')
.then((body) => {
const {
result,
token: { access_token }
} = body
expect(result).to.equal('success')
expect(access_token).to.not.be.empty
})
})
})

it("should require login with prompt=login even when session exists", function () {
const client = nc()
it('should require login with prompt=login even when session exists', function () {
createClient(nc()).then((client) => {
cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ['openid'], remember: true },
createClient: false
},
'openid'
)

cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ["openid"], remember: true },
},
"openid",
)

cy.request(
`${Cypress.env("client_url")}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid&prompt=login`,
)
.its("body")
.then((body) => {
expect(body).to.contain("Please log in")
})
cy.request(
`${Cypress.env('client_url')}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid&prompt=login`
)
.its('body')
.then((body) => {
expect(body).to.contain('Please log in')
})
})
})
it("should require consent with prompt=consent even when session exists", function () {
const client = nc()

cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ["openid"], remember: true },
},
"openid",
)
it('should require consent with prompt=consent even when session exists', function () {
createClient(nc()).then((client) => {
cy.authCodeFlow(
client,
{
login: { remember: true },
consent: { scope: ['openid'], remember: true },
createClient: false
},
'openid'
)

cy.request(
`${Cypress.env("client_url")}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid&prompt=consent`,
)
.its("body")
.then((body) => {
expect(body).to.contain("An application requests access to your data!")
})
cy.request(
`${Cypress.env('client_url')}/openid/code?client_id=${
client.client_id
}&client_secret=${client.client_secret}&scope=openid&prompt=consent`
)
.its('body')
.then((body) => {
expect(body).to.contain(
'An application requests access to your data!'
)
})
})
})
})

0 comments on commit 30855d9

Please sign in to comment.