|
1 | | -require 'spec_helper_acceptance' |
2 | | -require 'securerandom' |
3 | | - |
4 | | -describe 'iam_instance_profile' do |
5 | | - before(:all) do |
6 | | - @default_region = 'us-east-1' |
7 | | - @aws = AwsHelper.new(@default_region) |
8 | | - @template = 'iam_instance_profile.pp.tmpl' |
9 | | - end |
10 | | - |
11 | | - def get_role(name) |
12 | | - roles = @aws.get_iam_roles(name) |
13 | | - expect(roles.count).to eq(1) |
14 | | - roles.first |
15 | | - end |
16 | | - |
17 | | - def get_instance_profile(name) |
18 | | - instance_profiles = @aws.get_iam_instance_profiles(name) |
19 | | - expect(instance_profiles.count).to eq(1) |
20 | | - instance_profiles.first |
21 | | - end |
22 | | - |
23 | | - describe 'managing as puppet resource' do |
24 | | - before :all do |
25 | | - @name = "#{SecureRandom.uuid}" |
26 | | - |
27 | | - @config = { |
28 | | - :role_name => @name, |
29 | | - :profile_name => @name, |
30 | | - :path_prefix => "/#{SecureRandom.hex(8)}/", |
31 | | - :ensure => 'present', |
32 | | - } |
33 | | - end |
34 | | - |
35 | | - it "should create properly with only defaults" do |
36 | | - profile_options = { :name => @config[:profile_name], :path => @config[:path_prefix], :ensure => @config[:ensure] } |
37 | | - result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/') |
38 | | - expect(result.stderr).not_to match(/Error:/) |
39 | | - end |
40 | | - |
41 | | - it "should have the specified name" do |
42 | | - profile = get_instance_profile(@config[:profile_name]) |
43 | | - expect(profile.instance_profile_name).to eq(@config[:profile_name]) |
44 | | - end |
45 | | - |
46 | | - it "should have a valid ARN" do |
47 | | - profile = get_instance_profile(@config[:profile_name]) |
48 | | - expect(profile.arn).to match(/^arn\:aws\:iam\:\:\d+\:\S+$/) |
49 | | - expect(profile.arn).to include("#{@config[:path]}#{@config[:profile_name]}") |
50 | | - end |
51 | | - |
52 | | - it "should accept a role assignment after the fact" do |
53 | | - role_options = { :name => @config[:role_name], :path => @config[:path_prefix], :ensure => @config[:ensure] } |
54 | | - result = TestExecutor.puppet_resource('iam_role', role_options, '--modulepath spec/fixtures/modules/ --trace') |
55 | | - expect(result.stderr).not_to match(/Error:/) |
56 | | - |
57 | | - profile_options = { :name => @config[:profile_name], :path => @config[:path_prefix], :ensure => @config[:ensure], :roles => @config[:role_name] } |
58 | | - result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/ --trace') |
59 | | - expect(result.stderr).not_to match(/Error:/) |
60 | | - end |
61 | | - |
62 | | - it "should accept policy attachment" do |
63 | | - policy_options = { :name => 'IAMFullAccess', :roles => @config[:role_name] } |
64 | | - result = TestExecutor.puppet_resource('iam_policy_attachment', policy_options, '--modulepath spec/fixtures/modules/ --trace') |
65 | | - expect(result.stderr).not_to match(/Error:/) |
66 | | - end |
67 | | - |
68 | | - it "should destroy and cleanup properly" do |
69 | | - new_config = @config.update({:ensure => 'absent'}) |
70 | | - |
71 | | - role_options = { :name => new_config[:role_name], :path => @config[:path_prefix], :ensure => new_config[:ensure] } |
72 | | - result = TestExecutor.puppet_resource('iam_role', role_options, '--modulepath spec/fixtures/modules/ --trace') |
73 | | - expect(result.stderr).not_to match(/Error:/) |
74 | | - |
75 | | - profile_options = { :name => new_config[:profile_name], :path => @config[:path_prefix], :ensure => new_config[:ensure] } |
76 | | - result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/ --trace') |
77 | | - expect(result.stderr).not_to match(/Error:/) |
78 | | - end |
79 | | - |
80 | | - end |
81 | | - |
82 | | - describe 'managing via puppet manifest apply' do |
83 | | - |
84 | | - before (:all) do |
85 | | - @name = "#{SecureRandom.uuid}" |
86 | | - @path_prefix = "/#{SecureRandom.hex(8)}/" |
87 | | - @role_policy_json = <<-'JSON' |
88 | | - { |
89 | | - "Version": "2012-10-17", |
90 | | - "Statement": [ |
91 | | - { |
92 | | - "Effect": "Allow", |
93 | | - "Principal": { |
94 | | - "Service": "ec2.amazonaws.com" |
95 | | - }, |
96 | | - "Action": "sts:AssumeRole" |
97 | | - } |
98 | | - ] |
99 | | - } |
100 | | - JSON |
101 | | - |
102 | | - @config = { |
103 | | - :role_name => @name, |
104 | | - :profile_name => @name, |
105 | | - :path => @path_prefix, |
106 | | - :role_policy_document => @role_policy_json.strip.gsub(/\r\n?/, " "), |
107 | | - :ensure => 'present', |
108 | | - } |
109 | | - end |
110 | | - |
111 | | - it "should compile and apply" do |
112 | | - result = PuppetManifest.new(@template, @config).apply |
113 | | - expect(result.stderr).not_to match(/Error:/) |
114 | | - end |
115 | | - |
116 | | - it "with the specified name" do |
117 | | - profile = get_instance_profile(@config[:profile_name]) |
118 | | - expect(profile.instance_profile_name).to eq(@config[:profile_name]) |
119 | | - end |
120 | | - |
121 | | - it "should have valid ARN" do |
122 | | - profile = get_instance_profile(@config[:profile_name]) |
123 | | - expect(profile.arn).to match(/^arn\:aws\:iam\:\:\d+\:\S+$/) |
124 | | - expect(profile.arn).to include("#{@config[:path]}#{@config[:profile_name]}") |
125 | | - end |
126 | | - |
127 | | - it "should cleanup properly" do |
128 | | - new_config = @config.update({:ensure => 'absent'}) |
129 | | - result = PuppetManifest.new(@template, new_config).apply |
130 | | - expect(result.stderr).not_to match(/Error:/) |
131 | | - end |
132 | | - end |
133 | | - |
134 | | -end |
| 1 | +#require 'spec_helper_acceptance' |
| 2 | +#require 'securerandom' |
| 3 | +# |
| 4 | +#describe 'iam_instance_profile' do |
| 5 | +# before(:all) do |
| 6 | +# @default_region = 'us-east-1' |
| 7 | +# @aws = AwsHelper.new(@default_region) |
| 8 | +# @template = 'iam_instance_profile.pp.tmpl' |
| 9 | +# end |
| 10 | +# |
| 11 | +# def get_role(name) |
| 12 | +# roles = @aws.get_iam_roles(name) |
| 13 | +# expect(roles.count).to eq(1) |
| 14 | +# roles.first |
| 15 | +# end |
| 16 | +# |
| 17 | +# def get_instance_profile(name) |
| 18 | +# instance_profiles = @aws.get_iam_instance_profiles(name) |
| 19 | +# expect(instance_profiles.count).to eq(1) |
| 20 | +# instance_profiles.first |
| 21 | +# end |
| 22 | +# |
| 23 | +# describe 'managing as puppet resource' do |
| 24 | +# before :all do |
| 25 | +# @name = "#{SecureRandom.uuid}" |
| 26 | +# |
| 27 | +# @config = { |
| 28 | +# :role_name => @name, |
| 29 | +# :profile_name => @name, |
| 30 | +# :path_prefix => "/#{SecureRandom.hex(8)}/", |
| 31 | +# :ensure => 'present', |
| 32 | +# } |
| 33 | +# end |
| 34 | +# |
| 35 | +# it "should create properly with only defaults" do |
| 36 | +# profile_options = { :name => @config[:profile_name], :path => @config[:path_prefix], :ensure => @config[:ensure] } |
| 37 | +# result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/') |
| 38 | +# expect(result.stderr).not_to match(/Error:/) |
| 39 | +# end |
| 40 | +# |
| 41 | +# it "should have the specified name" do |
| 42 | +# profile = get_instance_profile(@config[:profile_name]) |
| 43 | +# expect(profile.instance_profile_name).to eq(@config[:profile_name]) |
| 44 | +# end |
| 45 | +# |
| 46 | +# it "should have a valid ARN" do |
| 47 | +# profile = get_instance_profile(@config[:profile_name]) |
| 48 | +# expect(profile.arn).to match(/^arn\:aws\:iam\:\:\d+\:\S+$/) |
| 49 | +# expect(profile.arn).to include("#{@config[:path]}#{@config[:profile_name]}") |
| 50 | +# end |
| 51 | +# |
| 52 | +# it "should accept a role assignment after the fact" do |
| 53 | +# role_options = { :name => @config[:role_name], :path => @config[:path_prefix], :ensure => @config[:ensure] } |
| 54 | +# result = TestExecutor.puppet_resource('iam_role', role_options, '--modulepath spec/fixtures/modules/ --trace') |
| 55 | +# expect(result.stderr).not_to match(/Error:/) |
| 56 | +# |
| 57 | +# profile_options = { :name => @config[:profile_name], :path => @config[:path_prefix], :ensure => @config[:ensure], :roles => @config[:role_name] } |
| 58 | +# result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/ --trace') |
| 59 | +# expect(result.stderr).not_to match(/Error:/) |
| 60 | +# end |
| 61 | +# |
| 62 | +# it "should accept policy attachment" do |
| 63 | +# policy_options = { :name => 'IAMFullAccess', :roles => @config[:role_name] } |
| 64 | +# result = TestExecutor.puppet_resource('iam_policy_attachment', policy_options, '--modulepath spec/fixtures/modules/ --trace') |
| 65 | +# expect(result.stderr).not_to match(/Error:/) |
| 66 | +# end |
| 67 | +# |
| 68 | +# it "should destroy and cleanup properly" do |
| 69 | +# new_config = @config.update({:ensure => 'absent'}) |
| 70 | +# |
| 71 | +# role_options = { :name => new_config[:role_name], :path => @config[:path_prefix], :ensure => new_config[:ensure] } |
| 72 | +# result = TestExecutor.puppet_resource('iam_role', role_options, '--modulepath spec/fixtures/modules/ --trace') |
| 73 | +# expect(result.stderr).not_to match(/Error:/) |
| 74 | +# |
| 75 | +# profile_options = { :name => new_config[:profile_name], :path => @config[:path_prefix], :ensure => new_config[:ensure] } |
| 76 | +# result = TestExecutor.puppet_resource('iam_instance_profile', profile_options, '--modulepath spec/fixtures/modules/ --trace') |
| 77 | +# expect(result.stderr).not_to match(/Error:/) |
| 78 | +# end |
| 79 | +# |
| 80 | +# end |
| 81 | +# |
| 82 | +# describe 'managing via puppet manifest apply' do |
| 83 | +# |
| 84 | +# before (:all) do |
| 85 | +# @name = "#{SecureRandom.uuid}" |
| 86 | +# @path_prefix = "/#{SecureRandom.hex(8)}/" |
| 87 | +# @role_policy_json = <<-'JSON' |
| 88 | +# { |
| 89 | +# "Version": "2012-10-17", |
| 90 | +# "Statement": [ |
| 91 | +# { |
| 92 | +# "Effect": "Allow", |
| 93 | +# "Principal": { |
| 94 | +# "Service": "ec2.amazonaws.com" |
| 95 | +# }, |
| 96 | +# "Action": "sts:AssumeRole" |
| 97 | +# } |
| 98 | +# ] |
| 99 | +# } |
| 100 | +# JSON |
| 101 | +# |
| 102 | +# @config = { |
| 103 | +# :role_name => @name, |
| 104 | +# :profile_name => @name, |
| 105 | +# :path => @path_prefix, |
| 106 | +# :role_policy_document => @role_policy_json.strip.gsub(/\r\n?/, " "), |
| 107 | +# :ensure => 'present', |
| 108 | +# } |
| 109 | +# end |
| 110 | +# |
| 111 | +# it "should compile and apply" do |
| 112 | +# result = PuppetManifest.new(@template, @config).apply |
| 113 | +# expect(result.stderr).not_to match(/Error:/) |
| 114 | +# end |
| 115 | +# |
| 116 | +# it "with the specified name" do |
| 117 | +# profile = get_instance_profile(@config[:profile_name]) |
| 118 | +# expect(profile.instance_profile_name).to eq(@config[:profile_name]) |
| 119 | +# end |
| 120 | +# |
| 121 | +# it "should have valid ARN" do |
| 122 | +# profile = get_instance_profile(@config[:profile_name]) |
| 123 | +# expect(profile.arn).to match(/^arn\:aws\:iam\:\:\d+\:\S+$/) |
| 124 | +# expect(profile.arn).to include("#{@config[:path]}#{@config[:profile_name]}") |
| 125 | +# end |
| 126 | +# |
| 127 | +# it "should cleanup properly" do |
| 128 | +# new_config = @config.update({:ensure => 'absent'}) |
| 129 | +# result = PuppetManifest.new(@template, new_config).apply |
| 130 | +# expect(result.stderr).not_to match(/Error:/) |
| 131 | +# end |
| 132 | +# end |
| 133 | +# |
| 134 | +#end |
0 commit comments