-
Notifications
You must be signed in to change notification settings - Fork 103
soumyo/aws_hosted_zone_all_record_issue_fix #811
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 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e559441
issue fix
soumyo13 44130ab
fixed the unit tests
soumyo13 9c3474e
Update docs/resources/aws_hosted_zones.md
soumyo13 dcb1c1f
Update docs/resources/aws_hosted_zones.md
soumyo13 694002d
Update docs/resources/aws_hosted_zones.md
soumyo13 f6219e8
Update docs/resources/aws_hosted_zones.md
soumyo13 27a0e67
resolved conflicts
soumyo13 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 |
|---|---|---|
|
|
@@ -2,38 +2,46 @@ | |
|
|
||
| require 'aws_backend' | ||
|
|
||
| class AwsHostedZones < AwsResourceBase | ||
| class AWSHostedZones < AwsResourceBase | ||
| name 'aws_hosted_zones' | ||
| desc 'Verifies hosted zones settings are correct.' | ||
| desc 'Retrieves a list of the public and private hosted zones that are associated with the current Amazon Web Services account.' | ||
|
|
||
| example " | ||
| describe aws_hosted_zones() do | ||
| describe aws_hosted_zones do | ||
| it { should exist } | ||
| its ('name') { should include ('carry-on.films.com'))} | ||
| end | ||
| " | ||
| attr_reader :table | ||
|
|
||
| FilterTable.create | ||
| .register_column(:name, field: :name) | ||
| .register_column(:id, field: :id) | ||
| .install_filter_methods_on_resource(self, :table) | ||
| attr_reader :table | ||
|
|
||
| def initialize(opts = {}) | ||
| super(opts) | ||
| validate_parameters | ||
| zones = [] | ||
| catch_aws_errors do | ||
| resp [email protected]_client.list_hosted_zones | ||
| @table = fetch_data | ||
| end | ||
|
|
||
| resp.hosted_zones.each do |zone| | ||
| zones += [{ | ||
| name: zone.name, | ||
| id: zone.id, | ||
| }] | ||
| end | ||
| end | ||
| FilterTable.create | ||
| .register_column(:ids, field: :id) | ||
| .register_column(:names, field: :name) | ||
| .register_column(:caller_references, field: :caller_reference) | ||
| .register_column(:configs, field: :config) | ||
| .register_column(:resource_record_set_counts, field: :resource_record_set_count) | ||
| .register_column(:linked_services, field: :linked_service) | ||
| .install_filter_methods_on_resource(self, :table) | ||
|
|
||
| @table = zones | ||
| def fetch_data | ||
| catch_aws_errors do | ||
| @resp = @aws.route53_client.list_hosted_zones.map do |table| | ||
| table.hosted_zones.map { |table_name| { | ||
| id: table_name.id, | ||
| name: table_name.name, | ||
| caller_reference: table_name.caller_reference, | ||
| config: table_name.config, | ||
| resource_record_set_count: table_name.resource_record_set_count, | ||
| linked_service: table_name.linked_service, | ||
| } | ||
| } | ||
| end.flatten | ||
| end | ||
| end | ||
| end | ||
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,12 +1,22 @@ | ||
| hosted_zone_name = attribute(:aws_route_53_zone) | ||
| aws_route53_zone_id = attribute(aws_route53_zone_id, value: '', description: '') | ||
| aws_route53_zone_name = attribute(aws_route53_zone_name, value: '', description: '') | ||
|
|
||
| control "Hosted zones tests" do | ||
| impact 1.0 | ||
| title "Hosted zones" | ||
| desc "Check hosted zones work" | ||
| title 'Ensure the hosted zone have the correct properties.' | ||
|
|
||
| describe aws_hosted_zones() do | ||
| control 'aws-hosted-zones-1.0' do | ||
| impact 1.0 | ||
|
|
||
| describe aws_hosted_zones do | ||
| it { should exist } | ||
| its ('name') { should include ("#{hosted_zone_name}.")} | ||
| its('count') { should >= 1 } | ||
| end | ||
|
|
||
| describe aws_hosted_zones do | ||
| its('ids') { should include aws_route53_zone_id } | ||
| its('names') { should include aws_route53_zone_name } | ||
| its('caller_references') { should_not be_empty } | ||
| its('configs') { should_not be_empty } | ||
| its('resource_record_set_counts') { should_not include 1 } | ||
| its('linked_services') { should_not be_empty } | ||
| end | ||
| end |
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,36 +1,39 @@ | ||
| require 'aws-sdk-core' | ||
| require 'helper' | ||
| require 'aws_hosted_zones' | ||
| require 'aws-sdk-core' | ||
|
|
||
| class AwsHostedZonesTests < Minitest::Test | ||
| class AWSHostedZonesConstructorTest < Minitest::Test | ||
|
|
||
| def test_fail_constructor_values | ||
| assert_raises(ArgumentError) { AwsHostedZones.new('not needed') } | ||
| def test_rejects_unrecognized_params | ||
| assert_raises(ArgumentError) { AWSHostedZones.new(unexpected: 9) } | ||
| end | ||
|
|
||
| end | ||
|
|
||
| class AWSHostedZonesSuccessPathTest < Minitest::Test | ||
|
|
||
| def setup | ||
| zones_call = {} | ||
| zones_call[:method] = :list_hosted_zones | ||
| zones_call[:data] = { hosted_zones: | ||
| [{name: "carry-on.films.com", id: "some_random_id", caller_reference: "reference"}], | ||
| marker: "nil", is_truncated: false, next_marker: "nil", max_items: 100} | ||
| zones_call[:client] = Aws::Route53::Client | ||
|
|
||
| @zones = AwsHostedZones.new(client_args: { stub_responses: true }, stub_data: [zones_call]) | ||
| mock_data = {} | ||
| mock_data[:method] = :list_hosted_zones | ||
| mock_data[:data] = { hosted_zones: | ||
| [{name: "test1", id: "test1", caller_reference: "test1"}], | ||
| marker: "nil", is_truncated: false, next_marker: "nil", max_items: 100} | ||
| mock_data[:client] = Aws::Route53::Client | ||
| @resp = AWSHostedZones.new(client_args: { stub_responses: true }, stub_data: [mock_data]) | ||
| end | ||
|
|
||
| def test_exists_works | ||
| assert @zones.exist? | ||
| def test_hosted_zones_exists | ||
| assert @resp.exist? | ||
| end | ||
|
|
||
| def test_includes_finds | ||
| assert @zones.name.include?("carry-on.films.com") | ||
| def ids | ||
| assert_equal(@resp.ids, ['test1']) | ||
| end | ||
|
|
||
| def test_count_correct | ||
| assert_equal(@zones.name.count, 1) | ||
| def names | ||
| assert_equal(@resp.names, ['test1']) | ||
| end | ||
|
|
||
| def test_not_included | ||
| refute @zones.name.include?("fast.films.com") | ||
| def caller_references | ||
| assert_equal(@resp.caller_references, ['test1']) | ||
| end | ||
| end | ||
| end |
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.