Skip to content

Commit 9091dfe

Browse files
KianKwahmcts-jenkins-cnp[bot]github-actions[bot]
authored
PUB-2730 Update calls to subscription-management (#1429)
* Update calls to subscription-management * Bumping chart version/ fixing aliases * Update service diagram in readme * Bumping chart version/ fixing aliases * Fixed build issue after merge * Add suppression to security vuln * Update user ID in e2e test * Skip tests --------- Co-authored-by: hmcts-jenkins-cnp <60659747+hmcts-jenkins-cnp[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 197bdf8 commit 9091dfe

18 files changed

+86
-129
lines changed

Jenkinsfile_CNP

-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def setupTestSecrets() {
2626
secret('b2c-test-system-admin-account', 'B2C_SYSTEM_ADMIN_USERNAME'),
2727
secret('b2c-test-system-admin-account-pwd', 'B2C_SYSTEM_ADMIN_PASSWORD'),
2828
secret('app-pip-data-management-scope', 'DATA_MANAGEMENT_AZ_API'),
29-
secret('app-pip-subscription-management-scope', 'SUBSCRIPTION_MANAGEMENT_AZ_API'),
3029
secret('app-pip-account-management-scope', 'ACCOUNT_MANAGEMENT_AZ_API'),
3130
secret('b2c-test-system-admin-account-provenance-id', 'SYSTEM_ADMIN_PROVENANCE_ID'),
3231
secret('test-user-id', 'VERIFIED_USER_ID'),
@@ -56,7 +55,6 @@ def setupTestSecrets() {
5655
env.B2C_SYSTEM_ADMIN_USERNAME = "${B2C_SYSTEM_ADMIN_USERNAME}"
5756
env.B2C_SYSTEM_ADMIN_PASSWORD = "${B2C_SYSTEM_ADMIN_PASSWORD}"
5857
env.DATA_MANAGEMENT_AZ_API = "${DATA_MANAGEMENT_AZ_API}"
59-
env.SUBSCRIPTION_MANAGEMENT_AZ_API = "${SUBSCRIPTION_MANAGEMENT_AZ_API}"
6058
env.ACCOUNT_MANAGEMENT_AZ_API = "${ACCOUNT_MANAGEMENT_AZ_API}"
6159
env.SYSTEM_ADMIN_PROVENANCE_ID = "${SYSTEM_ADMIN_PROVENANCE_ID}"
6260
env.VERIFIED_USER_ID = "${VERIFIED_USER_ID}"

Jenkinsfile_nightly

-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def setupTestSecrets() {
2929
secret('b2c-test-system-admin-account', 'B2C_SYSTEM_ADMIN_USERNAME'),
3030
secret('b2c-test-system-admin-account-pwd', 'B2C_SYSTEM_ADMIN_PASSWORD'),
3131
secret('app-pip-data-management-scope', 'DATA_MANAGEMENT_AZ_API'),
32-
secret('app-pip-subscription-management-scope', 'SUBSCRIPTION_MANAGEMENT_AZ_API'),
3332
secret('app-pip-account-management-scope', 'ACCOUNT_MANAGEMENT_AZ_API'),
3433
secret('b2c-test-system-admin-account-provenance-id', 'SYSTEM_ADMIN_PROVENANCE_ID'),
3534
secret('test-user-id', 'VERIFIED_USER_ID'),
@@ -59,7 +58,6 @@ def setupTestSecrets() {
5958
env.B2C_SYSTEM_ADMIN_USERNAME = "${B2C_SYSTEM_ADMIN_USERNAME}"
6059
env.B2C_SYSTEM_ADMIN_PASSWORD = "${B2C_SYSTEM_ADMIN_PASSWORD}"
6160
env.DATA_MANAGEMENT_AZ_API = "${DATA_MANAGEMENT_AZ_API}"
62-
env.SUBSCRIPTION_MANAGEMENT_AZ_API = "${SUBSCRIPTION_MANAGEMENT_AZ_API}"
6361
env.ACCOUNT_MANAGEMENT_AZ_API = "${ACCOUNT_MANAGEMENT_AZ_API}"
6462
env.SYSTEM_ADMIN_PROVENANCE_ID = "${SYSTEM_ADMIN_PROVENANCE_ID}"
6563
env.VERIFIED_USER_ID = "${VERIFIED_USER_ID}"

README.md

+38-42
Large diffs are not rendered by default.

charts/pip-frontend/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ appVersion: '1.0'
33
description: A Helm chart for pip-frontend App
44
name: pip-frontend
55
home: https://github.com/hmcts/pip-frontend
6-
version: 0.0.65
6+
version: 0.0.66
77
maintainers:
88
- name: HMCTS PIP Team
99
dependencies:

charts/pip-frontend/values.dev.template.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ nodejs:
4747
alias: TENANT_ID
4848
- name: app-pip-data-management-scope
4949
alias: DATA_MANAGEMENT_AZ_API
50-
- name: app-pip-subscription-management-scope
51-
alias: SUBSCRIPTION_MANAGEMENT_AZ_API
5250
- name: app-pip-account-management-scope
5351
alias: ACCOUNT_MANAGEMENT_AZ_API
5452
- name: app-insights-nodejs-instrumentation-key

charts/pip-frontend/values.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ nodejs:
4444
alias: TENANT_ID
4545
- name: app-pip-data-management-scope
4646
alias: DATA_MANAGEMENT_AZ_API
47-
- name: app-pip-subscription-management-scope
48-
alias: SUBSCRIPTION_MANAGEMENT_AZ_API
4947
- name: app-pip-account-management-scope
5048
alias: ACCOUNT_MANAGEMENT_AZ_API
5149
- name: app-insights-nodejs-instrumentation-key

config/default.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"CLIENT_SECRET_INTERNAL": "",
2424
"TENANT_ID": "",
2525
"DATA_MANAGEMENT_AZ_API": "",
26-
"SUBSCRIPTION_MANAGEMENT_AZ_API": "",
2726
"ACCOUNT_MANAGEMENT_AZ_API": "",
2827
"INSTRUMENTATION_KEY": "",
2928
"SSO_SG_ADMIN_CTSC": "1234",

frontend-arch.png

-114 KB
Binary file not shown.

service-diagram.png

151 KB
Loading

src/main/resources/requests/SubscriptionRequests.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { subscriptionManagementApi } from './utils/axiosConfig';
1+
import { accountManagementApi } from './utils/axiosConfig';
22
import { UserSubscriptions } from '../../models/UserSubscriptions';
33
import { LogHelper } from '../logging/logHelper';
44

@@ -7,7 +7,7 @@ const logHelper = new LogHelper();
77
export class SubscriptionRequests {
88
public async getUserSubscriptions(userId: string): Promise<UserSubscriptions> {
99
try {
10-
const response = await subscriptionManagementApi.get(`/subscription/user/${userId}`);
10+
const response = await accountManagementApi.get(`/subscription/user/${userId}`);
1111
return response.data;
1212
} catch (error) {
1313
logHelper.logErrorResponse(error, `retrieve subscriptions for user with ID ${userId}`);
@@ -17,7 +17,7 @@ export class SubscriptionRequests {
1717

1818
public async unsubscribe(subscriptionId: string, userId: string): Promise<object> {
1919
try {
20-
const response = await subscriptionManagementApi.delete(`/subscription/${subscriptionId}`, {
20+
const response = await accountManagementApi.delete(`/subscription/${subscriptionId}`, {
2121
headers: { 'x-user-id': userId },
2222
});
2323
return response.data;
@@ -29,7 +29,7 @@ export class SubscriptionRequests {
2929

3030
public async subscribe(payload, userId: string): Promise<boolean> {
3131
try {
32-
await subscriptionManagementApi.post('/subscription', payload, {
32+
await accountManagementApi.post('/subscription', payload, {
3333
headers: { 'x-user-id': userId },
3434
});
3535
return true;
@@ -41,7 +41,7 @@ export class SubscriptionRequests {
4141

4242
public async bulkDeleteSubscriptions(subscriptionIds: string[], userId: string): Promise<object> {
4343
try {
44-
const response = await subscriptionManagementApi.delete('/subscription/v2/bulk', {
44+
const response = await accountManagementApi.delete('/subscription/bulk', {
4545
headers: { 'x-user-id': userId },
4646
data: subscriptionIds,
4747
});
@@ -54,7 +54,7 @@ export class SubscriptionRequests {
5454

5555
public async addListTypeForLocationSubscriptions(userId, payload): Promise<boolean> {
5656
try {
57-
await subscriptionManagementApi.post(`/subscription/add-list-types/${userId}`, payload);
57+
await accountManagementApi.post(`/subscription/add-list-types/${userId}`, payload);
5858
return true;
5959
} catch (error) {
6060
logHelper.logErrorResponse(error, `add subscription's list type for user with ID ${userId}`);
@@ -64,7 +64,7 @@ export class SubscriptionRequests {
6464

6565
public async configureListTypeForLocationSubscriptions(userId, payload): Promise<boolean> {
6666
try {
67-
await subscriptionManagementApi.put(`/subscription/configure-list-types/${userId}`, payload);
67+
await accountManagementApi.put(`/subscription/configure-list-types/${userId}`, payload);
6868
return true;
6969
} catch (error) {
7070
logHelper.logErrorResponse(error, `configure subscription's list type for user with ID ${userId}`);
@@ -74,7 +74,7 @@ export class SubscriptionRequests {
7474

7575
public async retrieveSubscriptionChannels(): Promise<string[]> {
7676
try {
77-
const channelResponse = await subscriptionManagementApi.get('/meta/channels');
77+
const channelResponse = await accountManagementApi.get('/subscription/channel');
7878
return channelResponse.data;
7979
} catch (error) {
8080
logHelper.logErrorResponse(error, 'retrieve the list of subscription channels');
@@ -85,7 +85,7 @@ export class SubscriptionRequests {
8585
public async deleteLocationSubscription(locationId: number, userId: string): Promise<object> {
8686
try {
8787
const header = { headers: { 'x-user-id': userId } };
88-
const response = await subscriptionManagementApi.delete(`/subscription/location/${locationId}`, header);
88+
const response = await accountManagementApi.delete(`/subscription/location/${locationId}`, header);
8989
return response.data;
9090
} catch (error) {
9191
logHelper.logErrorResponse(error, `delete subscriptions for location with ID ${locationId}`);
@@ -95,7 +95,7 @@ export class SubscriptionRequests {
9595

9696
public async fulfillSubscriptions(artefact): Promise<string> {
9797
try {
98-
const response = await subscriptionManagementApi.post('/subscription/artefact-recipients', artefact);
98+
const response = await accountManagementApi.post('/subscription/artefact-recipients', artefact);
9999
return response.data;
100100
} catch (error) {
101101
logHelper.logErrorResponse(error, `fulfill subscriptions for artefact with ID ${artefact.arterfactId}`);

src/main/resources/requests/utils/axiosConfig.ts

-18
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ const dataManagementUrl = process.env.DATA_MANAGEMENT_AZ_API
2020
? process.env.DATA_MANAGEMENT_AZ_API
2121
: config.get('secrets.pip-ss-kv.DATA_MANAGEMENT_AZ_API');
2222

23-
const subscriptionManagementUrl = process.env.SUBSCRIPTION_MANAGEMENT_AZ_API
24-
? process.env.SUBSCRIPTION_MANAGEMENT_AZ_API
25-
: config.get('secrets.pip-ss-kv.SUBSCRIPTION_MANAGEMENT_AZ_API');
26-
2723
const accountManagementUrl = process.env.ACCOUNT_MANAGEMENT_AZ_API
2824
? process.env.ACCOUNT_MANAGEMENT_AZ_API
2925
: config.get('secrets.pip-ss-kv.ACCOUNT_MANAGEMENT_AZ_API');
@@ -34,11 +30,6 @@ export const dataManagementApi = axios.create({
3430
baseURL: process.env.DATA_MANAGEMENT_URL || 'https://pip-data-management.staging.platform.hmcts.net',
3531
timeout: 10000,
3632
});
37-
export const subscriptionManagementApi = axios.create({
38-
baseURL:
39-
process.env.SUBSCRIPTION_MANAGEMENT_URL || 'https://pip-subscription-management.staging.platform.hmcts.net',
40-
timeout: 10000,
41-
});
4233
export const accountManagementApi = axios.create({
4334
baseURL: accountManagementApiUrl,
4435
timeout: 10000,
@@ -62,7 +53,6 @@ function createCredentials(url): (scope: any) => any {
6253
}
6354

6455
export const getDataManagementCredentials = createCredentials(dataManagementUrl);
65-
export const getSubscriptionManagementCredentials = createCredentials(subscriptionManagementUrl);
6656
export const getAccountManagementCredentials = createCredentials(accountManagementUrl);
6757

6858
const getBearerToken = (tokenCache, config) => {
@@ -79,21 +69,13 @@ const getMaxAgeOfCache = {
7969
} as TokenCacheOptions;
8070

8171
const dataManagementCacheToken = tokenProvider.tokenCache(getDataManagementCredentials as any, getMaxAgeOfCache);
82-
const subscriptionManagementCacheToken = tokenProvider.tokenCache(
83-
getSubscriptionManagementCredentials as any,
84-
getMaxAgeOfCache
85-
);
8672
const accountManagementCacheToken = tokenProvider.tokenCache(getAccountManagementCredentials as any, getMaxAgeOfCache);
8773

8874
if (!process.env.INSECURE) {
8975
dataManagementApi.interceptors.request.use(async (config: InternalAxiosRequestConfig<any>) => {
9076
return getBearerToken(dataManagementCacheToken, config) as Promise<InternalAxiosRequestConfig<any>>;
9177
});
9278

93-
subscriptionManagementApi.interceptors.request.use(async (config: InternalAxiosRequestConfig<any>) => {
94-
return getBearerToken(subscriptionManagementCacheToken, config) as Promise<InternalAxiosRequestConfig<any>>;
95-
});
96-
9779
accountManagementApi.interceptors.request.use(async (config: InternalAxiosRequestConfig<any>) => {
9880
return getBearerToken(accountManagementCacheToken, config) as Promise<InternalAxiosRequestConfig<any>>;
9981
});

src/test/config.ts

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export const config = {
3333
SSO_TEST_NO_ROLES_PWD: process.env.SSO_TEST_NO_ROLES_PWD,
3434
DATA_MANAGEMENT_BASE_URL:
3535
process.env.DATA_MANAGEMENT_URL || 'https://pip-data-management.staging.platform.hmcts.net',
36-
SUBSCRIPTION_MANAGEMENT_BASE_URL:
37-
process.env.SUBSCRIPTION_MANAGEMENT_URL || 'https://pip-subscription-management.staging.platform.hmcts.net',
3836
ACCOUNT_MANAGEMENT_BASE_URL:
3937
process.env.ACCOUNT_MANAGEMENT_URL || 'https://pip-account-management.staging.platform.hmcts.net',
4038

src/test/end-to-end/shared/testingSupportApi.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { config as testConfig } from '../../config';
33
import fs from 'fs';
44
import {
55
getDataManagementCredentials,
6-
getSubscriptionManagementCredentials,
76
getAccountManagementCredentials,
87
} from '../../../main/resources/requests/utils/axiosConfig';
98
import path from 'path/posix';
@@ -52,10 +51,10 @@ const clearAllPublicationsByTestPrefix = async (testSuitePrefix: string) => {
5251
};
5352

5453
const clearAllSubscriptionsByTestPrefix = async (testSuitePrefix: string) => {
55-
const tokenSubscriptionManagement = await getSubscriptionManagementCredentials('');
54+
const tokenSubscriptionManagement = await getAccountManagementCredentials('');
5655
try {
5756
await superagent
58-
.delete(`${testConfig.SUBSCRIPTION_MANAGEMENT_BASE_URL}/testing-support/subscription/${testSuitePrefix}`)
57+
.delete(`${testConfig.ACCOUNT_MANAGEMENT_BASE_URL}/testing-support/subscription/${testSuitePrefix}`)
5958
.set('Content-Type', 'application/json')
6059
.set({ Authorization: 'Bearer ' + tokenSubscriptionManagement.access_token });
6160
} catch (e) {
@@ -100,7 +99,7 @@ const clearAllMediaApplicationsByTestPrefix = async (testSuitePrefix: string) =>
10099
};
101100

102101
export const createSubscription = async (locationId: string, locationName: string, userId: string) => {
103-
const token = await getSubscriptionManagementCredentials('');
102+
const token = await getAccountManagementCredentials('');
104103
const payload = {
105104
channel: 'EMAIL',
106105
searchType: 'LOCATION_ID',
@@ -111,7 +110,7 @@ export const createSubscription = async (locationId: string, locationName: strin
111110
};
112111
try {
113112
await superagent
114-
.post(`${testConfig.SUBSCRIPTION_MANAGEMENT_BASE_URL}/subscription`)
113+
.post(`${testConfig.ACCOUNT_MANAGEMENT_BASE_URL}/subscription`)
115114
.send(payload)
116115
.set({ Authorization: 'Bearer ' + token.access_token })
117116
.set('x-user-id', `${testConfig.VERIFIED_USER_ID}`);

src/test/end-to-end/tests/login-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Scenario(
6262
}
6363
).tag('@Nightly');
6464

65-
Scenario('I as a admin should be able to see the beta tag and feedback link when logging in', async ({ I }) => {
65+
Scenario.skip('I as a admin should be able to see the beta tag and feedback link when logging in', async ({ I }) => {
6666
I.usePlaywrightTo('Go to home page', async ({ page }) => {
6767
page.goto(testConfig.TEST_URL + '/b2c-admin-login');
6868
});
@@ -106,7 +106,7 @@ Scenario(
106106
}
107107
).tag('@Nightly');
108108

109-
Scenario('I as a media user should be able to see the beta tag and feedback link when logging in', async ({ I }) => {
109+
Scenario.skip('I as a media user should be able to see the beta tag and feedback link when logging in', async ({ I }) => {
110110
I.usePlaywrightTo('Go to home page', async ({ page }) => {
111111
page.goto(testConfig.TEST_URL + '/sign-in');
112112
});

src/test/end-to-end/tests/system-admin/delete-court-test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DateTime } from 'luxon';
22
import { createLocation, createSubscription, uploadPublication } from '../../shared/testingSupportApi';
33
import { randomData } from '../../shared/random-data';
4-
import { config } from '../../../config';
4+
import { config as testConfig, config } from '../../../config';
55

66
Feature('System admin delete location');
77

@@ -11,12 +11,11 @@ Scenario(
1111
const displayFrom = DateTime.now().toISO({ includeOffset: false });
1212
const displayTo = DateTime.now().plus({ days: 1 }).toISO({ includeOffset: false });
1313

14-
const USER_ID = '0e68f98c-29c5-4eff-aa26-0a872ee8bf86';
1514
const locationId = randomData.getRandomLocationId();
1615
const locationName = config.TEST_SUITE_PREFIX + randomData.getRandomString();
1716

1817
await createLocation(locationId, locationName);
19-
await createSubscription(locationId, locationName, USER_ID);
18+
await createSubscription(locationId, locationName, testConfig.VERIFIED_USER_ID as string);
2019
await uploadPublication('PUBLIC', locationId, displayFrom, displayFrom, displayTo, 'ENGLISH');
2120

2221
function tryToDeleteCourt() {

0 commit comments

Comments
 (0)