Skip to content

Commit

Permalink
refactor mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed Feb 3, 2024
1 parent fe6f8a9 commit bb5d3e6
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 1,148 deletions.
75 changes: 4 additions & 71 deletions nav-app/src/app/matrix/matrix-flat/matrix-flat.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatrixFlatComponent } from './matrix-flat.component';
import { Matrix, Technique } from '../../classes/stix';
import { TechniqueVM, ViewModel } from '../../classes';

let stixSDO = {
"name": "Name",
"description": "Description",
"created": "2001-01-01T01:01:00.000Z",
"modified": "2001-01-01T01:01:00.000Z",
"x_mitre_version": "1.0",
}
let tacticSDO = {
"id": "tactic-0",
...stixSDO,
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
let matrixSDO = {
"external_references": [
{
"external_id": "enterprise-attack",
"source_name": "mitre-attack",
"url": "https://attack.mitre.org/matrices/enterprise"
}
],
"id": "x-mitre-matrix--eafc1b4c-5e56-4965-bd4e-66a6a89c88cc",
"name":"Enterprise ATT&CK",
"tactic_refs": ["tactic-0"],
"tactics": [
{
"id": "tactic-0",
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
]
}
let templateSDO = {
...stixSDO,
"type": "attack-pattern",
"x_mitre_platforms": ['PRE'],
"kill_chain_phases": [
{
"kill_chain_name": "mitre-attack",
"phase_name": "reconnaissance"
}
],
}
let techniqueSDO = {
...templateSDO,
"id": "attack-pattern-0",
"external_references": [
{
"external_id": "T1595",
"url": "https://attack.mitre.org/techniques/T1595"
}
]
}
import * as MockData from '../../../tests/utils/mock-data';

describe('MatrixFlatComponent', () => {
let component: MatrixFlatComponent;
Expand All @@ -89,13 +22,13 @@ describe('MatrixFlatComponent', () => {
component = fixture.componentInstance;
component.viewModel = new ViewModel("layer","33","enterprise-attack-13",null);
let idToTacticSDO = new Map<string, any>();
idToTacticSDO.set("tactic-0", tacticSDO);
idToTacticSDO.set("tactic-0", MockData.TA0000);
component.viewModel.showTacticRowBackground = true;
let t1 = new Technique(techniqueSDO,[],null);
let t1 = new Technique(MockData.T0000,[],null);
technique_list.push(t1);
let tvm_1 = new TechniqueVM("T1595^reconnaissance");
component.viewModel.setTechniqueVM(tvm_1);
component.matrix = new Matrix(matrixSDO, idToTacticSDO,technique_list,null);
component.matrix = new Matrix(MockData.matrixSDO, idToTacticSDO,technique_list,null);
fixture.detectChanges();
});

Expand Down
75 changes: 4 additions & 71 deletions nav-app/src/app/matrix/matrix-mini/matrix-mini.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatrixMiniComponent } from './matrix-mini.component';
import { TechniqueVM, ViewModel } from '../../classes';
import { Matrix, Technique } from '../../classes/stix';

let stixSDO = {
"name": "Name",
"description": "Description",
"created": "2001-01-01T01:01:00.000Z",
"modified": "2001-01-01T01:01:00.000Z",
"x_mitre_version": "1.0",
}
let tacticSDO = {
"id": "tactic-0",
...stixSDO,
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
let matrixSDO = {
"external_references": [
{
"external_id": "enterprise-attack",
"source_name": "mitre-attack",
"url": "https://attack.mitre.org/matrices/enterprise"
}
],
"id": "x-mitre-matrix--eafc1b4c-5e56-4965-bd4e-66a6a89c88cc",
"name":"Enterprise ATT&CK",
"tactic_refs": ["tactic-0"],
"tactics": [
{
"id": "tactic-0",
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
]
}
let templateSDO = {
...stixSDO,
"type": "attack-pattern",
"x_mitre_platforms": ['PRE'],
"kill_chain_phases": [
{
"kill_chain_name": "mitre-attack",
"phase_name": "reconnaissance"
}
],
}
let techniqueSDO = {
...templateSDO,
"id": "attack-pattern-0",
"external_references": [
{
"external_id": "T1595",
"url": "https://attack.mitre.org/techniques/T1595"
}
]
}
import * as MockData from '../../../tests/utils/mock-data';

describe('MatrixMiniComponent', () => {
let component: MatrixMiniComponent;
Expand All @@ -89,13 +22,13 @@ describe('MatrixMiniComponent', () => {
component = fixture.componentInstance;
component.viewModel = new ViewModel("layer","33","enterprise-attack-13",null);
let idToTacticSDO = new Map<string, any>();
idToTacticSDO.set("tactic-0", tacticSDO);
idToTacticSDO.set("tactic-0", MockData.TA0000);
component.viewModel.showTacticRowBackground = true;
let t1 = new Technique(techniqueSDO,[],null);
let t1 = new Technique(MockData.T0000,[],null);
technique_list.push(t1);
let tvm_1 = new TechniqueVM("T1595^reconnaissance");
component.viewModel.setTechniqueVM(tvm_1);
component.matrix = new Matrix(matrixSDO, idToTacticSDO,technique_list,null);
component.matrix = new Matrix(MockData.matrixSDO, idToTacticSDO,technique_list,null);
fixture.detectChanges();
});

Expand Down
75 changes: 4 additions & 71 deletions nav-app/src/app/matrix/matrix-side/matrix-side.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,7 @@ import { MatrixSideComponent } from './matrix-side.component';
import { MatDialogModule } from '@angular/material/dialog';
import { TechniqueVM, ViewModel } from '../../classes';
import { Matrix, Technique } from '../../classes/stix';

let stixSDO = {
"name": "Name",
"description": "Description",
"created": "2001-01-01T01:01:00.000Z",
"modified": "2001-01-01T01:01:00.000Z",
"x_mitre_version": "1.0",
}
let tacticSDO = {
"id": "tactic-0",
...stixSDO,
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
let matrixSDO = {
"external_references": [
{
"external_id": "enterprise-attack",
"source_name": "mitre-attack",
"url": "https://attack.mitre.org/matrices/enterprise"
}
],
"id": "x-mitre-matrix--eafc1b4c-5e56-4965-bd4e-66a6a89c88cc",
"name":"Enterprise ATT&CK",
"tactic_refs": ["tactic-0"],
"tactics": [
{
"id": "tactic-0",
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
]
}
let templateSDO = {
...stixSDO,
"type": "attack-pattern",
"x_mitre_platforms": ['PRE'],
"kill_chain_phases": [
{
"kill_chain_name": "mitre-attack",
"phase_name": "reconnaissance"
}
],
}
let techniqueSDO = {
...templateSDO,
"id": "attack-pattern-0",
"external_references": [
{
"external_id": "T1595",
"url": "https://attack.mitre.org/techniques/T1595"
}
]
}
import * as MockData from '../../../tests/utils/mock-data';

describe('MatrixSideComponent', () => {
let component: MatrixSideComponent;
Expand All @@ -90,13 +23,13 @@ describe('MatrixSideComponent', () => {
component = fixture.componentInstance;
component.viewModel = new ViewModel("layer","33","enterprise-attack-13",null);
let idToTacticSDO = new Map<string, any>();
idToTacticSDO.set("tactic-0", tacticSDO);
idToTacticSDO.set("tactic-0", MockData.TA0000);
component.viewModel.showTacticRowBackground = true;
let t1 = new Technique(techniqueSDO,[],null);
let t1 = new Technique(MockData.T0000, [], null);
technique_list.push(t1);
let tvm_1 = new TechniqueVM("T1595^reconnaissance");
component.viewModel.setTechniqueVM(tvm_1);
component.matrix = new Matrix(matrixSDO, idToTacticSDO,technique_list,null);
component.matrix = new Matrix(MockData.matrixSDO, idToTacticSDO, technique_list,null);
fixture.detectChanges();
});

Expand Down
49 changes: 4 additions & 45 deletions nav-app/src/app/matrix/tactic-cell/tactic-cell.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { TechniqueVM, ViewModel } from '../../classes';
import { Tactic, Technique } from '../../classes/stix';
import { TacticCellComponent } from './tactic-cell.component';

let stixSDO = {
"name": "Name",
"description": "Description",
"created": "2001-01-01T01:01:00.000Z",
"modified": "2001-01-01T01:01:00.000Z",
"x_mitre_version": "1.0",
}
let tacticSDO = {
"id": "tactic-0",
...stixSDO,
"name": "Reconnaissance",
"type": "x-mitre-tactic",
"x_mitre_shortname": "reconnaissance",
"external_references": [
{
"external_id": "TA0043",
"url": "https://attack.mitre.org/tactics/TA0043"
}
]
}
let templateSDO = {
...stixSDO,
"type": "attack-pattern",
"x_mitre_platforms": ['PRE'],
"kill_chain_phases": [
{
"kill_chain_name": "mitre-attack",
"phase_name": "reconnaissance"
}
],
}
let techniqueSDO = {
...templateSDO,
"id": "attack-pattern-0",
"external_references": [
{
"external_id": "T1595",
"url": "https://attack.mitre.org/techniques/T1595"
}
]
}
import * as MockData from '../../../tests/utils/mock-data';

describe('TacticCellComponent', () => {
let component: TacticCellComponent;
Expand All @@ -59,13 +18,13 @@ describe('TacticCellComponent', () => {
let technique_list: Technique[] = [];
fixture = TestBed.createComponent(TacticCellComponent);
component = fixture.componentInstance;
component.viewModel = new ViewModel("layer","33","enterprise-attack-13",null);
component.viewModel = new ViewModel("layer", "33", "enterprise-attack-13", null);
component.viewModel.domainVersionID = "enterprise-attack-13";
let t1 = new Technique(techniqueSDO,[],null);
let t1 = new Technique(MockData.T0000, [], null);
technique_list.push(t1);
let tvm_1 = new TechniqueVM("T1595^reconnaissance");
component.viewModel.setTechniqueVM(tvm_1);
component.tactic = new Tactic(tacticSDO,technique_list,null);
component.tactic = new Tactic(MockData.TA0000, technique_list, null);
fixture.detectChanges();
});

Expand Down
Loading

0 comments on commit bb5d3e6

Please sign in to comment.