Skip to content

Commit 0a86dbd

Browse files
committed
add org create access request
1 parent fcffda5 commit 0a86dbd

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

src/controllers/v3/OrgAccessRequestsController.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { Product } from './types';
1717
import { getGwaProductEnvironment } from '../../services/workflow';
1818
import { getOrgNamespaces } from '../../services/workflow/get-namespaces';
1919
import { getAccessRequestsByNamespace } from '../../services/keystone';
20-
import { OrgAccessRequest } from './types-extra';
20+
import { OrgAccessRequest, OrgAccessRequestCreateInput } from './types-extra';
21+
import { OrgAccessRequestCreate } from '../../services/workflow/org-access-request';
2122

2223
@injectable()
2324
@Route('/organizations')
@@ -73,19 +74,16 @@ export class OrgAccessRequestsController extends Controller {
7374
@Security('jwt', ['Namespace.Assign'])
7475
public async put(
7576
@Path() org: string,
76-
@Body() body: Product,
77+
@Body() body: OrgAccessRequestCreateInput,
7778
@Request() request: any
78-
): Promise<BatchResult> {
79-
// TODO: Make sure namespace is allowed for this org
80-
// body['gatewayId'] = gatewayId;
81-
// body['organization'] = org;
79+
): Promise<OrgAccessRequest> {
80+
const ctx = this.keystone.createContext(request, true);
81+
82+
const userId = ctx['user']['id'];
83+
84+
const result = await OrgAccessRequestCreate(ctx, org, body.orgMemberId, userId,
85+
body.consumerProductEnvAppId, body.providerProductEnvAppId, body.businessProcess, body.accessPointDN, body.optionalClientScopes);
8286

83-
// return await syncRecordsThrowErrors(
84-
// this.keystone.createContext(request, true),
85-
// 'Product',
86-
// body['appId'],
87-
// replaceKey(body, 'gatewayId', 'namespace')
88-
// );
89-
return { status: 400, result: 'Not implemented'}
87+
return result.accessRequest as any
9088
}
9189
}

src/controllers/v3/types-extra.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ export interface GatewayAdd {
2828
dataPlane?: string;
2929
}
3030

31+
export interface OrgAccessRequestCreateInput {
32+
orgMemberId: string;
33+
consumerProductEnvAppId: string;
34+
providerProductEnvAppId: string;
35+
businessProcess: string;
36+
accessPointDN: string;
37+
optionalClientScopes: string[];
38+
}
39+
3140
export interface OrgAccessRequest {
3241
id: string;
3342
name: string;

src/services/workflow/org-access-request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { NewCredential } from './types';
1818

1919
const logger = Logger('wf.OrgAccessReq');
2020

21-
export const OrgAccessRequest = async (
21+
export const OrgAccessRequestCreate = async (
2222
context: any,
2323
org: string,
2424
orgMemberID: string,
@@ -70,7 +70,7 @@ credential: NewCredential,
7070

7171
// prepare the access request
7272
const controls = {
73-
clientName: app.name,
73+
clientName: `${formatResourceLocator(orgMemberID, consumerProdEnv)} TO ${formatResourceLocator(orgMemberID, providerProdEnv)}`,
7474
subjectDn: accessPointDN,
7575
//defaultClientScopes: [],
7676
optionalClientScopes,

src/test/integrated/keystonejs/accessRequest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
getOrgNamespaces,
5252
} from '../../../services/workflow/get-namespaces';
5353
import { getRecords, replaceKey } from '../../../batch/feed-worker';
54-
import { OrgAccessRequest } from '../../../services/workflow/org-access-request';
54+
import { OrgAccessRequestCreate } from '../../../services/workflow/org-access-request';
5555

5656
(async () => {
5757
const keystone = await InitKeystone();
@@ -80,7 +80,8 @@ import { OrgAccessRequest } from '../../../services/workflow/org-access-request'
8080
// 424C7EB5 SDX-WORKING-API (dev)
8181
// 38D0FED9 SDX-SAMPLE-API (prod)
8282
//
83-
const result = await OrgAccessRequest(ctx, 'ministry-of-citizens-services', 'MIN/CITZ', userId, '424C7EB5', '7A031F2A', "SDX Onboarding", "CN=abcd", ["user/Test2"]);
83+
const result = await OrgAccessRequestCreate(ctx, 'ministry-of-citizens-services', 'MIN/CITZ', userId,
84+
'424C7EB5', '7A031F2A', "SDX Onboarding", "CN=abcd", ["user/Test2"]);
8485
o(result);
8586
}
8687

0 commit comments

Comments
 (0)