mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-29 02:22:28 +00:00
Cypress tests for OAuth login
This commit is contained in:
parent
d048d1fc98
commit
47d7896301
@ -33,6 +33,7 @@ func TestShutdown(t *testing.T) {
|
|||||||
err := Shutdown()
|
err := Shutdown()
|
||||||
require.Nil(t, err, "Shutdown should not return an error when jobqueue is started")
|
require.Nil(t, err, "Shutdown should not return an error when jobqueue is started")
|
||||||
|
|
||||||
|
// nolint: gosimple
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
switch ctx.Err() {
|
switch ctx.Err() {
|
||||||
|
Binary file not shown.
@ -1,16 +1,10 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
const { curry } = require("lodash");
|
|
||||||
|
|
||||||
// WIP
|
|
||||||
|
|
||||||
describe('LDAP with Authentik', () => {
|
describe('LDAP with Authentik', () => {
|
||||||
let token;
|
let token;
|
||||||
if (Cypress.env('stack') === 'postgres') {
|
if (Cypress.env('stack') === 'postgres') {
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.task('log', 'STACK IS: ' + Cypress.env('stack'));
|
|
||||||
|
|
||||||
cy.resetUsers();
|
cy.resetUsers();
|
||||||
cy.getToken().then((tok) => {
|
cy.getToken().then((tok) => {
|
||||||
token = tok;
|
token = tok;
|
||||||
|
66
test/cypress/e2e/api/OAuth.cy.js
Normal file
66
test/cypress/e2e/api/OAuth.cy.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
describe('OAuth with Authentik', () => {
|
||||||
|
let token;
|
||||||
|
if (Cypress.env('stack') === 'postgres') {
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.resetUsers();
|
||||||
|
cy.getToken().then((tok) => {
|
||||||
|
token = tok;
|
||||||
|
|
||||||
|
cy.task('backendApiPut', {
|
||||||
|
token: token,
|
||||||
|
path: '/api/settings/oauth-auth',
|
||||||
|
data: {
|
||||||
|
value: {
|
||||||
|
client_id: 'U5gCy0ymU8OofWS4nmkAPugCbWkFkkPztap38ReD',
|
||||||
|
client_secret: '9ZFClxwp7LzbfhIDk7k9DngQNQfwDAYqPrQMGXjFumCvQZATtXCwme20o0TnLP6uEHUkKqEFOInhxp01gVeaHCLW83iTK4PonoUnpFnXgyZAcu0H3zBxxOkVtRwACaoW',
|
||||||
|
authorization_url: 'http://authentik-ldap:9000/application/o/authorize/',
|
||||||
|
resource_url: 'http://authentik-ldap:9000/application/o/userinfo/',
|
||||||
|
token_url: 'http://authentik-ldap:9000/application/o/token/',
|
||||||
|
logout_url: 'http://authentik-ldap:9000/application/o/npm3/end-session/',
|
||||||
|
identifier: 'preferred_username',
|
||||||
|
scopes: [],
|
||||||
|
auto_create_user: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).then((data) => {
|
||||||
|
cy.validateSwaggerSchema('put', 200, '/settings/{name}', data);
|
||||||
|
expect(data.result).to.have.property('id');
|
||||||
|
expect(data.result.id).to.be.greaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.task('backendApiPut', {
|
||||||
|
token: token,
|
||||||
|
path: '/api/settings/auth-methods',
|
||||||
|
data: {
|
||||||
|
value: [
|
||||||
|
'local',
|
||||||
|
'oauth'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}).then((data) => {
|
||||||
|
cy.validateSwaggerSchema('put', 200, '/settings/{name}', data);
|
||||||
|
expect(data.result).to.have.property('id');
|
||||||
|
expect(data.result.id).to.be.greaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should log in with OAuth', function() {
|
||||||
|
cy.task('backendApiGet', {
|
||||||
|
token: token,
|
||||||
|
path: '/oauth/login?redirect_base=http%3A%2F%2Ffullstack%3A81',
|
||||||
|
}).then((data) => {
|
||||||
|
expect(data).to.have.property('result');
|
||||||
|
cy.visit(data.result);
|
||||||
|
cy.get('input[name="uidField"]').type('cypress');
|
||||||
|
cy.get('button[type="submit"]').click();
|
||||||
|
cy.get('input[name="password"]').type('fqXBfUYqHvYqiwBHWW7f');
|
||||||
|
cy.get('button[type="submit"]').click();
|
||||||
|
cy.url().should('match', /fullstack/)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user