forked from theonestack/hl-component-s3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c990585
commit 1b92964
Showing
5 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,39 @@ | ||
require 'yaml' | ||
|
||
describe 'compiled component s3' do | ||
|
||
context 'cftest' do | ||
it 'compiles test' do | ||
expect(system("cfhighlander cftest #{@validate} --tests tests/website_redirect_to_another_bucket.test.yaml")).to be_truthy | ||
end | ||
end | ||
|
||
let(:template) { YAML.load_file("#{File.dirname(__FILE__)}/../out/tests/website_redirect_to_another_bucket/s3.compiled.yaml") } | ||
|
||
context "Resource" do | ||
|
||
|
||
context "Normalbucket" do | ||
let(:resource) { template["Resources"]["Normalbucket"] } | ||
|
||
it "is of type AWS::S3::Bucket" do | ||
expect(resource["Type"]).to eq("AWS::S3::Bucket") | ||
end | ||
|
||
it "to have property BucketName" do | ||
expect(resource["Properties"]["BucketName"]).to eq({"Fn::Sub"=>"normal-bucket"}) | ||
end | ||
|
||
it "to have property Tags" do | ||
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-normal-bucket"}}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}]) | ||
end | ||
|
||
it "to have property WebsiteConfiguration" do | ||
expect(resource["Properties"]["WebsiteConfiguration"]).to eq({"RedirectAllRequestsTo"=>{"HostName"=>"testbucket", "Protocol"=>"http"}}) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains 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,39 @@ | ||
require 'yaml' | ||
|
||
describe 'compiled component s3' do | ||
|
||
context 'cftest' do | ||
it 'compiles test' do | ||
expect(system("cfhighlander cftest #{@validate} --tests tests/website.test.yaml")).to be_truthy | ||
end | ||
end | ||
|
||
let(:template) { YAML.load_file("#{File.dirname(__FILE__)}/../out/tests/website/s3.compiled.yaml") } | ||
|
||
context "Resource" do | ||
|
||
|
||
context "Normalbucket" do | ||
let(:resource) { template["Resources"]["Normalbucket"] } | ||
|
||
it "is of type AWS::S3::Bucket" do | ||
expect(resource["Type"]).to eq("AWS::S3::Bucket") | ||
end | ||
|
||
it "to have property BucketName" do | ||
expect(resource["Properties"]["BucketName"]).to eq({"Fn::Sub"=>"normal-bucket"}) | ||
end | ||
|
||
it "to have property Tags" do | ||
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-normal-bucket"}}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}]) | ||
end | ||
|
||
it "to have property WebsiteConfiguration" do | ||
expect(resource["Properties"]["WebsiteConfiguration"]).to eq({"ErrorDocument"=>"error.html", "IndexDocument"=>"index.html", "RoutingRules"=>[{"RedirectRule"=>{"HostName"=>"test1", "HttpRedirectCode"=>"301", "Protocol"=>"http", "ReplaceKeyWith"=>"test1"}, "RoutingRuleCondition"=>{"HttpErrorCodeReturnedEquals"=>"400", "KeyPrefixEquals"=>"test1"}}, {"RedirectRule"=>{"ReplaceKeyPrefixWith"=>"documents/"}, "RoutingRuleCondition"=>{"KeyPrefixEquals"=>"docs/"}}]}) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains 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,26 @@ | ||
test_metadata: | ||
type: config | ||
name: website | ||
description: s3 website with multiple routing rules | ||
|
||
# Insert your tests here | ||
buckets: | ||
normal-bucket: | ||
type: default | ||
website: | ||
redirect_requests: false | ||
error_document: error.html | ||
index_document: index.html | ||
routing_rules: | ||
- redirect_rule: | ||
hostname: "test1" | ||
http_redirect_code: "301" | ||
protocol: "http" | ||
replace_key_with: "test1" | ||
routing_rule_condition: | ||
http_error_code_returned_equals: "400" | ||
key_prefix_equals: "test1" | ||
- redirect_rule: | ||
replace_key_prefix_with: "documents/" | ||
routing_rule_condition: | ||
key_prefix_equals: "docs/" |
This file contains 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,13 @@ | ||
test_metadata: | ||
type: config | ||
name: website_redirect_to_another_bucket | ||
description: s3 website that redirects to another s3 bucket | ||
|
||
# Insert your tests here | ||
buckets: | ||
normal-bucket: | ||
type: default | ||
website: | ||
redirect_requests: true | ||
redirect_hostname: "testbucket" | ||
redirect_protocol: "http" |