Skip to content

Commit

Permalink
Merge branch 'main' into CA-237-Translate-key-words-and-some-AutoComp…
Browse files Browse the repository at this point in the history
…leteSelect
  • Loading branch information
Mohamed-Hacene committed Feb 29, 2024
2 parents 06935d9 + d184346 commit bc33f32
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 33 deletions.
15 changes: 13 additions & 2 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,11 @@ def quality_check(self) -> dict:
"object": _object,
}
)
if not self.authors:
if not self.authors.all():
info_lst.append(
{
"msg": _(
"{}: No author assigned to this risk risk assessment"
"{}: No author assigned to this risk assessment"
).format(str(self)),
"obj_type": "risk_assessment",
"object": _object,
Expand Down Expand Up @@ -1314,6 +1314,17 @@ def quality_check(self) -> dict:
"object": _object,
}
)

if not self.authors.all():
info_lst.append(
{
"msg": _(
"{}: No author assigned to this compliance assessment"
).format(str(self)),
"obj_type": "complianceassessment",
"object": _object,
}
)
# ---

# --- check on requirement assessments:
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/routes/(app)/x-rays/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@
<div class="space-y-2">
<div class="variant-soft-secondary rounded-token px-2 py-1">
<i class="fa-solid fa-circle-info mr-1" />
{#if quality_check.infos.length === 1}
<span class="font-bold">{quality_check.infos.length}</span>
{#if quality_check.info.length === 1}
<span class="font-bold">{quality_check.info.length}</span>
{m.infosFound({ s: ''})}
{:else}
<span class="font-bold">{quality_check.infos.length}</span>
<span class="font-bold">{quality_check.info.length}</span>
{m.infosFound({ s: 's'})}
{/if}
</div>
Expand Down Expand Up @@ -202,11 +202,11 @@
<div class="space-y-2">
<div class="variant-soft-secondary rounded-token px-2 py-1">
<i class="fa-solid fa-circle-info mr-1" />
{#if quality_check.infos.length === 1}
<span class="font-bold">{quality_check.infos.length}</span>
{#if quality_check.info.length === 1}
<span class="font-bold">{quality_check.info.length}</span>
{m.infosFound({ s: ''})}
{:else}
<span class="font-bold">{quality_check.infos.length}</span>
<span class="font-bold">{quality_check.info.length}</span>
{m.infosFound({ s: 's'})}
{/if}
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/tests/functional/detailed/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ for (const key of testPages) {
page
}) => {
await pages[key].itemDetail.verifyItem(items[key].build);
await pages[key].checkForUndefinedText();
page.url().includes('evidences') ? await pages[key].page.waitForTimeout(1000) : null; // prevent crashing
});

Expand Down
1 change: 1 addition & 0 deletions frontend/tests/functional/detailed/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ baseTest.skip('login page as expected title', async ({ page }) => {
test('login / logout process is working properly', async ({ loginPage, analyticsPage, sideBar, page }) => {
await loginPage.hasUrl(1);
await expect.soft(page.getByRole('heading', { name: 'Login into your account' })).toBeVisible();

Check failure on line 13 in frontend/tests/functional/detailed/login.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[chromium] › functional/detailed/login.test.ts:11:1 › login / logout process is working properly

2) [chromium] › functional/detailed/login.test.ts:11:1 › login / logout process is working properly Error: Timed out 10000ms waiting for expect(locator).toBeVisible() Locator: getByRole('heading', { name: 'Login into your account' }) Expected: visible Received: hidden Call log: - expect.soft.toBeVisible with timeout 10000ms - waiting for getByRole('heading', { name: 'Login into your account' }) 11 | test('login / logout process is working properly', async ({ loginPage, analyticsPage, sideBar, page }) => { 12 | await loginPage.hasUrl(1); > 13 | await expect.soft(page.getByRole('heading', { name: 'Login into your account' })).toBeVisible(); | ^ 14 | await loginPage.checkForUndefinedText(); 15 | await loginPage.login(); 16 | await analyticsPage.hasUrl(); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/detailed/login.test.ts:13:84

Check failure on line 13 in frontend/tests/functional/detailed/login.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[chromium] › functional/detailed/login.test.ts:11:1 › login / logout process is working properly

2) [chromium] › functional/detailed/login.test.ts:11:1 › login / logout process is working properly Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 10000ms waiting for expect(locator).toBeVisible() Locator: getByRole('heading', { name: 'Login into your account' }) Expected: visible Received: hidden Call log: - expect.soft.toBeVisible with timeout 10000ms - waiting for getByRole('heading', { name: 'Login into your account' }) 11 | test('login / logout process is working properly', async ({ loginPage, analyticsPage, sideBar, page }) => { 12 | await loginPage.hasUrl(1); > 13 | await expect.soft(page.getByRole('heading', { name: 'Login into your account' })).toBeVisible(); | ^ 14 | await loginPage.checkForUndefinedText(); 15 | await loginPage.login(); 16 | await analyticsPage.hasUrl(); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/detailed/login.test.ts:13:84
await loginPage.checkForUndefinedText();
await loginPage.login();
await analyticsPage.hasUrl();
sideBar.moreButton.click();
Expand Down
33 changes: 18 additions & 15 deletions frontend/tests/functional/nav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag
};

const locals = localItems(languageTag());

for await (const [key, value] of sideBar.items) {
for await (const item of value) {
if (item.href !== '/role-assignments') {
await sideBar.click(key, item.href);
await expect(page).toHaveURL(item.href);
if (item.name in temporaryPageTitle) {
await expect.soft(logedPage.pageTitle).toHaveText(temporaryPageTitle[item.name]);
} else {
await expect.soft(logedPage.pageTitle).toHaveText(locals[item.name]);
}
}
}
for await (const [key, value] of sideBar.items) {
for await (const item of value) {
if (item.href !== '/role-assignments') {
await sideBar.click(key, item.href);
await expect(page).toHaveURL(item.href);
if (item.name in temporaryPageTitle) {
await expect.soft(logedPage.pageTitle).toHaveText(temporaryPageTitle[item.name]);
} else {
await expect.soft(logedPage.pageTitle).toHaveText(locals[item.name]);
}
}
}
});
}
});

await test.step('user email is showing properly', async () => {
await expect(page.getByTestId('sidebar-user-account-display')).toHaveText(logedPage.email);
Expand All @@ -47,19 +46,23 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag
await test.step('more panel links are working properly', async () => {
await sideBar.moreButton.click();
await expect(sideBar.morePanel).not.toHaveAttribute('inert');
await logedPage.checkForUndefinedText();
await expect(sideBar.profileButton).toBeVisible();
await sideBar.profileButton.click();
await expect(sideBar.morePanel).toHaveAttribute('inert');
await expect(page).toHaveURL('/my-profile');
await expect.soft(logedPage.pageTitle).toHaveText('My profile');

await logedPage.checkForUndefinedText();

await sideBar.moreButton.click();
await expect(sideBar.morePanel).not.toHaveAttribute('inert');
await logedPage.checkForUndefinedText();
await expect(sideBar.aboutButton).toBeVisible();
await sideBar.aboutButton.click();
await expect(sideBar.morePanel).toHaveAttribute('inert');
await expect(logedPage.modalTitle).toBeVisible();
await expect.soft(logedPage.modalTitle).toHaveText('About CISO Assistant');
await logedPage.checkForUndefinedText();
await page.mouse.click(20, 20); // click outside the modal to close it
await expect(logedPage.modalTitle).not.toBeVisible();

Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/functional/user-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('user usual routine actions are working correctly', async ({
await pages.librariesPage.hasTitle();
await pages.librariesPage.hasTitle();

await pages.librariesPage.importLibrary(vars.framework.name, vars.framework.urn);
await pages.librariesPage.importLibrary(vars.framework.ref, vars.framework.urn);

await sideBar.click('Compliance', pages.frameworksPage.url);
await pages.frameworksPage.hasUrl();
Expand Down
4 changes: 4 additions & 0 deletions frontend/tests/utils/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export abstract class BasePage {

//TODO function to assert breadcrumb path is accurate

async checkForUndefinedText() {
await expect.soft(this.page.getByText('undefined'), "An undefined text is visible on the page").toHaveCount(0);
}

async isToastVisible(value: string, flags?: string | undefined, options?: {} | undefined) {
const toast = this.page.getByTestId('toast').filter({ hasText: new RegExp(value, flags) });
await expect(toast).toBeVisible(options);
Expand Down
12 changes: 6 additions & 6 deletions frontend/tests/utils/page-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PageContent extends BasePage {
await this.page.goto('/libraries');
await this.page.waitForURL('/libraries');

await this.importLibrary(dependency.name, dependency.urn);
await this.importLibrary(dependency.ref || dependency.name, dependency.urn);
await this.goto();
}

Expand All @@ -69,22 +69,22 @@ export class PageContent extends BasePage {
}
}

async importLibrary(name: string, urn: string, language: string = 'English') {
async importLibrary(ref: string, urn: string, language: string = 'English') {
if (await this.tab('Imported libraries').isVisible()) {
if (await this.getRow(name).isHidden()) {
if (await this.getRow(ref).isHidden()) {
await this.tab('Libraries store').click();
expect(this.tab('Libraries store').getAttribute('aria-selected')).toBeTruthy();
} else {
return;
}
}
await this.importItemButton(name, language).click();
await this.importItemButton(ref, language).click();
await this.isToastVisible('Successfully imported library ' + urn + '.+', undefined, {
timeout: 15000
});
await this.tab('Imported libraries').click();
expect(this.tab('Imported libraries').getAttribute('aria-selected')).toBeTruthy();
expect(this.getRow(name)).toBeVisible();
expect(this.getRow(ref)).toBeVisible();
}

async viewItemDetail(value?: string) {
Expand Down Expand Up @@ -134,6 +134,6 @@ export class PageContent extends BasePage {
importItemButton(value: string, language?: string) {
return language
? this.getRow(value, language).getByTestId('tablerow-import-button')
: this.getRow(value).getByTestId('tablerow-import-button').first();
: this.getRow(value).getByTestId('tablerow-import-button');
}
}
13 changes: 10 additions & 3 deletions frontend/tests/utils/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default {
validator: 'Validator'
},
framework: {
name: 'NIST CSF',
name: 'NIST CSF v1.1',
ref: 'NIST-CSF-1.1',
urn: 'urn:intuitem:risk:library:nist-csf-1.1'
},
matrix: {
Expand All @@ -39,6 +40,7 @@ export default {
category: 'policy',
library: {
name: 'Documents and policies',
ref: 'doc-pol',
urn: 'urn:intuitem:risk:library:doc-pol'
},
urn: 'urn:intuitem:risk:function:POL.PHYSICAL'
Expand All @@ -48,6 +50,7 @@ export default {
category: 'process',
library: {
name: 'Documents and policies',
ref: 'doc-pol',
urn: 'urn:intuitem:risk:library:doc-pol'
},
urn: 'urn:intuitem:risk:function:DOC.CONTROLS'
Expand All @@ -56,6 +59,7 @@ export default {
name: 'Exfiltration Over Other Network Medium',
library: {
name: 'Mitre ATT&CK v14 - Threats and mitigations',
ref: 'mitre-attack',
urn: 'urn:intuitem:risk:library:mitre-attack-v14'
},
urn: 'urn:intuitem:risk:threat:mitre-attack:T1011'
Expand All @@ -64,21 +68,24 @@ export default {
name: 'Exfiltration Over Physical Medium',
library: {
name: 'Mitre ATT&CK v14 - Threats and mitigations',
ref: 'mitre-attack',
urn: 'urn:intuitem:risk:library:mitre-attack-v14'
},
urn: 'urn:intuitem:risk:threat:mitre-attack:T1052'
},
requirement_assessment: {
name: 'RC.RP - Recovery Planning',
library: {
name: 'NIST CSF',
name: 'NIST CSF v1.1',
ref: 'NIST-CSF-1.1',
urn: 'urn:intuitem:risk:library:nist-csf-1.1'
}
},
requirement_assessment2: {
name: 'ID.GV - Governance',
library: {
name: 'NIST CSF',
name: 'NIST CSF v1.1',
ref: 'NIST-CSF-1.1',
urn: 'urn:intuitem:risk:library:nist-csf-1.1'
}
}
Expand Down

0 comments on commit bc33f32

Please sign in to comment.