Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

fix: test path and request validation #59

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion todo-src/addTodo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports.addToDoItem = metricScope((metrics) => async (event, context) => {
metrics.putDimensions({ Service: "addTodo" });
metrics.setProperty("RequestId", context.requestId);

if (!isValidRequest(context, event)) {
if (!isValidRequest(event)) {
metrics.putMetric("Error", 1, Unit.Count);
return response(400, { message: "Error: Invalid request" });
}
Expand Down
2 changes: 1 addition & 1 deletion todo-src/completeTodo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ exports.completeToDoItem = metricScope((metrics) => async (event, context) => {
metrics.putDimensions({ Service: "completeTodo" });
metrics.setProperty("RequestId", context.requestId);

if (!isValidRequest(context, event)) {
if (!isValidRequest(event)) {
metrics.putMetric("Error", 1, Unit.Count);
return response(400, { message: "Error: Invalid request" });
}
Expand Down
2 changes: 1 addition & 1 deletion todo-src/deleteTodo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports.deleteToDoItem = metricScope((metrics) => async (event, context) => {
metrics.putDimensions({ Service: "deleteTodo" });
metrics.setProperty("RequestId", context.requestId);

if (!isValidRequest(context, event)) {
if (!isValidRequest(event)) {
metrics.putMetric("Error", 1, Unit.Count);
return response(400, { message: "Error: Invalid request" });
}
Expand Down
2 changes: 1 addition & 1 deletion todo-src/getTodo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports.getToDoItem = metricScope((metrics) => async (event, context) => {
metrics.setNamespace("TodoApp");
metrics.putDimensions({ Service: "getTodo" });
metrics.setProperty("RequestId", context.requestId);
if (!isValidRequest(context, event)) {
if (!isValidRequest(event)) {
metrics.putMetric("Error", 1, Unit.Count);
return response(400, { message: "Error: Invalid request" });
}
Expand Down
2 changes: 1 addition & 1 deletion todo-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"axios": "^0.21.1"
},
"scripts": {
"test": "mocha tests/unit/"
"test": "mocha test/unit/"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion todo-src/test/unit/test-handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const app = require('../../app.js');
const app = require('../../getTodo/app.js');
const chai = require('chai');
const expect = chai.expect;
var event, context;
Expand Down
2 changes: 1 addition & 1 deletion todo-src/updateTodo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ exports.updateToDoItem = metricScope((metrics) => async (event, context) => {
metrics.putDimensions({ Service: "updateTodo" });
metrics.setProperty("RequestId", context.requestId);

if (!isValidRequest(context, event)) {
if (!isValidRequest(event)) {
metrics.putMetric("Error", 1, Unit.Count);
return response(400, { message: "Error: Invalid request" });
}
Expand Down
8 changes: 4 additions & 4 deletions www/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// aws cloudformation describe-stacks --stack-name <YOUR STACK NAME> --query "Stacks[0].Outputs[]"

const config = {
"aws_user_pools_web_client_id": "None", // CognitoClientID
"api_base_url": "None", // TodoFunctionApi
"cognito_hosted_domain": "None", // CognitoDomainName
"redirect_url": "None" // AmplifyURL
"aws_user_pools_web_client_id": "31i4f4k9uqujnsl6o4aumcvlgu", // CognitoClientID
"api_base_url": "https://l1unaseofh.execute-api.us-west-2.amazonaws.com/prod", // TodoFunctionApi
"cognito_hosted_domain": "mytodoappdemo-todo-demo.auth.us-west-2.amazoncognito.com", // CognitoDomainName
"redirect_url": "https://master.d1gbbx9nzhqa8j.amplifyapp.com" // AmplifyURL
};

export default config;