Skip to content

edmundcong/CloudConformity

Repository files navigation

CloudConformity

Employment exercise for CloudConformity API Gateway + Lambda

How to hit the endpoint

  • do a GET on: https://wdzgnf4au8.execute-api.us-west-2.amazonaws.com/prod/securityGroups
  • Make sure your Content-Type header is set to application/vnd.api+json
  • Make sure your Accept header (if) set includes application/vnd.api+json without any media params
  • To test authorization please pass in Authorization header with value true
  • Example: curl -i -H "Accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" -H "Authorization: true" https://wdzgnf4au8.execute-api.us-west-2.amazonaws.com/prod/securityGroups

File directory:

  • ec2-security-groups: NPM Module
    • test/test.js : Mocha + Chai + Proxyquire tests
    • index.js : Module that we imported into our lambda function
  • get-security-groups: AWS Lambda function
    • node_modules
      • ec2-security-groups: NPM'd version of module
      • all other modules omitted from repo
    • index.js : index.js is our Lambda function (withour our module)
    • test/test.js : Mocha + Chai + Proxyquire tests
    • serverless.yml: Serverless framework yaml file

Code Coverage reports:

Lambda function:



  getSecurityGroups
    ✓ fail as we haven't passed in content-type
    ✓ fail as we have passed in wrong content-type
    ✓ fail as our client submitted correct Accept but wrong content-type
    ✓ should succeed as we've successfully retrieved our security groups from our module
    ✓ should succeed and return an array of size 0
    ✓ should fail as we thrown an error


  6 passing (42ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |      100 |      100 |      100 |      100 |                   |
 index.js |      100 |      100 |      100 |      100 |                   |
----------|----------|----------|----------|----------|-------------------|

Node Module:



 fetchSecurityGroups
   ✓ should succeed and return an object of ec2 security groups

 constructSecurityGroupsArray
   ✓ should return a well formatted object
   ✓ should return empty array


 3 passing (41ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |      100 |      100 |      100 |      100 |                   |
index.js |      100 |      100 |      100 |      100 |                   |
----------|----------|----------|----------|----------|-------------------|

About

Employment exercise for CloudConformity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published