Skip to content

Commit 8f2f6bd

Browse files
authored
📝 FC-2013 Adjusted docs and integration Tests (#130)
* Simplified integration tests * adjusted integration test var naming * Adjusted documentation * adjust readme * adjusted docs
1 parent bbb17b6 commit 8f2f6bd

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

.github/workflows/integration-test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,19 @@ jobs:
2121
- run: npm run integration
2222
env:
2323
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
24-
SUCCESS_LAMBDA_UUID: ${{ secrets.SUCCESS_LAMBDA_UUID }}
24+
FUNCTION_UUID: ${{ secrets.FUNCTION_UUID }}
2525
CLIENT_ID: ${{ secrets.CLIENT_ID }}
2626
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
2727
OAUTH_API_KEY: ${{ secrets.OAUTH_API_KEY }}
2828
OAUTH_API_SECRET: ${{ secrets.OAUTH_API_SECRET }}
2929
OAUTH_TOKEN_KEY: ${{ secrets.OAUTH_TOKEN_KEY }}
3030
OAUTH_TOKEN_SECRET: ${{ secrets.OAUTH_TOKEN_SECRET }}
3131
OAUTH_SIGNATURE_METHOD: ${{ secrets.OAUTH_SIGNATURE_METHOD }}
32-
ERROR_LAMBDA_UUID: ${{ secrets.ERROR_LAMBDA_UUID }}
3332
USER_ID: ${{ secrets.USER_ID }}
3433
ACCOUNT_ID_V1: ${{ secrets.ACCOUNT_ID_V1 }}
35-
SUCCESS_LAMBDA_UUID_V1: ${{ secrets.SUCCESS_LAMBDA_UUID_V1 }}
34+
LAMBDA_UUID_V1: ${{ secrets.SUCCESS_LAMBDA_UUID_V1 }}
3635
CLIENT_ID_V1: ${{ secrets.CLIENT_ID_V1 }}
3736
CLIENT_SECRET_V1: ${{ secrets.CLIENT_SECRET_V1 }}
38-
ERROR_LAMBDA_UUID_V1: ${{ secrets.ERROR_LAMBDA_UUID_V1 }}
3937
USER_ID_V1: ${{ secrets.USER_ID_V1 }}
4038
USER_NAME: ${{ secrets.USER_NAME }}
4139
PASSWORD: ${{ secrets.PASSWORD }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ We are excited to announce a **major update** to our client: **Functions V2** is
3636
- *DefaultConfig* `apiVersion`: not available in V2. Still used for V1.
3737
- *DefaultConfig* `getLambdasUri`: use `getFunctionsUri` instead.
3838
- *InvocationMetricData* `externalSystem`: use `lpEventSource` instead.
39-
- Method *getLambdas()*: use `getFunctions` instead.
39+
- Method *getLambdas()*: Now compatible with V1 and V2. Only for V2 `getFunctions` is recommended.
4040
- Type *BaseQuery*: not used in V2. Still used for V1.
4141
- Type *GetLambdasQuery*: replaced by `GetFunctionsQuery` in V2.
4242
- Type *LambdaRequest*: replaced by `FunctionRequest`in V2.

src/client/baseClient.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ export class BaseClient {
113113
}
114114
}
115115

116+
// TODO: Remove once V1 is shut down.
116117
/**
117-
* Lists functions.
118-
*
119-
* @param lambdaRequestData filtering data
120-
* @returns A list of functions.
121-
* @deprecated While still compatible with V2 Functions, using 'getFunctions' is recommended.
118+
* Lists functions. compatible with V2 and V1 Functions.
119+
* Should be used during transition period to V2. Please be aware than some V2 functions properties may be different than V1.
120+
* @param lambdaRequestData filtering data.
121+
* @returns A list of functions (V2 or V1).
122+
* @deprecated Will be replaced by 'getFunctions' in V2.
122123
*/
123124
async getLambdas(lambdaRequestData: LambdaRequest): Promise<Response> {
124125
const baseMetrics = this.collectBaseMetricsFrom(lambdaRequestData);
@@ -129,7 +130,6 @@ export class BaseClient {
129130
this.config.uiCsdsServiceName
130131
));
131132

132-
// TODO: Remove once V1 is shut down.
133133
const isV2 = this.isV2Domain(domain);
134134

135135
const resp = isV2
@@ -168,6 +168,11 @@ export class BaseClient {
168168
}
169169
}
170170

171+
/**
172+
* Lists functions, Only V2.
173+
* @param functionRequestData filtering data.
174+
* @returns A list of functions.
175+
*/
171176
async getFunctions(functionRequestData: FunctionRequest): Promise<Response> {
172177
const baseMetrics = this.collectBaseMetricsFrom(functionRequestData);
173178
const watch = new stopwatch();

test/integration/invoke.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {GetAuthorizationHeader} from '../../src/client/clientConfig';
44
import {createHmac} from 'crypto';
55
import OAuth from 'oauth-1.0a';
66

7-
const successLambdaUUID =
8-
process.env['SUCCESS_LAMBDA_UUID_V1'] || 'does-not-exist';
7+
const lambdaUUID =
8+
process.env['LAMBDA_UUID_V1'] || 'does-not-exist';
99
const accountId = process.env['ACCOUNT_ID_V1'] || 'does-not-exist';
1010
const clientId = process.env['CLIENT_ID_V1'] || 'does-not-exist';
1111
const clientSecret = process.env['CLIENT_SECRET_V1'] || 'does-not-exist';
@@ -32,7 +32,7 @@ describe('Invoke by UUID', () => {
3232
};
3333

3434
const response = await client.invoke({
35-
lambdaUuid: successLambdaUUID,
35+
lambdaUuid: lambdaUUID,
3636
externalSystem: 'integration-tests',
3737
body: {
3838
headers: [],
@@ -44,7 +44,7 @@ describe('Invoke by UUID', () => {
4444
});
4545

4646
// Skipped, Oauth1 will be deprecated
47-
/* it.skip('should invoke and get result via custom Oauth1 implementation', async () => {
47+
it.skip('should invoke and get result via custom Oauth1 implementation', async () => {
4848
// custom auth implementation start
4949
const getAuthorizationHeader: GetAuthorizationHeader = async ({
5050
url,
@@ -82,7 +82,7 @@ describe('Invoke by UUID', () => {
8282
};
8383

8484
const response = await client.invoke({
85-
lambdaUuid: successLambdaUUID,
85+
lambdaUuid: lambdaUUID,
8686
externalSystem: 'integration-tests',
8787
body: {
8888
headers: [],
@@ -92,7 +92,7 @@ describe('Invoke by UUID', () => {
9292
});
9393

9494
expect(response.ok).toEqual(true);
95-
});*/
95+
});
9696

9797
it('should fail if lambda does not exist', async () => {
9898
const nonExistingLambda = 'c521cadf-d444-4519-ad11-1c1111114415';

test/integration/invoke.v2.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import {
66
} from '../../src/helper/metricCollector';
77
import {Tooling} from '../../src/types/tooling';
88

9-
const successLambdaUUID =
10-
process.env['SUCCESS_LAMBDA_UUID'] || 'does-not-exist';
9+
const functionUUID =
10+
process.env['FUNCTION_UUID'] || 'does-not-exist';
1111

12-
const errorLambdaUUID = process.env['ERROR_LAMBDA_UUID'] || 'does-not-exist';
1312
const accountId = process.env['ACCOUNT_ID'] || 'does-not-exist';
1413
const clientId = process.env['CLIENT_ID'] || 'does-not-exist';
1514
const clientSecret = process.env['CLIENT_SECRET'] || 'does-not-exist';
@@ -60,7 +59,7 @@ describe('V2 Invoke by UUID', () => {
6059
});
6160

6261
const response = await client.invoke({
63-
lambdaUuid: successLambdaUUID,
62+
lambdaUuid: functionUUID,
6463
lpEventSource: 'integration-tests',
6564
body: {
6665
headers: [],
@@ -86,18 +85,18 @@ describe('V2 Invoke by UUID', () => {
8685

8786
try {
8887
await client.invoke({
89-
lambdaUuid: errorLambdaUUID,
88+
lambdaUuid: functionUUID,
9089
externalSystem: 'integration-tests',
9190
body: {
92-
headers: [],
91+
headers: [{key:"run",value: "error"}],
9392
payload,
9493
},
9594
});
9695
fail('should fail');
9796
} catch (error: any) {
9897
expect(error?.name).toEqual('FaaSLambdaError');
9998
expect(error?.message).toStartWith(
100-
`Failed to invoke lambda : ${errorLambdaUUID}`
99+
`Failed to invoke lambda : ${functionUUID}`
101100
);
102101
}
103102
});

0 commit comments

Comments
 (0)