mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-05-03 07:58:11 +02:00
Add simple auth (#186)
This commit is contained in:
@@ -2,31 +2,31 @@ describe('user', () => {
|
||||
it('open ticket', () => {
|
||||
cy.visit('/');
|
||||
|
||||
// login
|
||||
cy.get("#username").type("bob");
|
||||
cy.get("#password").type("bob");
|
||||
cy.get("#kc-login").click();
|
||||
if (Cypress.env('AUTH') === 'simple') {
|
||||
cy.login();
|
||||
} else if (Cypress.env('AUTH') === 'keycloak') {
|
||||
cy.get("#username").type("bob");
|
||||
cy.get("#password").type("bob");
|
||||
cy.get("#kc-login").click();
|
||||
}
|
||||
|
||||
cy.getCookie('user').should('exist');
|
||||
|
||||
cy.intercept('GET', '/api/userdata/demo', { fixture: 'userdata_demo.json' })
|
||||
cy.intercept('GET', '/api/users/demo', { fixture: 'user_demo.json' })
|
||||
|
||||
cy.origin('http://localhost', () => {
|
||||
cy.visit('/tickets');
|
||||
cy.visit('http://localhost/ui/tickets');
|
||||
|
||||
// clear caql
|
||||
cy.get("#app > div > main > div > div > div > div > header > div > div.v-input.v-input--hide-details.v-input--is-label-active.v-input--is-dirty.v-input--dense.theme--light.v-text-field.v-text-field--single-line.v-text-field--solo.v-text-field--solo-flat.v-text-field--is-booted.v-text-field--enclosed.v-text-field--placeholder > div > div > div:nth-child(2) > div > button")
|
||||
.click();
|
||||
// clear caql
|
||||
cy.get("#caqlbar > div > div > div > div > div:nth-child(2) > div > button").click();
|
||||
|
||||
// open ticket
|
||||
cy.get("#app > div > main > div > div > div > div > div > div.v-data-table__wrapper > table > tbody > tr:nth-child(1) > td > a")
|
||||
.click()
|
||||
// open ticket
|
||||
cy.contains("live zebra").click()
|
||||
|
||||
// assert url
|
||||
cy.url().should('eq', "http://localhost/tickets/8123")
|
||||
// assert url
|
||||
cy.url().should('eq', "http://localhost/ui/tickets/8123")
|
||||
|
||||
// assert title
|
||||
cy.get("#\\38 123 > div > div > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div > div.col-lg-8.col-12 > h1")
|
||||
.should("have.text", " Incident #8123: live zebra ")
|
||||
})
|
||||
// assert title
|
||||
cy.get("h1").should("have.text", " Incident #8123: live zebra ")
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,22 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
||||
@@ -4,3 +4,20 @@
|
||||
// ***********************************************************
|
||||
|
||||
import './commands'
|
||||
|
||||
Cypress.Cookies.defaults({
|
||||
preserve: 'user',
|
||||
})
|
||||
|
||||
Cypress.on('uncaught:exception', (err, runnable) => {
|
||||
return false
|
||||
})
|
||||
|
||||
Cypress.Commands.add('login', (options = {}) => {
|
||||
// login
|
||||
cy.contains("Name").click({force: true});
|
||||
cy.get("#username").type("tom");
|
||||
cy.contains("Password").click({force: true});
|
||||
cy.get("#password").type("tom");
|
||||
cy.get("button").contains("Login").click();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user