Skip to content

Commit 521fd42

Browse files
authored
Merge pull request #783 from DEFRA/feat/df-924-remove-group-claims
feat/df-924: Removed group claims
2 parents 4e8c8e1 + 7215561 commit 521fd42

11 files changed

Lines changed: 118 additions & 314 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ MONGO_DATABASE=""
6060
OIDC_JWKS_URI=""
6161
OIDC_VERIFY_AUD=""
6262
OIDC_VERIFY_ISS=""
63-
ROLE_EDITOR_GROUP_ID=""
6463
HTTP_PROXY=
6564
HTTPS_PROXY=
6665
NO_PROXY=

docker-compose.integration-test.yml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,48 @@ services:
8282
retries: 18
8383
start_period: 90s
8484

85+
forms-entitlement-api-test:
86+
image: defradigital/forms-entitlement-api:latest
87+
container_name: forms-entitlement-api-test
88+
platform: linux/amd64
89+
environment:
90+
NODE_ENV: production
91+
PORT: 3004
92+
# Mongo
93+
MONGO_URI: mongodb://mongo_test:27017/forms-entitlement-api?replicaSet=rs0&directConnection=true
94+
MONGO_DATABASE: forms-entitlement-api
95+
# OIDC
96+
OIDC_JWKS_URI: 'http://oidc:80/.well-known/openid-configuration/jwks'
97+
OIDC_VERIFY_AUD: 'newman-test-client'
98+
OIDC_VERIFY_ISS: 'http://oidc:80'
99+
SYNC_ADMIN_USERS_ENABLED: false
100+
TRACE_HEADER: x-trace-id
101+
LOG_LEVEL: info
102+
AWS_REGION: eu-west-2
103+
AWS_ACCESS_KEY_ID: test
104+
AWS_SECRET_ACCESS_KEY: test
105+
networks:
106+
- forms_test_net
107+
ports:
108+
- '3004:3004'
109+
healthcheck:
110+
test:
111+
[
112+
'CMD-SHELL',
113+
'curl -fsS http://localhost:3004/health >/dev/null || exit 1'
114+
]
115+
interval: 10s
116+
timeout: 10s
117+
retries: 18
118+
start_period: 15s
119+
depends_on:
120+
mongo_test:
121+
condition: service_healthy
122+
oidc:
123+
condition: service_healthy
124+
localstack:
125+
condition: service_healthy
126+
85127
app_test:
86128
image: app-test
87129
build:
@@ -107,27 +149,21 @@ services:
107149
OIDC_JWKS_URI: 'http://oidc:80/.well-known/openid-configuration/jwks'
108150
OIDC_VERIFY_AUD: 'newman-test-client'
109151
OIDC_VERIFY_ISS: 'http://oidc:80'
110-
ROLE_EDITOR_GROUP_ID: '7049296f-2156-4d61-8ac3-349276438ef9'
111-
TRACING_HEADER: x-cdp-request-id
112-
AWS_REGION: eu-west-2
113-
FEATURE_FLAG_PUBLISH_AUDIT_EVENTS: false
114152
FORM_DEF_BUCKET_NAME: form-definition-storage
115153
S3_FORCE_PATH_STYLE: true
116154
S3_ENDPOINT: http://localstack:4566
117155
SNS_ENDPOINT: http://localstack:4566
118156
SNS_TOPIC_ARN: arn:aws:sns:eu-west-2:000000000000:forms_manager_events
157+
AWS_REGION: eu-west-2
119158
AWS_ACCESS_KEY_ID: test
120159
AWS_SECRET_ACCESS_KEY: test
121-
ENTITLEMENT_URL: http://localhost:3004
122-
FEATURE_FLAG_USE_ENTITLEMENT_API: false
160+
ENTITLEMENT_URL: http://forms-entitlement-api-test:3004
161+
FEATURE_FLAG_PUBLISH_AUDIT_EVENTS: false
162+
FEATURE_FLAG_USE_ENTITLEMENT_API: true
123163
# PUBLIC_KEY is a test value - do not use for any deployments
124164
PUBLIC_KEY_FOR_SECRETS: 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUE0WU53YUJjenlBdWpJZ2k2aTBmawpINUVYeGxtTmNBd1AzUkpRaDB2ckxjeDIxU2RCSkFOUU5JWmdTcWhST3ViUlozWTJWQ2Zsbkd3cFVSTTNrY0tFCkNHUlk2Nk5leVUwL3QzS2hVOUY1cG1heVBSVUFiWkRjalFCL0xYbVNGUUdGelZDQlp0ZjBIeHJiSnBUNDFiSGIKR05udFpDdm94WjZQOUJxdU4wa2c0Y1JXcTdyWUozVE1xWXArc1RzQU01UFZwMVh6WklIRFJ2UVJ2bktnMDVUUQovRFA1cXcvYkdwelVsQ01WVU9MTHhxL2xTY040RnhDRTRUUi9kSWNNM25wTU1PUUVjaEhLcEE2SWs3UmhmQml0CjZBSEpINWN2c0dWUTFHUmlvUXBIWXBWclZLRFV5ZmIrS3VzbjlWUTVTQ3JGZDJ3WWRaRzBkdVNOZFp3VklJQm8KVElWZjlrSUMrZjl5YTVLMmcvalJhMXUyVGdNc3UvZnM4UWVRZHk2disxNkFtWFA1cXNXYUtFK00zRkJoRitrZAozbS91YjNJVFRRVmplYWY1M2ZsTVlMZlZmN2NVR2FQN0VIajlUY0dGYVlGTzhuWGNWbS9lT2lkMXBGL3p5NCtzCnpFZG5oOFNRYm5ncElwdFJiMk51Wmw5RWZNR01CTFlyQ3FiWnMyYU1KV0N5M1FGWFZDeTYzUzZhRDkrbzQ1N0cKUDNGVnNZY2d2eHAzTGVTQ0phUHMzL0FlSjh1MUFSeHZwMG02ZjdPLy9yMFFQYzJnd2RyZjRVMUkwdlduclh2eApCc2RMWU5NMXVYVjhMKzExYloxeGpVaFU4QldTd3dnTTdQMGxqVTJ4UE9WbG55MlFGeXh0ZTgzK0E5SXNBcmFxCmthNlhEdDhYZkNZYm84dEpnem9mbEs4Q0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ=='
125165
depends_on:
126-
mongo_test:
127-
condition: service_healthy
128-
oidc:
129-
condition: service_healthy
130-
localstack:
166+
forms-entitlement-api-test:
131167
condition: service_healthy
132168
command: ['npm', 'start', '--ignore-scripts']
133169
networks:

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
"postversion": "git add package.json package-lock.json && git commit -m $npm_package_version",
2424
"test": "jest --color --coverage --verbose",
2525
"test:watch": "jest --color --watch",
26-
"test:integration:setup": "docker compose -f docker-compose.integration-test.yml up -d localstack oidc mongo_test",
26+
"test:integration:setup": "docker compose -f docker-compose.integration-test.yml up -d localstack oidc mongo_test forms-entitlement-api-test",
27+
"test:integration:seed": "docker run --rm --network forms-manager_forms_test_net -v './test/utils/seed-users.json:/seed-users.json' mongo:6.0 mongoimport --uri 'mongodb://mongo_test:27017/forms-entitlement-api?replicaSet=rs0&directConnection=true' --collection user-entitlement --file /seed-users.json --jsonArray --mode=upsert --upsertFields=userId",
2728
"test:integration:start": "docker compose -f docker-compose.integration-test.yml up --build -d app_test",
2829
"test:integration:wait": "echo 'Waiting for app...' && sleep 15 && until curl --fail http://localhost:3001/health; do echo 'Still waiting...'; sleep 5; done; echo 'App ready!'",
2930
"test:integration:run": "docker compose -f docker-compose.integration-test.yml run --rm --entrypoint=\"\" newman sh -c \"npm install -g newman-reporter-htmlextra && newman run /etc/newman/forms-manager-ci-mock.postman_collection.json -e /etc/newman/forms-manager-ci-mock.postman_environment.json -r cli,json,htmlextra --reporter-json-export /etc/newman/reports/newman-summary.json --reporter-htmlextra-export /etc/newman/reports/newman-report.html --reporter-htmlextra-showConsoleLogs\"",
3031
"test:integration:stop": "docker compose -f docker-compose.integration-test.yml down -v --remove-orphans",
31-
"test:integration": "npm run test:integration:setup && npm run test:integration:start && npm run test:integration:wait && npm run test:integration:run; EXIT_CODE=$? && exit $EXIT_CODE",
32+
"test:integration": "npm run test:integration:setup && npm run test:integration:seed && npm run test:integration:start && npm run test:integration:wait && npm run test:integration:run; EXIT_CODE=$? && exit $EXIT_CODE",
3233
"server:watch": "NODE_ENV=development tsx watch --clear-screen=false --enable-source-maps --exclude \"**/*.test.*\"",
3334
"server:watch:dev": "npm run server:watch -- ./src/index.js",
3435
"server:watch:debug": "npm run server:watch -- --inspect-wait ./src/index.js",

src/api/entitlements/service.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { RoleScopes, Roles } from '@defra/forms-model'
21
import Boom from '@hapi/boom'
32

43
import { config } from '~/src/config/index.js'
@@ -57,11 +56,3 @@ export async function getUserScopes(oid, authToken) {
5756
return []
5857
}
5958
}
60-
61-
/**
62-
* Gets the default scopes when entitlements API is not used
63-
* @returns {string[]} Default scopes array
64-
*/
65-
export function getDefaultScopes() {
66-
return [...RoleScopes[Roles.Admin]]
67-
}

src/api/entitlements/service.test.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ describe('entitlements service', () => {
88
error: jest.fn()
99
}
1010

11-
/** @type {() => string[]} */
12-
let getDefaultScopes
1311
/** @type {(oid: string, authToken?: string) => Promise<string[]>} */
1412
let getUserScopes
1513
/** @type {any} */
@@ -46,7 +44,6 @@ describe('entitlements service', () => {
4644
getJson = /** @type {any} */ (fetchModule.getJson)
4745

4846
const serviceModule = await import('~/src/api/entitlements/service.js')
49-
getDefaultScopes = serviceModule.getDefaultScopes
5047
getUserScopes = serviceModule.getUserScopes
5148
})
5249

@@ -171,29 +168,4 @@ describe('entitlements service', () => {
171168
)
172169
})
173170
})
174-
175-
describe('getDefaultScopes', () => {
176-
it('should return admin scopes', () => {
177-
const result = getDefaultScopes()
178-
179-
expect(result).toEqual([
180-
'form-delete',
181-
'form-edit',
182-
'form-read',
183-
'form-publish',
184-
'user-create',
185-
'user-delete',
186-
'user-edit',
187-
'forms-feedback'
188-
])
189-
})
190-
191-
it('should return a new array instance each time', () => {
192-
const result1 = getDefaultScopes()
193-
const result2 = getDefaultScopes()
194-
195-
expect(result1).not.toBe(result2)
196-
expect(result1).toEqual(result2)
197-
})
198-
})
199171
})

src/config/index.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@ export const config = convict({
162162
default: null,
163163
env: 'OIDC_VERIFY_ISS'
164164
},
165-
/** @type {SchemaObj<string>} */
166-
roleEditorGroupId: {
167-
doc: 'The AD security group the access token needs to claim membership of',
168-
format: String,
169-
default: null,
170-
env: 'ROLE_EDITOR_GROUP_ID'
171-
},
172165
tracing: {
173166
/** @type {SchemaObj<string>} */
174167

@@ -228,13 +221,6 @@ export const config = convict({
228221
default: null,
229222
env: 'ENTITLEMENT_URL'
230223
},
231-
/** @type {SchemaObj<boolean>} */
232-
useEntitlementApi: {
233-
doc: 'Feature flag to enable entitlement API for fetching scopes',
234-
format: Boolean,
235-
default: null,
236-
env: 'FEATURE_FLAG_USE_ENTITLEMENT_API'
237-
},
238224
/** @type {SchemaObj<string>} */
239225
publicKeyForSecrets: {
240226
doc: 'Public key for encryption of secrets',

0 commit comments

Comments
 (0)