-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from ubc-biztech/dev
Merge dev to prod
- Loading branch information
Showing
28 changed files
with
22,475 additions
and
7,252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
export const INTEGRATION_TEST_USER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_USER_EMAIL = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_USER_EMAIL_2 = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_USER_EMAIL = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_USER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_USER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_USER_EMAIL_2 = "[email protected]"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_USER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_EVENT_ID = "__INTEGRATION_TEST_EVENT_POST"; | ||
export const INTEGRATION_TEST_YEAR = 2020; | ||
export const INTEGRATION_TEST_PERSISTENT_EVENT_ID = "__INTEGRATION_TEST_EVENT"; | ||
export const INTEGRATION_TEST_PERSISTENT_YEAR = 2020; | ||
export const INTEGRATION_TEST_PERSISTENT_EVENT_ID_2 = | ||
"__INTEGRATION_TEST_EVENT_2"; | ||
export const INTEGRATION_TEST_PERSISTENT_EVENT_ID_2 = "__INTEGRATION_TEST_EVENT_2"; | ||
export const INTEGRATION_TEST_PERSISTENT_YEAR_2 = 2020; | ||
export const INTEGRATION_TEST_NON_EXISTANT_EVENT_ID = | ||
"someRandomEventThatDoesNotExist123"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_EVENT_ID = "someRandomEventThatDoesNotExist123"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_YEAR = 1234; | ||
export const INTEGRATION_TEST_PRIZE_ID = "__INTEGRATION_TEST_PRIZE_POST"; | ||
export const INTEGRATION_TEST_PERSISTENT_PRIZE_ID = "__INTEGRATION_TEST_PRIZE"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_PRIZE_ID = | ||
"someRandomPrizeThatDoesNotExist123"; | ||
export const INTEGRATION_TEST_MEMBER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_MEMBER_EMAIL = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_MEMBER_EMAIL_2 = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_NON_EXISTENT_MEMBER_EMAIL = | ||
"[email protected]"; | ||
export const INTEGRATION_TEST_NON_EXISTANT_PRIZE_ID = "someRandomPrizeThatDoesNotExist123"; | ||
export const INTEGRATION_TEST_MEMBER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_MEMBER_EMAIL = "[email protected]"; | ||
export const INTEGRATION_TEST_PERSISTENT_MEMBER_EMAIL_2 = "[email protected]"; | ||
export const INTEGRATION_TEST_NON_EXISTENT_MEMBER_EMAIL = "[email protected]"; | ||
|
||
export const INTEGRATION_TEST_PERSISTENT_REGISTRATION_PARAMETERS = { | ||
eventId: INTEGRATION_TEST_PERSISTENT_EVENT_ID_2, // has capacity of "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,45 @@ | ||
import { | ||
Lambda | ||
} from "@aws-sdk/client-lambda"; | ||
import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda"; | ||
|
||
const OPTIONS = { | ||
region: "us-west-2" | ||
}; | ||
const API_PREFIX = "biztechApi"; | ||
const lambda = new Lambda(OPTIONS); | ||
const lambdaClient = new LambdaClient(OPTIONS); | ||
|
||
export default { | ||
|
||
/** | ||
* Create a promise that invokes specified lambda function for integration testing | ||
* @param {*} functionName - the lambda function name | ||
* @param {*} payload - JSON string with function payload. Empty by default | ||
* Invokes specified lambda function for integration testing | ||
* @param {string} service - the service name | ||
* @param {string} functionName - the lambda function name | ||
* @param {string} payload - JSON string with function payload. Empty by default | ||
* @returns {Promise<[number, object]>} Promise resolving to [statusCode, responseBody] | ||
*/ | ||
invokeLambda: function(service, functionName, payload = "") { | ||
invokeLambda: async function(service, functionName, payload = "") { | ||
const serviceName = service === "" ? API_PREFIX : `${API_PREFIX}-${service}`; | ||
|
||
let params = { | ||
const params = { | ||
FunctionName: `${serviceName}-dev-${functionName}`, | ||
Payload: payload ? Buffer.from(payload) : undefined | ||
}; | ||
if (payload) { | ||
params.Payload = payload; | ||
} | ||
return new Promise((resolve, reject) => { | ||
lambda.invoke(params, function(err, data) { | ||
if (err) { | ||
// something went wrong when invoking function! | ||
console.error(err); | ||
reject(err); | ||
} | ||
|
||
const payload = JSON.parse(data["Payload"]); | ||
if (!payload.hasOwnProperty("statusCode") && !payload.hasOwnProperty("body")) { | ||
resolve([null, null]); | ||
} | ||
resolve([payload.statusCode, JSON.parse(payload.body)]); | ||
}); | ||
}); | ||
try { | ||
const command = new InvokeCommand(params); | ||
const response = await lambdaClient.send(command); | ||
|
||
// Convert Uint8Array to string and parse JSON | ||
const responsePayload = JSON.parse(new TextDecoder().decode(response.Payload)); | ||
|
||
if (!responsePayload.hasOwnProperty("statusCode") && !responsePayload.hasOwnProperty("body")) { | ||
return [null, null]; | ||
} | ||
|
||
return [ | ||
responsePayload.statusCode, | ||
JSON.parse(responsePayload.body) | ||
]; | ||
} catch (error) { | ||
console.error('Lambda invocation error:', error); | ||
throw error; | ||
} | ||
}, | ||
}; |
Oops, something went wrong.