@lambda-kata/cdk 0.1.4 → 0.1.6

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.
@@ -1,218 +0,0 @@
1
- /**
2
- * Mock Licensing Service for Lambda Kata CDK Integration Testing
3
- *
4
- * This module provides a mock implementation of the LicensingService interface
5
- * for testing the kata() wrapper without making real network calls.
6
- *
7
- * @module mock-licensing
8
- */
9
- import { LicensingService, LicenseCheckParams } from './licensing';
10
- import { LicensingResponse } from './types';
11
- /**
12
- * Mock implementation of the LicensingService interface for testing.
13
- *
14
- * This class allows programmatic control over entitlement status,
15
- * enabling comprehensive testing of the kata() wrapper behavior
16
- * for both entitled and non-entitled accounts.
17
- *
18
- * @example
19
- * ```typescript
20
- * const mockService = new MockLicensingService();
21
- *
22
- * // Set up an entitled account
23
- * mockService.setEntitled('123456789012', 'arn:aws:lambda:us-east-1:999999999999:layer:LambdaKata:1');
24
- *
25
- * // Check entitlement
26
- * const response = await mockService.checkEntitlement('123456789012');
27
- * console.log(response.entitled); // true
28
- * console.log(response.layerArn); // 'arn:aws:lambda:us-east-1:999999999999:layer:LambdaKata:1'
29
- *
30
- * // Non-entitled account
31
- * const response2 = await mockService.checkEntitlement('000000000000');
32
- * console.log(response2.entitled); // false
33
- * ```
34
- *
35
- * @remarks
36
- * Validates: Requirements 3.2, 3.3
37
- * - 3.2: Provides mock validation of account entitlements
38
- * - 3.3: Returns customer-specific Layer_ARN for entitled accounts
39
- */
40
- export declare class MockLicensingService implements LicensingService {
41
- /**
42
- * Map of AWS account IDs to their entitled Layer ARNs.
43
- * Accounts not in this map are considered non-entitled.
44
- */
45
- private entitlements;
46
- /**
47
- * Map of AWS account IDs to custom messages (for non-entitled accounts).
48
- */
49
- private customMessages;
50
- /**
51
- * Optional custom message to return for entitled accounts.
52
- */
53
- private entitledMessage;
54
- /**
55
- * Optional custom message to return for non-entitled accounts.
56
- * Default matches the expected warning message from Requirement 6.4.
57
- */
58
- private notEntitledMessage;
59
- /**
60
- * Optional expiration date for entitlements.
61
- */
62
- private expiresAt?;
63
- /**
64
- * Flag to simulate service unavailability.
65
- */
66
- private simulateServiceError;
67
- /**
68
- * Custom error message when simulating service errors.
69
- */
70
- private serviceErrorMessage;
71
- /**
72
- * Flag to simulate entitled response without layerArn (service issue).
73
- */
74
- private simulateEntitledWithoutLayerArn;
75
- /**
76
- * Sets an account as entitled with a specific Layer ARN.
77
- *
78
- * @param accountId - The AWS account ID (12-digit string)
79
- * @param layerArn - The customer-specific Lambda Layer ARN
80
- *
81
- * @example
82
- * ```typescript
83
- * mockService.setEntitled('123456789012', 'arn:aws:lambda:us-east-1:999999999999:layer:LambdaKata:1');
84
- * ```
85
- */
86
- setEntitled(accountId: string, layerArn: string): void;
87
- /**
88
- * Removes entitlement for an account.
89
- *
90
- * @param accountId - The AWS account ID to remove entitlement for
91
- *
92
- * @example
93
- * ```typescript
94
- * mockService.removeEntitlement('123456789012');
95
- * ```
96
- */
97
- removeEntitlement(accountId: string): void;
98
- /**
99
- * Clears all entitlements.
100
- *
101
- * @example
102
- * ```typescript
103
- * mockService.clearEntitlements();
104
- * ```
105
- */
106
- clearEntitlements(): void;
107
- /**
108
- * Sets a custom message for entitled accounts.
109
- *
110
- * @param message - The message to return for entitled accounts
111
- */
112
- setEntitledMessage(message: string): void;
113
- /**
114
- * Sets a custom message for non-entitled accounts.
115
- *
116
- * @param message - The message to return for non-entitled accounts
117
- */
118
- setNotEntitledMessage(message: string): void;
119
- /**
120
- * Sets a custom message for a specific non-entitled account.
121
- * This allows testing per-account custom error messages from the licensing service.
122
- *
123
- * @param accountId - The AWS account ID
124
- * @param message - The custom message to return for this account
125
- *
126
- * @example
127
- * ```typescript
128
- * mockService.setCustomMessage('123456789012', 'Custom licensing error: Account suspended');
129
- * ```
130
- */
131
- setCustomMessage(accountId: string, message: string): void;
132
- /**
133
- * Sets the expiration date for entitlements.
134
- *
135
- * @param expiresAt - ISO 8601 formatted expiration date
136
- */
137
- setExpiresAt(expiresAt: string): void;
138
- /**
139
- * Configures the mock to simulate service unavailability.
140
- *
141
- * @param simulate - Whether to simulate service errors
142
- * @param errorMessage - Optional custom error message
143
- *
144
- * @example
145
- * ```typescript
146
- * // Simulate service being down
147
- * mockService.setSimulateServiceError(true);
148
- *
149
- * // With custom error message
150
- * mockService.setSimulateServiceError(true, 'Connection refused');
151
- * ```
152
- */
153
- setSimulateServiceError(simulate: boolean, errorMessage?: string): void;
154
- /**
155
- * Configures the mock to simulate entitled response without layerArn.
156
- * This simulates a licensing service issue where the account is entitled
157
- * but the service fails to return the layer ARN.
158
- *
159
- * @param simulate - Whether to simulate entitled without layerArn
160
- *
161
- * @example
162
- * ```typescript
163
- * // Simulate service returning entitled: true but no layerArn
164
- * mockService.setSimulateEntitledWithoutLayerArn(true);
165
- * ```
166
- */
167
- setSimulateEntitledWithoutLayerArn(simulate: boolean): void;
168
- /**
169
- * Check if an AWS account is entitled to use Lambda Kata.
170
- *
171
- * This mock implementation returns entitlement status based on
172
- * accounts configured via setEntitled().
173
- *
174
- * @param params - License check parameters or accountId string for backward compatibility
175
- * @returns Promise resolving to entitlement status and Layer ARN if entitled
176
- *
177
- * @remarks
178
- * Validates: Requirements 3.2, 3.3
179
- * - 3.2: Validates the account's entitlement based on configured entitlements
180
- * - 3.3: Returns the customer-specific Layer_ARN if entitled
181
- */
182
- checkEntitlement(params: LicenseCheckParams | string): Promise<LicensingResponse>;
183
- /**
184
- * Returns the number of entitled accounts.
185
- *
186
- * @returns The count of entitled accounts
187
- */
188
- getEntitlementCount(): number;
189
- /**
190
- * Checks if a specific account is entitled (without async).
191
- *
192
- * @param accountId - The AWS account ID to check
193
- * @returns true if the account is entitled
194
- */
195
- isEntitled(accountId: string): boolean;
196
- /**
197
- * Gets the Layer ARN for an entitled account (without async).
198
- *
199
- * @param accountId - The AWS account ID
200
- * @returns The Layer ARN if entitled, undefined otherwise
201
- */
202
- getLayerArn(accountId: string): string | undefined;
203
- }
204
- /**
205
- * Creates a MockLicensingService with pre-configured entitlements.
206
- *
207
- * @param entitlements - Map of account IDs to Layer ARNs
208
- * @returns A new MockLicensingService instance with the specified entitlements
209
- *
210
- * @example
211
- * ```typescript
212
- * const mockService = createMockLicensingService({
213
- * '123456789012': 'arn:aws:lambda:us-east-1:999999999999:layer:LambdaKata:1',
214
- * '987654321098': 'arn:aws:lambda:us-west-2:999999999999:layer:LambdaKata:2',
215
- * });
216
- * ```
217
- */
218
- export declare function createMockLicensingService(entitlements?: Record<string, string>): MockLicensingService;