Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/debrief_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ async def build_steps_d3(self, operation_ids):

for operation in operations:
# Add operation node
graph_output['nodes'].append(dict(name=operation.name, type='operation', id=op_id, img='operation',
graph_output['nodes'].append(dict(name=operation.name, type='operation', id=operation.id, img='operation',
timestamp=self._format_timestamp(operation.created)))

# Add agents for this operation
agents = [x for x in operation.agents if x]
self._add_agents_to_d3(agents, id_store, graph_output)
for agent in agents:
graph_output['links'].append(dict(source=op_id,
graph_output['links'].append(dict(source=operation.id,
target=id_store['agent' + agent.unique],
type='has_agent'))

Expand All @@ -42,12 +42,12 @@ async def build_steps_d3(self, operation_ids):
link_graph_id = id_store['link' + link.unique] = max(id_store.values()) + 1
display_name = link.ability.name + (' (cleanup)' if link.cleanup else '')
graph_output['nodes'].append(dict(type='link', name='link:'+link.unique, id=link_graph_id,
status=link.status, operation=op_id, img=link.ability.tactic,
status=link.status, operation=operation.id, img=link.ability.tactic,
attrs=dict(status=link.status, name=display_name),
timestamp=self._format_timestamp(link.created)))

if not previous_link_graph_id:
graph_output['links'].append(dict(source=op_id, target=link_graph_id, type='next_link'))
graph_output['links'].append(dict(source=operation.id, target=link_graph_id, type='next_link'))
else:
graph_output['links'].append(dict(source=previous_link_graph_id, target=link_graph_id,
type='next_link'))
Expand Down
8 changes: 6 additions & 2 deletions app/objects/c_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ def adjust_icon_svgs(path):
for icon_svg in svg.getroot().iter("{http://www.w3.org/2000/svg}svg"):
if icon_svg.get('id') == 'copy-svg':
continue
viewbox = [int(float(val)) for val in icon_svg.get('viewBox').split()]
viewbox_attr = icon_svg.get('viewBox')
if not viewbox_attr:
continue
viewbox = [int(float(val)) for val in viewbox_attr.split()]
aspect = viewbox[2] / viewbox[3]
icon_svg.set('width', str(round(float(icon_svg.get('height')) * aspect)))
if not icon_svg.get('id') or 'legend' not in icon_svg.get('id'):
icon_svg.set('x', '-' + str(int(icon_svg.get('width')) / 2))
svg.write(open(path, 'wb'))
with open(path, 'wb') as f:
svg.write(f)

@staticmethod
def get_table_object(val):
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "debrief-e2e-tests",
"version": "1.0.0",
"private": true,
"scripts": {
"test:e2e": "npx playwright test",
"test:e2e:headed": "npx playwright test --headed",
"test:e2e:debug": "npx playwright test --debug"
},
"devDependencies": {
"@playwright/test": "^1.49.0"
}
}
36 changes: 36 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

const CALDERA_URL = process.env.CALDERA_URL || 'http://localhost:8888';
const CALDERA_USER = process.env.CALDERA_USER || (process.env.CI ? undefined : 'admin');
const CALDERA_PASS = process.env.CALDERA_PASS || (process.env.CI ? undefined : 'admin');

if (process.env.CI && (!CALDERA_USER || !CALDERA_PASS)) {
throw new Error('CALDERA_USER and CALDERA_PASS must be set in CI');
}

module.exports = defineConfig({
testDir: './tests/e2e',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: 1,
reporter: [['html', { open: 'never' }], ['list']],
timeout: 60_000,
use: {
baseURL: CALDERA_URL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
headless: true,
httpCredentials: {
username: CALDERA_USER,
password: CALDERA_PASS,
},
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});
Loading