mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 23:32:47 +01:00
More e2d tests (#258)
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -96,6 +96,7 @@ jobs:
|
|||||||
cypress:
|
cypress:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
test: [ tickets, templates, playbooks ]
|
||||||
auth: [ simple, keycloak ]
|
auth: [ simple, keycloak ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -164,6 +165,7 @@ jobs:
|
|||||||
- uses: cypress-io/github-action@v4
|
- uses: cypress-io/github-action@v4
|
||||||
env:
|
env:
|
||||||
CYPRESS_AUTH: ${{ matrix.auth }}
|
CYPRESS_AUTH: ${{ matrix.auth }}
|
||||||
|
CYPRESS_TEST: ${{ matrix.test }}
|
||||||
with:
|
with:
|
||||||
browser: chrome
|
browser: chrome
|
||||||
working-directory: ui
|
working-directory: ui
|
||||||
|
|||||||
@@ -1,32 +1,148 @@
|
|||||||
describe('user', () => {
|
beforeEach(() => {
|
||||||
it('open ticket', () => {
|
cy.visit('/');
|
||||||
cy.visit('/');
|
|
||||||
|
|
||||||
if (Cypress.env('AUTH') === 'simple') {
|
cy.login();
|
||||||
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.getCookie('user').should('exist');
|
||||||
|
|
||||||
cy.intercept('GET', '/api/userdata/demo', { fixture: 'userdata_demo.json' })
|
cy.intercept('GET', '/api/userdata/demo', { fixture: 'userdata_demo.json' })
|
||||||
cy.intercept('GET', '/api/users/demo', { fixture: 'user_demo.json' })
|
cy.intercept('GET', '/api/users/demo', { fixture: 'user_demo.json' })
|
||||||
|
|
||||||
cy.visit('http://localhost/ui/tickets');
|
|
||||||
|
|
||||||
// clear caql
|
|
||||||
cy.get("#caqlbar > div > div > div > div > div:nth-child(2) > div > button").click();
|
|
||||||
|
|
||||||
// open ticket
|
|
||||||
cy.contains("live zebra").click()
|
|
||||||
|
|
||||||
// assert url
|
|
||||||
cy.url().should('eq', "http://localhost/ui/tickets/8123")
|
|
||||||
|
|
||||||
// assert title
|
|
||||||
cy.get("h1").should("have.text", " Incident #8123: live zebra ")
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (Cypress.env('TEST') === 'tickets') {
|
||||||
|
describe('tickets', () => {
|
||||||
|
it('open ticket', () => {
|
||||||
|
cy.visit('http://localhost/ui/tickets');
|
||||||
|
|
||||||
|
// clear caql
|
||||||
|
cy.get("#caqlbar > div > div > div > div > div:nth-child(2) > div > button").click();
|
||||||
|
|
||||||
|
// open ticket
|
||||||
|
cy.contains("live zebra").click()
|
||||||
|
|
||||||
|
// assert url
|
||||||
|
cy.url().should('eq', "http://localhost/ui/tickets/8123")
|
||||||
|
|
||||||
|
// assert title
|
||||||
|
cy.get("h1").should("have.text", " Incident #8123: live zebra ")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cypress.env('TEST') === 'templates') {
|
||||||
|
describe('templates', () => {
|
||||||
|
it('create template', () => {
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
cy.contains('Templates').click();
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
|
||||||
|
cy.get("body").then($body => {
|
||||||
|
if ($body.find('a[href="/ui/templates/description-only"]').length > 0) {
|
||||||
|
cy.get('a[href="/ui/templates/description-only"]').trigger('mouseover');
|
||||||
|
cy.get('a[href="/ui/templates/description-only"] button').click();
|
||||||
|
cy.get("#delete-button").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.contains("New Template").click();
|
||||||
|
cy.url().should('eq', "http://localhost/ui/templates/new");
|
||||||
|
cy.get("#name-edit").click().clear().type("DescriptionOnly");
|
||||||
|
cy.get("#template-edit #advanced").click({force: true});
|
||||||
|
cy.get(".prism-editor__textarea").clear().type('{ "type": "object", "name": "Incident", "required": [ "description" ], "properties": { "description": { "title": "Description", "type": "string", "x-display": "textarea" } } }', {parseSpecialCharSequences: false});
|
||||||
|
cy.contains("Create").click();
|
||||||
|
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
cy.contains('Alerts').click();
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
|
||||||
|
cy.contains("New Alert").click();
|
||||||
|
cy.get("#title-edit").type("New Alert");
|
||||||
|
cy.get("#templates-edit .v-input__slot").click();
|
||||||
|
cy.contains("DescriptionOnly").click();
|
||||||
|
cy.contains("Create").click();
|
||||||
|
cy.wait(1000);
|
||||||
|
|
||||||
|
cy.get("#description").type("Lorem Ipsum");
|
||||||
|
cy.contains("Save Details").click();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cypress.env('TEST') === 'playbooks') {
|
||||||
|
describe('playbooks', () => {
|
||||||
|
it('create playbook', () => {
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
cy.contains('Playbooks').click();
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
|
||||||
|
cy.get("body").then($body => {
|
||||||
|
if ($body.find('a[href="/ui/playbooks/test"]').length > 0) {
|
||||||
|
cy.get('a[href="/ui/playbooks/test"]').trigger('mouseover');
|
||||||
|
cy.get('a[href="/ui/playbooks/test"] button').click();
|
||||||
|
cy.get("#delete-button").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.contains("New Playbook").click();
|
||||||
|
cy.url().should('eq', "http://localhost/ui/playbooks/new");
|
||||||
|
cy.get(".prism-editor__textarea").clear().type('name: Test\n' +
|
||||||
|
'tasks:\n' +
|
||||||
|
' input:\n' +
|
||||||
|
' name: Enter something to hash\n' +
|
||||||
|
'type: input\n' +
|
||||||
|
'schema:\n' +
|
||||||
|
' title: Something\n' +
|
||||||
|
'type: object\n' +
|
||||||
|
'properties:\n' +
|
||||||
|
' something:\n' +
|
||||||
|
' type: string\n' +
|
||||||
|
'title: Something\n' +
|
||||||
|
'default: ""\n' +
|
||||||
|
'{backspace}{backspace}{backspace}next:\n' +
|
||||||
|
' hash: "something != \'\'"\n' +
|
||||||
|
'{backspace}{backspace}\n' +
|
||||||
|
'hash:\n' +
|
||||||
|
' name: Hash the something\n' +
|
||||||
|
'type: automation\n' +
|
||||||
|
'automation: hash.sha1\n' +
|
||||||
|
'payload:\n' +
|
||||||
|
' default: "playbook.tasks[\'input\'].data[\'something\']"\n' +
|
||||||
|
'{backspace}next:\n' +
|
||||||
|
' comment: "hash != \'\'"\n' +
|
||||||
|
'{backspace}{backspace}\n' +
|
||||||
|
'comment:\n' +
|
||||||
|
' name: Comment the hash\n' +
|
||||||
|
'type: automation\n' +
|
||||||
|
'automation: comment\n' +
|
||||||
|
'payload:\n' +
|
||||||
|
' default: "playbook.tasks[\'hash\'].data[\'hash\']"\n' +
|
||||||
|
'{backspace}next:\n' +
|
||||||
|
' done: "done"\n' +
|
||||||
|
'{backspace}{backspace}\n' +
|
||||||
|
'done:\n' +
|
||||||
|
' name: You can close this case now\n' +
|
||||||
|
'type: task\n');
|
||||||
|
cy.scrollTo('bottom');
|
||||||
|
cy.contains("Create").click();
|
||||||
|
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
cy.contains('Alerts').click();
|
||||||
|
cy.get("#toggle_menu").click();
|
||||||
|
|
||||||
|
cy.contains("New Alert").click();
|
||||||
|
cy.get("#title-edit").type("New Alert");
|
||||||
|
cy.get("#playbooks-edit .v-input__slot").click();
|
||||||
|
cy.contains("Test").click();
|
||||||
|
cy.contains("Create").click();
|
||||||
|
cy.wait(1000);
|
||||||
|
|
||||||
|
cy.scrollTo('bottom');
|
||||||
|
cy.get(".playbook-test .tasks").contains("Enter something to hash").click();
|
||||||
|
cy.get("#something").type("my test value");
|
||||||
|
cy.contains("Complete").click();
|
||||||
|
|
||||||
|
// cy.wait(300 * 1000);
|
||||||
|
// cy.contains("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3").should('exist');
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,10 +14,15 @@ Cypress.on('uncaught:exception', (err, runnable) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('login', (options = {}) => {
|
Cypress.Commands.add('login', (options = {}) => {
|
||||||
// login
|
if (Cypress.env('AUTH') === 'simple') {
|
||||||
cy.contains("Name").click({force: true});
|
cy.contains("Name").click({force: true});
|
||||||
cy.get("#username").type("tom");
|
cy.get("#username").type("tom");
|
||||||
cy.contains("Password").click({force: true});
|
cy.contains("Password").click({force: true});
|
||||||
cy.get("#password").type("tom");
|
cy.get("#password").type("tom");
|
||||||
cy.get("button").contains("Login").click();
|
cy.get("button").contains("Login").click();
|
||||||
|
} else if (Cypress.env('AUTH') === 'keycloak') {
|
||||||
|
cy.get("#username").type("bob");
|
||||||
|
cy.get("#password").type("bob");
|
||||||
|
cy.get("#kc-login").click();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -179,7 +179,7 @@
|
|||||||
|
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
<v-snackbar v-model="snackbar" :color="$store.state.alert.type" :timeout="$store.state.alert.type === 'error' ? -1 : 5000" outlined>
|
<v-snackbar id="alert" v-model="snackbar" :color="$store.state.alert.type" :timeout="$store.state.alert.type === 'error' ? -1 : 5000" outlined>
|
||||||
<b style="display: block">{{ $store.state.alert.name | capitalize }}</b>
|
<b style="display: block">{{ $store.state.alert.name | capitalize }}</b>
|
||||||
{{ $store.state.alert.detail }}
|
{{ $store.state.alert.detail }}
|
||||||
<template v-slot:action="{ attrs }">
|
<template v-slot:action="{ attrs }">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<div class="d-flex" >
|
<div class="d-flex" >
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-switch
|
<v-switch
|
||||||
|
id="advanced"
|
||||||
v-model="advanced"
|
v-model="advanced"
|
||||||
label="Advanced"
|
label="Advanced"
|
||||||
class="float-right mt-0"
|
class="float-right mt-0"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<prism-editor
|
<prism-editor
|
||||||
v-if="showEditor"
|
v-if="showEditor"
|
||||||
class="my-editor"
|
class="editor"
|
||||||
v-model="code"
|
v-model="code"
|
||||||
:highlight="highlighter"
|
:highlight="highlighter"
|
||||||
line-numbers
|
line-numbers
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
<v-card-title> Delete {{ singular }} {{ deleteName }} ? </v-card-title>
|
<v-card-title> Delete {{ singular }} {{ deleteName }} ? </v-card-title>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn color="error" text @click="dialog = false">Cancel</v-btn>
|
<v-btn id="cancel-button" color="error" text @click="dialog = false">Cancel</v-btn>
|
||||||
<v-btn color="success" outlined @click="deleteItem(deleteName)">Delete</v-btn>
|
<v-btn id="delete-button" color="success" outlined @click="deleteItem(deleteName)">Delete</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
<h2 v-else>Edit Template: {{ template.name }}</h2>
|
<h2 v-else>Edit Template: {{ template.name }}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-text-field label="Name" v-model="template.name" class="flex-grow-0 flex-shrink-0" :readonly="readonly"></v-text-field>
|
<v-text-field id="name-edit" label="Name" v-model="template.name" class="flex-grow-0 flex-shrink-0" :readonly="readonly"></v-text-field>
|
||||||
|
|
||||||
<AdvancedJSONSchemaEditor v-if="schema" @save="save" :schema="schema" :readonly="readonly" :hidepreview="false"></AdvancedJSONSchemaEditor>
|
<AdvancedJSONSchemaEditor id="template-edit" v-if="schema" @save="save" :schema="schema" :readonly="readonly" :hidepreview="false"></AdvancedJSONSchemaEditor>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -278,7 +278,7 @@
|
|||||||
<div
|
<div
|
||||||
v-for="(playbook, playbookid) in ticket.playbooks"
|
v-for="(playbook, playbookid) in ticket.playbooks"
|
||||||
:key="playbookid"
|
:key="playbookid"
|
||||||
class="mb-2"
|
:class="'playbook-'+playbookid + ' mb-2'"
|
||||||
>
|
>
|
||||||
<v-card color="cards" flat>
|
<v-card color="cards" flat>
|
||||||
<v-card-subtitle class="d-flex pa-2 pb-1 mb-0" style="line-height: 28px;">
|
<v-card-subtitle class="d-flex pa-2 pb-1 mb-0" style="line-height: 28px;">
|
||||||
@@ -310,7 +310,7 @@
|
|||||||
class="mx-4"
|
class="mx-4"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<v-list dense color="cards" class="py-0">
|
<v-list dense color="cards" class="tasks py-0">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="taskwithid in stasks(playbookid)"
|
v-for="taskwithid in stasks(playbookid)"
|
||||||
:key="taskwithid.id"
|
:key="taskwithid.id"
|
||||||
|
|||||||
@@ -2,24 +2,28 @@
|
|||||||
<div class="mt-8">
|
<div class="mt-8">
|
||||||
<h2>New {{ $route.params.type | capitalize }}</h2>
|
<h2>New {{ $route.params.type | capitalize }}</h2>
|
||||||
<v-form class="create clearfix">
|
<v-form class="create clearfix">
|
||||||
<v-text-field label="Title" v-model="name"></v-text-field>
|
<v-text-field id="title-edit" label="Title" v-model="name"></v-text-field>
|
||||||
|
|
||||||
<v-select
|
<div id="playbooks-edit">
|
||||||
label="Playbooks"
|
<v-select
|
||||||
:items="playbooks"
|
label="Playbooks"
|
||||||
item-text="name"
|
:items="playbooks"
|
||||||
return-object
|
item-text="name"
|
||||||
multiple
|
return-object
|
||||||
v-model="selectedPlaybooks"
|
multiple
|
||||||
></v-select>
|
v-model="selectedPlaybooks"
|
||||||
|
></v-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<v-select
|
<div id="templates-edit">
|
||||||
label="Template"
|
<v-select
|
||||||
:items="templates"
|
label="Template"
|
||||||
item-text="name"
|
:items="templates"
|
||||||
return-object
|
item-text="name"
|
||||||
v-model="selectedTemplate"
|
return-object
|
||||||
></v-select>
|
v-model="selectedTemplate"
|
||||||
|
></v-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<v-subheader class="pl-0 mt-4" style="height: 20px">Details</v-subheader>
|
<v-subheader class="pl-0 mt-4" style="height: 20px">Details</v-subheader>
|
||||||
<div v-if="selectedTemplate !== undefined" class="details">
|
<div v-if="selectedTemplate !== undefined" class="details">
|
||||||
|
|||||||
Reference in New Issue
Block a user