Skip to content

Commit

Permalink
fix JSON compares so they only care about the data
Browse files Browse the repository at this point in the history
  • Loading branch information
pghalliday committed Sep 4, 2015
1 parent 890ee31 commit 68c7ea0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
12 changes: 6 additions & 6 deletions features/configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: JSON configuration data
"""
When I deploy the formatron stack with target <target>
Then the region <region>, AWS access key ID <AWS access key ID> and AWS secret access key <AWS secret access key> should be used when communicating with S3
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and content
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and JSON
"""
{
"formatronRegion": "<region>",
Expand Down Expand Up @@ -75,7 +75,7 @@ Feature: JSON configuration data
"""
When I deploy the formatron stack with target <target>
Then the region <region>, AWS access key ID <AWS access key ID> and AWS secret access key <AWS secret access key> should be used when communicating with S3
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and content
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and JSON
"""
{
"formatronRegion": "<region>",
Expand Down Expand Up @@ -133,7 +133,7 @@ Feature: JSON configuration data
"""
When I deploy the formatron stack with target <target>
Then the region <region>, AWS access key ID <AWS access key ID> and AWS secret access key <AWS secret access key> should be used when communicating with S3
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and content
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and JSON
"""
{
"formatronRegion": "<region>",
Expand All @@ -145,10 +145,10 @@ Feature: JSON configuration data
"formatronOpscodeS3Key": "<target>/<name>/opscode",
"<name>": {
"param1": "<parameter 1>",
"param3": "<parameter 3>",
"subParams": {
"param2": "<parameter 2>"
}
},
"param3": "<parameter 3>"
},
"formatronPrefix": "<prefix>",
"formatronS3Bucket": "<bucket>",
Expand Down Expand Up @@ -200,7 +200,7 @@ Feature: JSON configuration data
"""
When I deploy the formatron stack with target <test target>
Then the region <region>, AWS access key ID <AWS access key ID> and AWS secret access key <AWS secret access key> should be used when communicating with S3
And the config should be uploaded to S3 bucket <bucket> with key <test target>/<name>/config.json, KMS key <KMS key> and content
And the config should be uploaded to S3 bucket <bucket> with key <test target>/<name>/config.json, KMS key <KMS key> and JSON
"""
{
"formatronRegion": "<region>",
Expand Down
2 changes: 1 addition & 1 deletion features/dependency.feature
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Feature: Formatron stacks can depend on other Formatron stacks
And dependency configuration should be downloaded from S3 bucket <bucket> with key <target>/<dependency 1>/config.json
And dependency configuration should be downloaded from S3 bucket <bucket> with key <target>/<dependency 2>/config.json
And dependency CloudFormation outputs should be loaded from CloudFormation stack <prefix>-<dependency 2>-<target>
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and content
And the config should be uploaded to S3 bucket <bucket> with key <target>/<name>/config.json, KMS key <KMS key> and JSON
"""
{
"formatronRegion": "<region>",
Expand Down
25 changes: 15 additions & 10 deletions features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Given(/^a Formatron project$/) do
@fp = FormatronProject.new
@deps = {}
@s3_puts = {}
end

Given(/^an? ([^\s]+) file with content$/) do |relative_path, content|
Expand Down Expand Up @@ -34,7 +35,9 @@
When(/^I deploy the formatron stack with target (\w+)$/) do |target|
@credentials = double
@s3_client = double
allow(@s3_client).to receive(:put_object)
allow(@s3_client).to receive(:put_object) do |params|
@s3_puts[params[:key]] = params[:body]
end
allow(@s3_client).to receive(:get_object) do |params|
dependency = %r{^#{target}/([^/]+)/config.json$}.match(params[:key])[1]
S3GetObjectResponse.new @deps[dependency].configuration
Expand All @@ -46,7 +49,6 @@
CloudformationDescribeStacksResponse.new @deps[dependency].outputs
end
allow(@cloudformation).to receive(:create_stack) do
puts Aws::CloudFormation::Errors::AlreadyExistsException
fail(
Aws::CloudFormation::Errors::AlreadyExistsException.new(
'context',
Expand Down Expand Up @@ -136,15 +138,18 @@
the[ ]config[ ]should[ ]be[ ]uploaded[ ]to[ ]S3[ ]bucket[ ](\w+)[ ]
with[ ]key[ ]([^\s,]+),[ ]
KMS[ ]key[ ](\w+)[ ]
and[ ]content
$/x) do |bucket, key, kms_key, content|
expect(@s3_client).to have_received(:put_object).once.with(
bucket: bucket,
key: key,
body: content.to_s,
server_side_encryption: 'aws:kms',
ssekms_key_id: kms_key
and[ ]JSON
$/x) do |bucket, key, kms_key, json|
@s3_client.should have_received(:put_object).once.with(
hash_including(
bucket: bucket,
key: key,
server_side_encryption: 'aws:kms',
ssekms_key_id: kms_key
)
)
config = JSON.parse(json)
JSON.parse(@s3_puts[key]).should eq(config)
end

Then(/^
Expand Down

0 comments on commit 68c7ea0

Please sign in to comment.