Skip to content
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

chore(demo) #46

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ override.tf.json
.terraformrc
terraform.rc

.byebug_history
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,28 @@ In addition to the automated tests that run on pull requests and pushes to the `
This allows for more flexibility in testing, especially in scenarios where you might want to test specific changes or configurations without making a pull request or a push.

For more details on GitHub's workflow dispatch event, refer to the [official documentation](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow).

## Developing

```
make docker/run
aws sts get-caller-identity #check your aws credentials
kitchen verify #standup the infrastructure
```

Once the infrastructure is setup we can skip infra setup and run the tests directly
```
rspec test/integration/base/verify/collection_spec.rb #run entire file

rspec test/integration/base/verify/collection_spec.rb:55 # run the test at line 55 (use the `it` line)

rspec test/integration/base/verify/collection_spec.rb -e 'Firehose group' #run the test described as Firhose group
```

Interactive debugger
```
gem install byebug # or equivalent

require byebug
byebug # where you want to pause in the test file
```
51 changes: 27 additions & 24 deletions test/integration/base/verify/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@

# Get all EventBridge rules
events = Aws::CloudWatchEvents::Client.new
eventbridge_rule_found = false
events.list_rules.rules.each do |rule|
# Filter out the ones that match your prefix
if rule.name.start_with?("#{provider}")
eventbridge_rule_found = true

describe 'EventBridge Rule' do
describe 'EventBridge Rules' do
rules = events.list_rules.rules.select { |rule| rule.name.start_with?("#{provider}") }

it 'has at least one rule with the desired prefix' do
expect(rules.size).to be > 0
end

rules.each do |rule|
context "Rule #{rule.name}" do
it 'exists' do
expect(rule).not_to be_nil
end
Expand All @@ -104,24 +107,24 @@
end

# Check if rule targets the correct Lambda function and has correct inputs
# targets = events.list_targets_by_rule({rule: rule.name}).targets
# targets.each do |target|
# if target.arn.include?("function:#{provider}-#{user}")
# it 'has correct input' do
# input_json = JSON.parse(target.input)
# expected_include_array = ["apigateway:Get*", "autoscaling:Describe*", "cloudformation:Describe*", "cloudformation:List*", "cloudfront:List*", "dynamodb:Describe*", "dynamodb:List*", "ec2:Describe*", "ecs:Describe*", "ecs:List*", "eks:Describe*", "eks:List*", "elasticache:Describe*", "elasticbeanstalk:Describe*", "elasticfilesystem:Describe*", "elasticloadbalancing:Describe*", "elasticmapreduce:Describe*", "elasticmapreduce:List*", "events:List*", "firehose:Describe*", "firehose:List*", "iam:Get*", "iam:List*", "kinesis:Describe*", "kinesis:List*", "kms:Describe*", "kms:List*", "lambda:List*", "logs:Describe*", "organizations:Describe*", "organizations:List*", "rds:Describe*", "redshift:Describe*", "route53:List*", "s3:GetBucket*", "s3:List*", "secretsmanager:List*", "sns:Get*", "sns:List*", "sqs:Get*", "sqs:List*", "synthetics:Describe*", "synthetics:List*"]
# expected_include_array.each do |expected_element|
# expect(input_json['snapshot']['include']).to include(expected_element)
# end
# end
# end
# end
end
end
end
targets = events.list_targets_by_rule({ rule: rule.name }).targets

it 'has at least one target' do
expect(targets.size).to be > 0
end

describe 'EventBridge rules' do
it 'has at least one matching rule' do
expect(eventbridge_rule_found).to be true
expected_include_array = ["apigateway:Get*", "autoscaling:Describe*", "cloudformation:Describe*", "cloudformation:List*", "cloudfront:List*", "dynamodb:Describe*", "dynamodb:List*", "ec2:Describe*", "ecs:Describe*", "ecs:List*", "eks:Describe*", "eks:List*", "elasticbeanstalk:Describe*", "elasticache:Describe*", "elasticfilesystem:Describe*", "elasticloadbalancing:Describe*", "elasticmapreduce:Describe*", "elasticmapreduce:List*", "events:List*", "firehose:Describe*", "firehose:List*", "iam:Get*", "iam:List*", "kinesis:Describe*", "kinesis:List*", "kms:Describe*", "kms:List*", "lambda:List*", "logs:Describe*", "organizations:Describe*", "organizations:List*", "rds:Describe*", "redshift:Describe*", "route53:List*", "s3:GetBucket*", "s3:List*", "secretsmanager:List*", "sns:Get*", "sns:List*", "sqs:Get*", "sqs:List*", "synthetics:Describe*", "synthetics:List*"]

targets.each do |target|
if target.arn.include?("function:#{provider}-#{user}")
it 'has correct input' do
input_json = JSON.parse(target.input)
expected_include_array.each do |expected_element|
expect(input_json['snapshot']['include']).to include(expected_element)
end
end
end
end
end
end
end
Loading