-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend/frontend] Fix enable references behavior when adding entities to containers #6175
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6175 +/- ##
==========================================
- Coverage 67.76% 66.75% -1.02%
==========================================
Files 532 541 +9
Lines 65065 64556 -509
Branches 5462 5307 -155
==========================================
- Hits 44093 43094 -999
- Misses 20972 21462 +490 ☔ View full report in Codecov by Sentry. |
655453f
to
d793a45
Compare
@@ -12126,8 +12126,8 @@ type ReportEditMutations { | |||
fieldPatch(input: [EditInput]!, commitMessage: String, references: [String]): Report @auth(for: [KNOWLEDGE_KNUPDATE]) | |||
contextPatch(input: EditContext): Report @auth(for: [KNOWLEDGE_KNUPDATE]) | |||
contextClean: Report @auth(for: [KNOWLEDGE_KNUPDATE]) | |||
relationAdd(input: StixRefRelationshipAddInput!): StixRefRelationship @auth(for: [KNOWLEDGE_KNUPDATE]) | |||
relationDelete(toId: StixRef!, relationship_type: String!): Report @auth(for: [KNOWLEDGE_KNUPDATE]) | |||
relationAdd(input: StixRefRelationshipAddInput!, commitMessage: String, references: [String]): StixRefRelationship @auth(for: [KNOWLEDGE_KNUPDATE]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all these API changes will need a client python update (here see opencti_report.py
add_stix_object_or_stix_relationship
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point thank you, I'll update the client as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading python client code, I think it's better to add commitMessage and references data to StixRefRelationshipAddInput instead of adding new parameters here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's to be consistent with our existing APIs, which all declare (if I'm not mistaken) commitMessage and references as separate parameters. Ex:
relationsAdd(input: StixRefRelationshipsAddInput!, commitMessage: String, references: [String]): StixCoreObject
relationDelete(toId: StixRef!, relationship_type: String!, commitMessage: String, references: [String]): StixCoreObject
84a7fec
to
5dff342
Compare
91a6b87
to
e6ee9f6
Compare
That's a bug that we also noticed, that is described here #6074 with the description "Edit an entity while having external reference". It will be worked on in the next step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only PR reading comment for now.
}); | ||
}); | ||
|
||
test('Add and remove observable from Observables tab of a Report as Admin user', async ({ page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is it intended that this "test" is not inside a test.describe block ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of! The describe blocks I used before were either to: group up tests that are dependant on each other (for the role/group/user creation), or to run the tests in the describe block with a specific context (the authentication describe block is used to run the authentication in a new browser context, to be able to log in the new user without having to log out the main user).
Since this test is independant from any others, I decided to not include it in a describe.
But the structure of the test file and the usage of describe blocks in general could be up to debate for sure
test('Create basic user role', async ({ page }) => { | ||
const rolesSettingsPage = new RolesSettingsPage(page); | ||
const rolePage = new RolePage(page); | ||
const roleFormPage = new RoleFormPage(page); | ||
|
||
await page.goto('/dashboard/settings/accesses/roles'); | ||
await expect(rolesSettingsPage.getSettingsPage()).toBeVisible(); | ||
await rolesSettingsPage.getAddRoleButton().click(); | ||
await roleFormPage.fillNameInput(noBypassRoleName); | ||
await roleFormPage.getCreateButton().click(); | ||
await expect(rolesSettingsPage.getRoleInList(noBypassRoleName)).toBeVisible(); | ||
await rolesSettingsPage.getRoleInList(noBypassRoleName).click(); | ||
await rolePage.getEditButton().click(); | ||
await roleFormPage.getCapabilitiesTab().click(); | ||
await roleFormPage.getAccessKnowledgeCheckbox().click(); | ||
await expect(roleFormPage.getAccessKnowledgeCheckbox()).toBeChecked(); | ||
await roleFormPage.getCreateUpdateKnowledgeCheckbox().click(); | ||
await expect(roleFormPage.getCreateUpdateKnowledgeCheckbox()).toBeChecked(); | ||
await roleFormPage.getAccessAdministrationCheckbox().click(); | ||
await expect(roleFormPage.getAccessAdministrationCheckbox()).toBeChecked(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random thinking: I guess we could have some way to reuse that piece of test code that creates user/roles and groups I don't mean one groups for all test, but have a methode like createRole(roleName, listOfCapacities) ...etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, we already talked about that with Souad and Jpk actually. We are planning to discuss it more during the e2e workshop
relationAdd: ({ input }) => stixDomainObjectAddRelation(context, context.user, id, input), | ||
relationDelete: ({ toId, relationship_type: relationshipType }) => stixDomainObjectDeleteRelation(context, context.user, id, toId, relationshipType), | ||
relationAdd: ({ input, commitMessage, references }) => stixDomainObjectAddRelation(context, context.user, id, input, { commitMessage, references }), | ||
// eslint-disable-next-line max-len |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you split the line instead ? Or is it really not readable ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find a nice way to keep it readable and keep lint happy, so i went with this. Also, in other resolvers like stixCoreRelationship, the relationDelete line was also handled this way
949e85d
to
9c98449
Compare
9c98449
to
c9fe0ea
Compare
This PR is only to fix enable references behavior in the scope of the #5884 issue. Other PRs will aim to fully fix the enable references behavior for all entities, and the full list of problems can be seen in the #6074
Checklist