@gitpod/gitpod-protocol 0.1.5-sje-pacman.1 → 0.1.5-sje-kots-node-reqs.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +153 -2
- package/lib/accounting-protocol.d.ts +7 -0
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +8 -1
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +4 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/attribution.d.ts +20 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +40 -0
- package/lib/attribution.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.js +1 -1
- package/lib/context-url.js.map +1 -1
- package/lib/env.d.ts +0 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +1 -20
- package/lib/env.js.map +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +8 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +35 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +22 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +53 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +23 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/gitpod-service.d.ts +29 -5
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +20 -10
- package/lib/gitpod-service.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +3 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +1 -0
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +7 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -0
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -0
- package/lib/messaging/error.js.map +1 -1
- package/lib/protocol.d.ts +86 -4
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +183 -12
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +16 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +12 -1
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +18 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/usage.d.ts +22 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +115 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/generate-workspace-id.d.ts +5 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +12 -8
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +10 -3
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +9 -2
- package/lib/util/logging.js.map +1 -1
- package/lib/util/timeutil.d.ts +1 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +7 -1
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +8 -10
- package/lib/util/tracing.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-cluster.d.ts +5 -7
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +17 -1
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.js +1 -1
- package/package.json +9 -6
- package/pkg-yarn.lock +7 -5
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +10 -0
- package/src/admin-protocol.ts +7 -0
- package/src/attribution.ts +48 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.ts +1 -1
- package/src/env.ts +0 -22
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +38 -0
- package/src/experiments/configcat.ts +58 -0
- package/src/experiments/types.ts +35 -0
- package/src/gitpod-service.ts +54 -11
- package/src/index.ts +1 -0
- package/src/installation-admin-protocol.ts +3 -0
- package/src/license-protocol.ts +7 -0
- package/src/messaging/error.ts +6 -0
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +258 -13
- package/src/team-subscription-protocol.ts +24 -0
- package/src/teams-projects-protocol.ts +20 -0
- package/src/usage.ts +146 -0
- package/src/util/debug-app.ts +81 -0
- package/src/util/generate-workspace-id.spec.ts +10 -3
- package/src/util/generate-workspace-id.ts +9 -3
- package/src/util/logging.ts +11 -3
- package/src/util/timeutil.ts +6 -0
- package/src/util/tracing.ts +8 -10
- package/src/webhook-event.ts +55 -0
- package/src/workspace-cluster.ts +2 -4
- package/src/workspace-instance.ts +30 -1
- package/src/wsready.ts +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License-AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { User } from "../protocol";
|
|
8
|
+
import { Team } from "../teams-projects-protocol";
|
|
9
|
+
|
|
10
|
+
export const Client = Symbol("Client");
|
|
11
|
+
|
|
12
|
+
// Attributes define attributes which can be used to segment audiences.
|
|
13
|
+
// Set the attributes which you want to use to group audiences into.
|
|
14
|
+
export interface Attributes {
|
|
15
|
+
// user.id is mapped to ConfigCat's "identifier" + "custom.user_id"
|
|
16
|
+
user?: User | { id: string; email?: string };
|
|
17
|
+
|
|
18
|
+
// Currently selected Gitpod Project ID (mapped to "custom.project_id")
|
|
19
|
+
projectId?: string;
|
|
20
|
+
|
|
21
|
+
// Currently selected Gitpod Team ID (mapped to "custom.team_id")
|
|
22
|
+
teamId?: string;
|
|
23
|
+
// Currently selected Gitpod Team Name (mapped to "custom.team_name")
|
|
24
|
+
teamName?: string;
|
|
25
|
+
|
|
26
|
+
// All the Gitpod Teams that the user is a member (or owner) of (mapped to "custom.team_names" and "custom.team_ids")
|
|
27
|
+
teams?: Team[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Client {
|
|
31
|
+
getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T>;
|
|
32
|
+
|
|
33
|
+
// dispose will dispose of the client, no longer retrieving flags
|
|
34
|
+
dispose(): void;
|
|
35
|
+
}
|
package/src/gitpod-service.ts
CHANGED
|
@@ -24,6 +24,9 @@ import {
|
|
|
24
24
|
GuessGitTokenScopesParams,
|
|
25
25
|
GuessedGitTokenScopes,
|
|
26
26
|
ProjectEnvVar,
|
|
27
|
+
PrebuiltWorkspace,
|
|
28
|
+
UserSSHPublicKeyValue,
|
|
29
|
+
SSHPublicKeyValue,
|
|
27
30
|
} from "./protocol";
|
|
28
31
|
import {
|
|
29
32
|
Team,
|
|
@@ -34,6 +37,7 @@ import {
|
|
|
34
37
|
PrebuildWithStatus,
|
|
35
38
|
StartPrebuildResult,
|
|
36
39
|
PartialProject,
|
|
40
|
+
PrebuildEvent,
|
|
37
41
|
} from "./teams-projects-protocol";
|
|
38
42
|
import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
|
|
39
43
|
import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
|
|
@@ -47,10 +51,17 @@ import { LicenseService } from "./license-protocol";
|
|
|
47
51
|
import { Emitter } from "./util/event";
|
|
48
52
|
import { AccountStatement, CreditAlert } from "./accounting-protocol";
|
|
49
53
|
import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
|
|
50
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
TeamSubscription,
|
|
56
|
+
TeamSubscription2,
|
|
57
|
+
TeamSubscriptionSlot,
|
|
58
|
+
TeamSubscriptionSlotResolved,
|
|
59
|
+
} from "./team-subscription-protocol";
|
|
51
60
|
import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
|
|
52
61
|
import { IDEServer } from "./ide-protocol";
|
|
53
62
|
import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
|
|
63
|
+
import { Currency } from "./plans";
|
|
64
|
+
import { BillableSession } from "./usage";
|
|
54
65
|
|
|
55
66
|
export interface GitpodClient {
|
|
56
67
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
@@ -142,6 +153,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
142
153
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
143
154
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
144
155
|
|
|
156
|
+
// User SSH Keys
|
|
157
|
+
hasSSHPublicKey(): Promise<boolean>;
|
|
158
|
+
getSSHPublicKeys(): Promise<UserSSHPublicKeyValue[]>;
|
|
159
|
+
addSSHPublicKey(value: SSHPublicKeyValue): Promise<UserSSHPublicKeyValue>;
|
|
160
|
+
deleteSSHPublicKey(id: string): Promise<void>;
|
|
161
|
+
|
|
145
162
|
// Teams
|
|
146
163
|
getTeams(): Promise<Team[]>;
|
|
147
164
|
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
@@ -165,7 +182,10 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
165
182
|
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
166
183
|
getUserProjects(): Promise<Project[]>;
|
|
167
184
|
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
185
|
+
getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
|
|
168
186
|
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
187
|
+
findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
|
|
188
|
+
getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
|
|
169
189
|
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
170
190
|
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
171
191
|
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
@@ -189,6 +209,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
189
209
|
|
|
190
210
|
// misc
|
|
191
211
|
sendFeedback(feedback: string): Promise<string | undefined>;
|
|
212
|
+
isGitHubAppEnabled(): Promise<boolean>;
|
|
192
213
|
registerGithubApp(installationId: string): Promise<void>;
|
|
193
214
|
|
|
194
215
|
/**
|
|
@@ -234,7 +255,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
234
255
|
*/
|
|
235
256
|
getChargebeeSiteId(): Promise<string>;
|
|
236
257
|
createPortalSession(): Promise<{}>;
|
|
258
|
+
createTeamPortalSession(teamId: string): Promise<{}>;
|
|
237
259
|
checkout(planId: string, planQuantity?: number): Promise<{}>;
|
|
260
|
+
teamCheckout(teamId: string, planId: string): Promise<{}>;
|
|
238
261
|
getAvailableCoupons(): Promise<PlanCoupon[]>;
|
|
239
262
|
getAppliedCoupons(): Promise<PlanCoupon[]>;
|
|
240
263
|
|
|
@@ -246,6 +269,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
246
269
|
subscriptionCancel(subscriptionId: string): Promise<void>;
|
|
247
270
|
subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
|
|
248
271
|
|
|
272
|
+
getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
|
|
249
273
|
tsGet(): Promise<TeamSubscription[]>;
|
|
250
274
|
tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
|
|
251
275
|
tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
|
|
@@ -261,6 +285,14 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
261
285
|
|
|
262
286
|
getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
|
|
263
287
|
|
|
288
|
+
getStripePublishableKey(): Promise<string>;
|
|
289
|
+
getStripeSetupIntentClientSecret(): Promise<string>;
|
|
290
|
+
findStripeSubscriptionIdForTeam(teamId: string): Promise<string | undefined>;
|
|
291
|
+
subscribeTeamToStripe(teamId: string, setupIntentId: string, currency: Currency): Promise<void>;
|
|
292
|
+
getStripePortalUrlForTeam(teamId: string): Promise<string>;
|
|
293
|
+
|
|
294
|
+
getBilledUsage(attributionId: string): Promise<BillableSession[]>;
|
|
295
|
+
|
|
264
296
|
/**
|
|
265
297
|
* Analytics
|
|
266
298
|
*/
|
|
@@ -307,7 +339,7 @@ export interface ProviderRepository {
|
|
|
307
339
|
account: string;
|
|
308
340
|
accountAvatarUrl: string;
|
|
309
341
|
cloneUrl: string;
|
|
310
|
-
updatedAt
|
|
342
|
+
updatedAt?: string;
|
|
311
343
|
installationId?: number;
|
|
312
344
|
installationUpdatedAt?: string;
|
|
313
345
|
|
|
@@ -321,7 +353,16 @@ export interface ClientHeaderFields {
|
|
|
321
353
|
clientRegion?: string;
|
|
322
354
|
}
|
|
323
355
|
|
|
324
|
-
export const
|
|
356
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_SHORT = "short";
|
|
357
|
+
export const WORKSPACE_TIMEOUT_DEFAULT_LONG = "long";
|
|
358
|
+
export const WORKSPACE_TIMEOUT_EXTENDED = "extended";
|
|
359
|
+
export const WORKSPACE_TIMEOUT_EXTENDED_ALT = "180m"; // for backwards compatibility since the IDE uses this
|
|
360
|
+
export const WorkspaceTimeoutValues = [
|
|
361
|
+
WORKSPACE_TIMEOUT_DEFAULT_SHORT,
|
|
362
|
+
WORKSPACE_TIMEOUT_DEFAULT_LONG,
|
|
363
|
+
WORKSPACE_TIMEOUT_EXTENDED,
|
|
364
|
+
WORKSPACE_TIMEOUT_EXTENDED_ALT,
|
|
365
|
+
] as const;
|
|
325
366
|
|
|
326
367
|
export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
|
|
327
368
|
methods: Partial<JsonRpcProxy<S>>,
|
|
@@ -339,7 +380,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
|
|
|
339
380
|
get: (target: S, property: keyof S) => {
|
|
340
381
|
const result = target[property];
|
|
341
382
|
if (!result) {
|
|
342
|
-
throw new Error(`Method ${property} not implemented`);
|
|
383
|
+
throw new Error(`Method ${String(property)} not implemented`);
|
|
343
384
|
}
|
|
344
385
|
return result;
|
|
345
386
|
},
|
|
@@ -355,6 +396,7 @@ export interface SetWorkspaceTimeoutResult {
|
|
|
355
396
|
|
|
356
397
|
export interface GetWorkspaceTimeoutResult {
|
|
357
398
|
duration: WorkspaceTimeoutDuration;
|
|
399
|
+
durationRaw: string;
|
|
358
400
|
canChange: boolean;
|
|
359
401
|
}
|
|
360
402
|
|
|
@@ -520,13 +562,14 @@ const hasWindow = typeof window !== "undefined";
|
|
|
520
562
|
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
|
|
521
563
|
unknown: 0,
|
|
522
564
|
preparing: 1,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
565
|
+
building: 2,
|
|
566
|
+
pending: 3,
|
|
567
|
+
creating: 4,
|
|
568
|
+
initializing: 5,
|
|
569
|
+
running: 6,
|
|
570
|
+
interrupted: 7,
|
|
571
|
+
stopping: 8,
|
|
572
|
+
stopped: 9,
|
|
530
573
|
};
|
|
531
574
|
export class WorkspaceInstanceUpdateListener {
|
|
532
575
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
8
8
|
|
|
9
9
|
const InstallationAdminSettingsPrototype = {
|
|
10
10
|
sendTelemetry: true,
|
|
11
|
+
sendCustomerID: true,
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export type InstallationAdminSettings = typeof InstallationAdminSettingsPrototype;
|
|
@@ -28,6 +29,8 @@ export interface TelemetryData {
|
|
|
28
29
|
totalUsers: number;
|
|
29
30
|
totalWorkspaces: number;
|
|
30
31
|
totalInstances: number;
|
|
32
|
+
licenseType: string;
|
|
33
|
+
customerID?: string;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export namespace InstallationAdmin {
|
package/src/license-protocol.ts
CHANGED
|
@@ -15,9 +15,15 @@ export type LicenseIssue = "seats-exhausted";
|
|
|
15
15
|
export interface LicenseInfo {
|
|
16
16
|
key: string;
|
|
17
17
|
seats: number;
|
|
18
|
+
userCount?: number;
|
|
18
19
|
valid: boolean;
|
|
19
20
|
validUntil: string;
|
|
20
21
|
plan?: string;
|
|
22
|
+
features?: string[];
|
|
23
|
+
enabledFeatures?: string[];
|
|
24
|
+
type?: string;
|
|
25
|
+
errorMsg?: string;
|
|
26
|
+
fallbackAllowed: boolean;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export interface GetLicenseInfoResult {
|
|
@@ -33,5 +39,6 @@ export enum LicenseFeature {
|
|
|
33
39
|
export interface LicenseService {
|
|
34
40
|
validateLicense(): Promise<LicenseValidationResult>;
|
|
35
41
|
getLicenseInfo(): Promise<GetLicenseInfoResult>;
|
|
42
|
+
adminGetLicense(): Promise<LicenseInfo>;
|
|
36
43
|
licenseIncludesFeature(feature: LicenseFeature): Promise<boolean>;
|
|
37
44
|
}
|
package/src/messaging/error.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export namespace ErrorCodes {
|
|
8
|
+
// 400 Unauthorized
|
|
9
|
+
export const BAD_REQUEST = 400;
|
|
10
|
+
|
|
8
11
|
// 401 Unauthorized
|
|
9
12
|
export const NOT_AUTHENTICATED = 401;
|
|
10
13
|
|
|
@@ -59,6 +62,9 @@ export namespace ErrorCodes {
|
|
|
59
62
|
// 490 Too Many Running Workspace
|
|
60
63
|
export const TOO_MANY_RUNNING_WORKSPACES = 490;
|
|
61
64
|
|
|
65
|
+
// 500 Internal Server Error
|
|
66
|
+
export const INTERNAL_SERVER_ERROR = 500;
|
|
67
|
+
|
|
62
68
|
// 501 EE Feature
|
|
63
69
|
export const EE_FEATURE = 501;
|
|
64
70
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License-AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { suite, test } from "mocha-typescript";
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
import { SSHPublicKeyValue } from ".";
|
|
10
|
+
|
|
11
|
+
const expect = chai.expect;
|
|
12
|
+
|
|
13
|
+
@suite
|
|
14
|
+
class TestSSHPublicKeyValue {
|
|
15
|
+
private key =
|
|
16
|
+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCnrN9UdK1bNGPmZfenTWXLuYYDjlYvZE8S+WOfP08WpR1GETzX5ZvgYOEZGwEE8KUPHC9cge4Hvo/ydIS9aqbZ5MiVGJ8cAIq1Ic89SjlDWU6fl8TwIqOPCi2imAASlEDP4q8vMLK1N6UOW1EVbxyL3uybGd10ysC1t1FxFPveIGNsYE/MOQeuEWS16AplpXYXIfVRSlgAskeBft2w8Ud3B4gNe8ECLA/FXu96UpvZkdtOarA3JZ9Z27GveNJg9Mtmmw0+US0KXiO9x9NyH7G8+mqVDwDY+nNvaFA5gtQxkkl/uY2oz9k/B4Rjlj3jOiUXe5uQs3XUm5m8g9a9fh62DabLpA2fEvtfg+a/VqNe52dNa5YjupwvBd6Inb5uMW/TYjNl6bNHPlXFKw/nwLOVzukpkjxMZUKS6+4BGkpoasj6y2rTU/wkpbdD8J7yjI1p6J9aKkC6KksIWgN7xGmHkv2PCGDqMHTNbnQyowtNKMgA/667vAYJ0qW7HAHBFXJRs6uRi/DI3+c1QV2s4wPCpEHDIYApovQ0fbON4WDPoGMyHd7kPh9xB/bX7Dj0uMXImu1pdTd62fQ/1XXX64+vjAAXS/P9RSCD0RCRt/K3LPKl2m7GPI3y1niaE52XhxZw+ms9ays6NasNVMw/ZC+f02Ti+L5FBEVf8230RVVRQ== notfound@gitpod.io";
|
|
17
|
+
|
|
18
|
+
@test public testValidate() {
|
|
19
|
+
const key = this.key;
|
|
20
|
+
const [t, k, e] = key.split(" ");
|
|
21
|
+
expect(
|
|
22
|
+
SSHPublicKeyValue.getData({
|
|
23
|
+
key,
|
|
24
|
+
name: "NiceName",
|
|
25
|
+
}),
|
|
26
|
+
).to.deep.equal({ type: t, key: k, email: e });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@test public testValidateWithDiffType() {
|
|
30
|
+
const key = this.key;
|
|
31
|
+
const [_, k, e] = key.split(" ");
|
|
32
|
+
expect(
|
|
33
|
+
SSHPublicKeyValue.getData({
|
|
34
|
+
key: key.replace("ssh-rsa", "sk-ecdsa-sha2-nistp256@openssh.com"),
|
|
35
|
+
name: "NiceName",
|
|
36
|
+
}),
|
|
37
|
+
).to.deep.equal({ type: "sk-ecdsa-sha2-nistp256@openssh.com", key: k, email: e });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@test public testValidateWithoutEmail() {
|
|
41
|
+
const key = this.key;
|
|
42
|
+
const [t, k, _] = key.split(" ");
|
|
43
|
+
expect(
|
|
44
|
+
SSHPublicKeyValue.getData({
|
|
45
|
+
key: key.replace(" notfound@gitpod.io", ""),
|
|
46
|
+
name: "NiceName",
|
|
47
|
+
}),
|
|
48
|
+
).to.deep.equal({ type: t, key: k, email: undefined });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@test public testValidateWithoutEmailButEndsWithSpaces() {
|
|
52
|
+
const key = this.key;
|
|
53
|
+
const [t, k, _] = key.split(" ");
|
|
54
|
+
expect(
|
|
55
|
+
SSHPublicKeyValue.getData({
|
|
56
|
+
key: key.replace("notfound@gitpod.io", " "),
|
|
57
|
+
name: "NiceName",
|
|
58
|
+
}),
|
|
59
|
+
).to.deep.equal({ type: t, key: k, email: undefined });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@test public testValidateWithError() {
|
|
63
|
+
expect(() =>
|
|
64
|
+
SSHPublicKeyValue.getData({
|
|
65
|
+
key: "Hello World",
|
|
66
|
+
name: "NiceName",
|
|
67
|
+
}),
|
|
68
|
+
).throw("Key is invalid");
|
|
69
|
+
|
|
70
|
+
expect(() =>
|
|
71
|
+
SSHPublicKeyValue.getData({
|
|
72
|
+
key: "",
|
|
73
|
+
name: "NiceName",
|
|
74
|
+
}),
|
|
75
|
+
).throw("Key is invalid");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@test public testGetFingerprint() {
|
|
79
|
+
const key = this.key;
|
|
80
|
+
expect(
|
|
81
|
+
SSHPublicKeyValue.getFingerprint({
|
|
82
|
+
key,
|
|
83
|
+
name: "NiceName",
|
|
84
|
+
}),
|
|
85
|
+
).to.equal("ykjP/b5aqoa3envmXzWpPMCGgEFMu3QvubfSTNrJCMA=");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@test public testGetFingerprintWithIncorrectPublicKey() {
|
|
89
|
+
expect(() =>
|
|
90
|
+
SSHPublicKeyValue.getFingerprint({
|
|
91
|
+
key: "Hello World",
|
|
92
|
+
name: "NiceName",
|
|
93
|
+
}),
|
|
94
|
+
).to.throw("Key is invalid");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
module.exports = new TestSSHPublicKeyValue(); // Only to circumvent no usage warning :-/
|