-
Notifications
You must be signed in to change notification settings - Fork 235
Feat/nested ou targets #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e9da14c
Adding in additional tests for account processing
StewartW 6d66b50
Adding in unit tests for organisations abstraction
StewartW 4dc256f
Adding in unit tests for organisations abstraction
StewartW 9c0e205
Initial commit - Now optionally resolves children OUs
StewartW d73ef44
Linting
StewartW 164b2cc
starting exclusion work
StewartW b70a628
Merge branch 'master' of github.com:awslabs/aws-deployment-framework …
StewartW 00178e1
Adding in unit tests for schema validation
StewartW 55e82d0
Adding in an example config to user-guide.md
StewartW f037976
Merge branch 'master' into feat/nested-ou-targets
StewartW d986010
Merge branch 'master' of github.com:awslabs/aws-deployment-framework …
StewartW e76c208
Merge branch 'feat/nested-ou-targets' of github.com:StewartW/aws-depl…
StewartW a8f4b7f
Merge branch 'master' into feat/nested-ou-targets
StewartW f83be8d
Codereview comments
StewartW 6e4feec
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
StewartW c1df9de
Apply suggestions from code review
sbkok addf71c
Merge remote-tracking branch 'upstream/master' into feat/nested-ou-ta…
sbkok 9f9566b
Remove redundant pylint disable line
sbkok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,5 +3,6 @@ isort==5.12.0 | |
| mock==5.1.0 | ||
| pylint==2.17.4 | ||
| pytest~=7.4.0 | ||
| pytest-cov==3.0.0 | ||
| tox==3.28.0 | ||
| yamllint==1.32.0 | ||
This file contains hidden or 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 hidden or 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 hidden or 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,2 +1,7 @@ | ||
| [pytest] | ||
| testpaths = tests | ||
| addopts = --cov=./src/lambda_codebase/account_processing/ --cov-fail-under=50 --cov-report term | ||
|
|
||
| [coverage:run] | ||
| omit = tests/ | ||
|
|
62 changes: 62 additions & 0 deletions
62
src/lambda_codebase/account_processing/tests/test_account_tags.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| """ | ||
| Tests the account tag configuration lambda | ||
| """ | ||
|
|
||
| import unittest | ||
| import boto3 | ||
| from botocore.stub import Stubber | ||
| from aws_xray_sdk import global_sdk_config | ||
| from ..configure_account_tags import ( | ||
| create_account_tags, | ||
| ) | ||
|
|
||
| global_sdk_config.set_sdk_enabled(False) | ||
|
|
||
| # pylint: disable=W0106 | ||
| class SuccessTestCase(unittest.TestCase): | ||
| def test_account_tag_creation(self): | ||
| test_event = {"account_id": "123456789012", "tags": [{"CreatedBy": "ADF"}]} | ||
| ou_client = boto3.client("organizations") | ||
| stubber = Stubber(ou_client) | ||
| stubber.add_response( | ||
| "tag_resource", | ||
| {}, | ||
| { | ||
| "Tags": [{"Key": "CreatedBy", "Value": "ADF"}], | ||
| "ResourceId": "123456789012", | ||
| }, | ||
| ), | ||
| stubber.activate() | ||
| create_account_tags( | ||
| test_event.get("account_id"), test_event.get("tags"), ou_client | ||
| ) | ||
| stubber.assert_no_pending_responses() | ||
|
|
||
| def test_account_tag_creation_multiple_tags(self): | ||
| test_event = { | ||
| "account_id": "123456789012", | ||
| "tags": [ | ||
| { | ||
| "CreatedBy": "ADF", | ||
| "TagName": "TagValue", | ||
| } | ||
| ], | ||
| } | ||
| ou_client = boto3.client("organizations") | ||
| stubber = Stubber(ou_client) | ||
| stubber.add_response( | ||
| "tag_resource", | ||
| {}, | ||
| { | ||
| "Tags": [ | ||
| {"Key": "CreatedBy", "Value": "ADF"}, | ||
| {"Key": "TagName", "Value": "TagValue"}, | ||
| ], | ||
| "ResourceId": "123456789012", | ||
| }, | ||
| ), | ||
| stubber.activate() | ||
| create_account_tags( | ||
| test_event.get("account_id"), test_event.get("tags"), ou_client | ||
| ) | ||
| stubber.assert_no_pending_responses() | ||
62 changes: 62 additions & 0 deletions
62
src/lambda_codebase/account_processing/tests/test_get_default_regions.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| """ | ||
| Tests the account tag configuration lambda | ||
| """ | ||
|
|
||
| import unittest | ||
| import boto3 | ||
| from botocore.stub import Stubber | ||
| from aws_xray_sdk import global_sdk_config | ||
| from ..get_account_regions import ( | ||
| get_default_regions_for_account, | ||
| ) | ||
|
|
||
| global_sdk_config.set_sdk_enabled(False) | ||
|
|
||
| # pylint: disable=W0106 | ||
| class SuccessTestCase(unittest.TestCase): | ||
| @staticmethod | ||
| def test_get_default_regions_for_account(): | ||
| ec2_client = boto3.client("ec2") | ||
| stubber = Stubber(ec2_client) | ||
| stubber.add_response( | ||
| "describe_regions", | ||
| { | ||
| "Regions": [ | ||
| { | ||
| "Endpoint": "blah", | ||
| "RegionName": "us-east-1", | ||
| "OptInStatus": "opt-in-not-required", | ||
| }, | ||
| { | ||
| "Endpoint": "blah", | ||
| "RegionName": "us-east-2", | ||
| "OptInStatus": "opt-in-not-required", | ||
| }, | ||
| { | ||
| "Endpoint": "blah", | ||
| "RegionName": "us-east-3", | ||
| "OptInStatus": "opted-in", | ||
| }, | ||
| { | ||
| "Endpoint": "blah", | ||
| "RegionName": "us-east-4", | ||
| "OptInStatus": "opted-in", | ||
| }, | ||
| ] | ||
| }, | ||
| { | ||
| "AllRegions": False, | ||
| "Filters": [ | ||
| { | ||
| "Values": [ | ||
| "opt-in-not-required", | ||
| "opted-in", | ||
| ], | ||
| "Name": "opt-in-status", | ||
| }, | ||
| ], | ||
| }, | ||
| ), | ||
| stubber.activate() | ||
| regions = get_default_regions_for_account(ec2_client) | ||
| assert regions == ["us-east-1", "us-east-2", "us-east-3", "us-east-4"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.