Skip to content

Commit a67a4a8

Browse files
committed
test(git-token-service): expose capability RPC smoke routes
1 parent cf470bf commit a67a4a8

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

services/git-token-service/test/test-worker.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@
1212
* POST /getTokenForRepo - { githubRepo, userId, orgId? }
1313
* POST /getToken - { installationId, appType? }
1414
* POST /getGitLabToken - { userId, orgId?, repositoryUrl?, createdOnPlatform? }
15+
* POST /issueGitHubSessionCapability
16+
* POST /redeemGitHubSessionCapability
17+
* POST /issueGitLabSessionCapability
18+
* POST /redeemGitLabSessionCapability
1519
*/
1620
import type {
1721
GitTokenRPCEntrypoint,
1822
GetTokenForRepoParams,
1923
GetTokenForRepoResult,
2024
GetGitLabTokenParams,
2125
GetGitLabTokenResult,
26+
IssueGitHubSessionCapabilityParams,
27+
IssueGitHubSessionCapabilityResult,
28+
RedeemGitHubSessionCapabilityParams,
29+
RedeemGitHubSessionCapabilityResult,
30+
IssueGitLabSessionCapabilityParams,
31+
IssueGitLabSessionCapabilityResult,
32+
RedeemGitLabSessionCapabilityParams,
33+
RedeemGitLabSessionCapabilityResult,
2234
} from '../src/index.js';
2335
import type { GitHubAppType } from '../src/github-token-service.js';
2436

@@ -58,13 +70,45 @@ export default {
5870
return Response.json(result);
5971
}
6072

73+
if (url.pathname === '/issueGitHubSessionCapability' && request.method === 'POST') {
74+
const body = (await request.json()) as IssueGitHubSessionCapabilityParams;
75+
const result: IssueGitHubSessionCapabilityResult =
76+
await env.GIT_TOKEN_SERVICE.issueGitHubSessionCapability(body);
77+
return Response.json(result, { status: result.success ? 200 : 400 });
78+
}
79+
80+
if (url.pathname === '/redeemGitHubSessionCapability' && request.method === 'POST') {
81+
const body = (await request.json()) as RedeemGitHubSessionCapabilityParams;
82+
const result: RedeemGitHubSessionCapabilityResult =
83+
await env.GIT_TOKEN_SERVICE.redeemGitHubSessionCapability(body);
84+
return Response.json(result, { status: result.success ? 200 : 400 });
85+
}
86+
87+
if (url.pathname === '/issueGitLabSessionCapability' && request.method === 'POST') {
88+
const body = (await request.json()) as IssueGitLabSessionCapabilityParams;
89+
const result: IssueGitLabSessionCapabilityResult =
90+
await env.GIT_TOKEN_SERVICE.issueGitLabSessionCapability(body);
91+
return Response.json(result, { status: result.success ? 200 : 400 });
92+
}
93+
94+
if (url.pathname === '/redeemGitLabSessionCapability' && request.method === 'POST') {
95+
const body = (await request.json()) as RedeemGitLabSessionCapabilityParams;
96+
const result: RedeemGitLabSessionCapabilityResult =
97+
await env.GIT_TOKEN_SERVICE.redeemGitLabSessionCapability(body);
98+
return Response.json(result, { status: result.success ? 200 : 400 });
99+
}
100+
61101
return Response.json(
62102
{
63103
error: 'Not Found',
64104
endpoints: [
65105
'POST /getTokenForRepo - { githubRepo, userId, orgId? }',
66106
'POST /getToken - { installationId, appType? }',
67107
'POST /getGitLabToken - { userId, orgId?, repositoryUrl?, createdOnPlatform? }',
108+
'POST /issueGitHubSessionCapability',
109+
'POST /redeemGitHubSessionCapability',
110+
'POST /issueGitLabSessionCapability',
111+
'POST /redeemGitLabSessionCapability',
68112
],
69113
},
70114
{ status: 404 }

0 commit comments

Comments
 (0)