Skip to content

Commit c9d983a

Browse files
committed
fix: some changes for frontend tests
1 parent 332d8f9 commit c9d983a

3 files changed

Lines changed: 95 additions & 12 deletions

File tree

Tokenization/backend/central-system/src/controllers/TokensController.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ export class TokensController {
4343
private readonly _tokensGetService: TokensGetService,
4444
private readonly _tokensService: Map<
4545
number,
46-
{ tokenId: number; validity: string; payload: string }
46+
{
47+
tokenId: number;
48+
last4chars: string;
49+
serviceFrom: string;
50+
serviceTo: string;
51+
exp: string;
52+
issuer: string;
53+
iat: string;
54+
permissions: string[];
55+
}
4756
>,
4857
private readonly _centralSystemWrapper: CentralSystemWrapper
4958
) {
@@ -88,9 +97,15 @@ export class TokensController {
8897
const newTokenId = this._tokensService.size + 1;
8998
const newToken = {
9099
tokenId: newTokenId,
91-
validity: 'good',
92-
payload,
100+
last4chars: 'wxyz',
101+
serviceFrom: 'Service 3',
102+
serviceTo: 'Service 4',
103+
exp: '2025-11-15T08:45:30',
104+
issuer: 'admin-portal',
105+
iat: '2025-09-15T14:22:10',
106+
permissions: ['GET'],
93107
};
108+
94109
this._tokensService.set(newTokenId, newToken);
95110

96111
const client: string =

Tokenization/backend/central-system/src/modules/CentralSystem.ts

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ class CentralSystem {
3131
private PROTO_PATH = path.join(__dirname, '../../../proto/wrapper.proto');
3232
private _fakeTokens: Map<
3333
number,
34-
{ tokenId: number; validity: string; payload: string }
34+
{
35+
tokenId: number;
36+
last4chars: string;
37+
serviceFrom: string;
38+
serviceTo: string;
39+
exp: string;
40+
issuer: string;
41+
iat: string;
42+
permissions: string[];
43+
}
3544
>;
3645
public readonly tokenController: TokensController;
3746

@@ -43,8 +52,58 @@ class CentralSystem {
4352
);
4453
this._centralSystemWrapper.listen();
4554
this._fakeTokens = new Map([
46-
[1, { tokenId: 1, validity: 'good', payload: 'payload1' }],
47-
[2, { tokenId: 2, validity: 'bad', payload: 'payload2' }],
55+
[
56+
1,
57+
{
58+
tokenId: 1,
59+
last4chars: 'abcd',
60+
serviceFrom: 'Service 1',
61+
serviceTo: 'Service 2',
62+
exp: '2026-01-12T11:31:12',
63+
issuer: 'central-system',
64+
iat: '2025-10-01T10:00:00',
65+
permissions: ['GET', 'POST'],
66+
},
67+
],
68+
[
69+
2,
70+
{
71+
tokenId: 2,
72+
last4chars: 'wxyz',
73+
serviceFrom: 'Service 3',
74+
serviceTo: 'Service 4',
75+
exp: '2025-11-15T08:45:30',
76+
issuer: 'admin-portal',
77+
iat: '2025-09-15T14:22:10',
78+
permissions: ['GET'],
79+
},
80+
],
81+
[
82+
3,
83+
{
84+
tokenId: 3,
85+
last4chars: 'efgh',
86+
serviceFrom: 'Service 2',
87+
serviceTo: 'Service 1',
88+
exp: '2026-03-20T16:30:00',
89+
issuer: 'central-system',
90+
iat: '2025-10-02T09:15:00',
91+
permissions: ['GET', 'POST', 'PUT', 'DELETE'],
92+
},
93+
],
94+
[
95+
4,
96+
{
97+
tokenId: 4,
98+
last4chars: '1234',
99+
serviceFrom: 'Service 1',
100+
serviceTo: 'Service 3',
101+
exp: '2026-02-05T12:00:00',
102+
issuer: 'api-gateway',
103+
iat: '2025-09-25T11:30:45',
104+
permissions: ['GET', 'PUT'],
105+
},
106+
],
48107
]);
49108
this.tokenController = new TokensController(
50109
tokensGetService,

Tokenization/backend/central-system/src/services/TokensGetService.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* or submit itself to any jurisdiction.
1313
*/
1414

15-
16-
1715
/**
1816
* @description Service for retrieving tokens from a data source.
1917
*/
@@ -25,14 +23,25 @@ export class TokensGetService {
2523
* @return An array of token objects containing tokenId, validity, and a truncated payload.
2624
*/
2725
public async getTokens(
28-
tokens: Map<number, { tokenId: number; validity: string; payload: string }>
29-
): Promise<Array<{ tokenId: number; validity: string; payload: string }>> {
26+
tokens: Map<
27+
number,
28+
{
29+
tokenId: number;
30+
last4chars: string;
31+
serviceFrom: string;
32+
serviceTo: string;
33+
exp: string;
34+
issuer: string;
35+
iat: string;
36+
permissions: string[];
37+
}
38+
>
39+
): Promise<Array<{ tokenId: number; payload: string }>> {
3040
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
3141
await sleep(1000);
3242
return Array.from(tokens.values()).map((token) => ({
3343
tokenId: token.tokenId,
34-
validity: token.validity,
35-
payload: token.payload.slice(-5),
44+
payload: token.last4chars,
3645
}));
3746
}
3847
}

0 commit comments

Comments
 (0)