mitre-attack / attack-data-model

ATT&CK Data Model (ADM): A TypeScript library for structured interaction with MITRE ATT&CK datasets. Uses Zod schemas, TypeScript types, and ES6 classes to provide a type-safe, object-oriented interface for STIX 2.1 formatted ATT&CK data. Features parsing, validation, and serialization capabilities.
Apache License 2.0
1 stars 0 forks source link

Object Testing #3

Closed seansica closed 1 week ago

seansica commented 1 month ago

ATT&CK Schema Testing Guide

Overview

This issue outlines the process for writing comprehensive test suites for ATT&CK schemas using Jest. Each developer will be assigned one or more schemas to test. Follow these instructions to ensure consistent and thorough testing across all schemas.

Assignments

Schema Module Assigned To Status Reviewer
campaign.schema.ts @adpare Done @seansica
matrix.schema.ts @erinehall Done @seansica
group.schema.ts @erinehall Done @seansica
collection.schema.ts @adpare Done @seansica
tactic.schema.ts @adpare Done @seansica
technique.schema.ts @seansica Done @seansica
asset.schema.ts @clemiller Done @seansica
tool.schema.ts @adpare Done @seansica
malware.schema.ts @adpare Done @seansica
identity.schema.ts @adpare Done @seansica
mitigation.schema.ts @erinehall Done @seansica
marking-definition.schema.ts @erinehall Done @seansica
data-source.schema.ts @adpare Done @seansica
data-component.schema.ts @adpare Done @seansica
relationship.schema.ts (sro) @clemiller Done @seansica
stix-bundle.schema.ts @seansica Done @seansica

Test Structure

Use the following template for your test suite: template.test.ts

Test Categories Explanation

True Positives Tests

These tests ensure that the schema accepts valid inputs. Include tests for:

True Negative Tests

These tests ensure that the schema rejects invalid inputs. For each property explicitly defined in the schema:

Also include schema-level tests, such as rejecting unknown properties.

Edge Cases and Special Scenarios

Create an it test for each case covered in the schema refinements (e.g., refine or superRefine). These tests should cover any complex validation logic specific to the schema.

Validate All Objects

This section tests the schema against all objects in the global.attackData.objectsByType array for the specific object type.

Instructions

  1. Create a new test file for your assigned schema(s) named [schema-name].test.ts.
  2. Copy the template above and adapt it to your specific schema.
  3. Implement tests for each category as described.
  4. Ensure all tests pass and provide good coverage of the schema.

Tips