Skip to content

Commit 70b059e

Browse files
Goumiesmarieflorescontact
authored andcommitted
[backend] WIP Update model (#4538)
1 parent 6a76582 commit 70b059e

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

opencti-platform/opencti-front/src/schema/relay.schema.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -9881,6 +9881,7 @@ type CaseIncident implements BasicObject & StixObject & StixCoreObject & StixDom
98819881
response_types: [String!]
98829882
severity: String
98839883
priority: String
9884+
authorized_members: [MemberAccess!]
98849885
}
98859886

98869887
enum CaseIncidentsOrdering {

opencti-platform/opencti-graphql/tests/02-integration/02-resolvers/case-incident-response-test.ts

+69-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { describe, it, expect } from 'vitest';
22
import gql from 'graphql-tag';
33
import { queryAsAdmin } from '../../utils/testQuery';
4+
import type { CaseIncident } from '../../../src/generated/graphql';
45

56
describe('Case Incident Response resolver standard behavior', () => {
6-
let caseIncidentResponseId = '';
7+
let caseIncidentResponse: CaseIncident;
78

89
const READ_QUERY = gql`
910
query caseIncident($id: String!) {
@@ -44,7 +45,71 @@ describe('Case Incident Response resolver standard behavior', () => {
4445
});
4546
expect(caseIncidentResponseData).not.toBeNull();
4647
expect(caseIncidentResponseData?.data?.caseIncidentAdd.authorized_members).not.toBeUndefined();
47-
caseIncidentResponseId = caseIncidentResponseData?.data?.caseIncidentAdd.id;
48+
caseIncidentResponse = caseIncidentResponseData?.data?.caseIncidentAdd;
49+
});
50+
it('should Case Incident Response loaded by internal id', async () => {
51+
const queryResult = await queryAsAdmin({ query: READ_QUERY, variables: { id: caseIncidentResponse.id } });
52+
expect(queryResult).not.toBeNull();
53+
expect(queryResult?.data?.caseIncident).not.toBeNull();
54+
expect(queryResult?.data?.caseIncident.id).toEqual(caseIncidentResponse.id);
55+
expect(queryResult?.data?.caseIncident.toStix.length).toBeGreaterThan(5);
56+
});
57+
it('should Case Incident Response loaded by standard id', async () => {
58+
const queryResult = await queryAsAdmin({ query: READ_QUERY, variables: { id: caseIncidentResponse.standard_id } });
59+
expect(queryResult).not.toBeNull();
60+
expect(queryResult?.data?.caseIncident).not.toBeNull();
61+
expect(queryResult?.data?.caseIncident.id).toEqual(caseIncidentResponse.id);
62+
});
63+
it('should list Case Incident Response', async () => {
64+
const LIST_QUERY = gql`
65+
query caseIncidents(
66+
$first: Int
67+
$after: ID
68+
$orderBy: CaseIncidentsOrdering
69+
$orderMode: OrderingMode
70+
$filters: FilterGroup
71+
$search: String
72+
$toStix: Boolean
73+
) {
74+
caseIncidents(
75+
first: $first
76+
after: $after
77+
orderBy: $orderBy
78+
orderMode: $orderMode
79+
filters: $filters
80+
search: $search
81+
toStix: $toStix
82+
) {
83+
edges {
84+
node {
85+
id
86+
standard_id
87+
}
88+
}
89+
}
90+
}
91+
`;
92+
const queryResult = await queryAsAdmin({ query: LIST_QUERY, variables: { first: 10 } });
93+
expect(queryResult?.data?.caseIncidents.edges.length).toEqual(1);
94+
});
95+
it('should update case', async () => {
96+
const UPDATE_QUERY = gql`
97+
mutation CaseIncident($id: ID!, $input: [EditInput]!) {
98+
stixDomainObjectEdit(id: $id) {
99+
fieldPatch(input: $input) {
100+
id
101+
... on Case {
102+
name
103+
}
104+
}
105+
}
106+
}
107+
`;
108+
const queryResult = await queryAsAdmin({
109+
query: UPDATE_QUERY,
110+
variables: { id: caseIncidentResponse.id, input: { key: 'name', value: ['Case - updated'] } },
111+
});
112+
expect(queryResult?.data?.stixDomainObjectEdit.fieldPatch.name).toEqual('Case - updated');
48113
});
49114
it('should Case Incident Response deleted', async () => {
50115
const DELETE_QUERY = gql`
@@ -55,10 +120,10 @@ describe('Case Incident Response resolver standard behavior', () => {
55120
// Delete the case
56121
await queryAsAdmin({
57122
query: DELETE_QUERY,
58-
variables: { id: caseIncidentResponseId },
123+
variables: { id: caseIncidentResponse.id },
59124
});
60125
// Verify is no longer found
61-
const queryResult = await queryAsAdmin({ query: READ_QUERY, variables: { id: caseIncidentResponseId } });
126+
const queryResult = await queryAsAdmin({ query: READ_QUERY, variables: { id: caseIncidentResponse.id } });
62127
expect(queryResult).not.toBeNull();
63128
expect(queryResult?.data?.caseIncident).toBeNull();
64129
});

0 commit comments

Comments
 (0)