Skip to content

Commit 23e94bc

Browse files
committed
Linting issues
1 parent 7ffdc13 commit 23e94bc

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

test/integration-tests/org/roleValidationTest.js

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,44 @@
22
const chai = require('chai')
33
const chaiHttp = require('chai-http')
44
const app = require('../../../src/index') // Adjust path as needed
5-
const { getConstants } = require('../../../src/constants')
65
const constants = require('../constants.js')
76
const expect = chai.expect
87

98
chai.use(chaiHttp)
109

11-
// This test assumes a running server or proper mock setup usually handled by the test runner.
12-
// For simplicity in this environment, we'll piggyback on existing integration test structures or
10+
// This test assumes a running server or proper mock setup usually handled by the test runner.
11+
// For simplicity in this environment, we'll piggyback on existing integration test structures or
1312
// use a very targeted unit/repo test data if we were mocking capable.
1413
// Given strict restriction, I will create a test that can be run with `npm test` assuming the environment handles DB.
1514

1615
describe('BaseOrgRepository Role Validation', () => {
17-
// defined in constants.js
18-
const secretariatHeaders = constants.headers
19-
20-
// We need a known org to test against. 'mitre' usually exists in seed data.
21-
const orgShortName = 'mitre'
22-
23-
it('should NOT add invalid roles to an organization', async () => {
24-
const res = await chai.request(app)
25-
.put(`/api/org/${orgShortName}?active_roles.add=INVALID_ROLE_XXX`)
26-
.set(secretariatHeaders)
27-
28-
// We expect 200 OK because we decided to filter out invalid values silently,
29-
// OR 400 if validation strictness was elsewhere.
30-
// Based on current code, it accepts arbitrary strings.
31-
// The fix will make it ignore them.
32-
33-
expect(res).to.have.status(200)
34-
expect(res.body.updated.authority.active_roles).to.not.include('INVALID_ROLE_XXX')
35-
})
36-
37-
it('should add valid roles to an organization', async () => {
38-
// Setup: assume MITRE is CNA. Let's try to add ROOT_CNA if not present, or just ensure it accepts valid enums.
39-
// CONSTANTS.AUTH_ROLE_ENUM.ROOT_CNA
40-
const validRole = 'ROOT_CNA'
41-
42-
const res = await chai.request(app)
43-
.put(`/api/org/${orgShortName}?active_roles.add=${validRole}`)
44-
.set(secretariatHeaders)
45-
46-
expect(res).to.have.status(200)
47-
expect(res.body.updated.authority.active_roles).to.include(validRole)
48-
})
16+
// We need a known org to test against. 'mitre' usually exists in seed data.
17+
const orgShortName = 'mitre'
18+
19+
it('should NOT add invalid roles to an organization', async () => {
20+
const res = await chai.request(app)
21+
.put(`/api/org/${orgShortName}?active_roles.add=INVALID_ROLE_XXX`)
22+
.set(constants.headers)
23+
24+
// We expect 200 OK because we decided to filter out invalid values silently,
25+
// OR 400 if validation strictness was elsewhere.
26+
// Based on current code, it accepts arbitrary strings.
27+
// The fix will make it ignore them.
28+
29+
expect(res).to.have.status(200)
30+
expect(res.body.updated.authority.active_roles).to.not.include('INVALID_ROLE_XXX')
31+
})
32+
33+
it('should add valid roles to an organization', async () => {
34+
// Setup: assume MITRE is CNA. Let's try to add ROOT_CNA if not present, or just ensure it accepts valid enums.
35+
// CONSTANTS.AUTH_ROLE_ENUM.ROOT_CNA
36+
const validRole = 'ROOT_CNA'
37+
38+
const res = await chai.request(app)
39+
.put(`/api/org/${orgShortName}?active_roles.add=${validRole}`)
40+
.set(constants.headers)
41+
42+
expect(res).to.have.status(200)
43+
expect(res.body.updated.authority.active_roles).to.include(validRole)
44+
})
4945
})

0 commit comments

Comments
 (0)