-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] fix capability check on feeds (#9573)
- Loading branch information
Showing
6 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
opencti-platform/opencti-graphql/tests/02-integration/02-resolvers/csvFeed-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { expect, it, describe } from 'vitest'; | ||
import gql from 'graphql-tag'; | ||
import { editorQuery, queryAsAdmin } from '../../utils/testQuery'; | ||
|
||
describe('CSV Feed resolver standard behavior', () => { | ||
let internalFeedId: string; | ||
|
||
it('should create CSV Feed', async () => { | ||
const CREATE_FEED = gql(` | ||
mutation FeedAdd($input: FeedAddInput!) { | ||
feedAdd(input: $input) { | ||
id | ||
name | ||
feed_types | ||
} | ||
} | ||
`); | ||
const feed = await queryAsAdmin({ | ||
query: CREATE_FEED, | ||
variables: { | ||
input: { | ||
name: 'List of created cities', | ||
separator: ';', | ||
rolling_time: 60, | ||
include_header: true, | ||
feed_types: ['City'], | ||
feed_date_attribute: 'created_at', | ||
feed_attributes: [{ | ||
attribute: 'A', | ||
mappings: [{ type: 'City', attribute: 'name' }] | ||
}] | ||
} | ||
}, | ||
}); | ||
expect(feed).not.toBeNull(); | ||
expect(feed.data?.feedAdd.name).toEqual('List of created cities'); | ||
internalFeedId = feed.data?.feedAdd.id; | ||
}); | ||
|
||
it('should access feed if user has capa to manage feeds', async () => { | ||
const QUERY_FEED = gql(` | ||
query QueryFeed($id: String!) { | ||
feed(id: $id) { | ||
id | ||
name | ||
} | ||
} | ||
`); | ||
const feed = await editorQuery({ | ||
query: QUERY_FEED, | ||
variables: { id: internalFeedId } | ||
}); | ||
expect(feed).not.toBeNull(); | ||
expect(feed.data?.feed.name).toEqual('List of created cities'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters