spec/cli_spec.rb in socialcast-1.0.6 vs spec/cli_spec.rb in socialcast-1.0.7

- old
+ new

@@ -62,11 +62,33 @@ end it 'sets account-type to external' do @result.should =~ %r{<account-type>external</account-type>} end end + context 'with multiple possible external group member' do + before do + @entry = Net::LDAP::Entry.new("dc=example,dc=com") + @entry[:mail] = 'ryan@example.com' + @entry[:isMemberOf] = 'cn=Contractor,dc=example,dc=com' + Net::LDAP.any_instance.stub(:search).and_yield(@entry) + + @result = '' + Zlib::GzipWriter.stub(:open).and_yield(@result) + File.stub(:open).with(/ldap.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_with_array_permission_mapping.yml'))) + File.stub(:open).with(/users.xml.gz/, anything).and_yield(@result) + File.stub(:open).with(/credentials.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml'))) + + RestClient::Resource.any_instance.stub(:post) + + Socialcast::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml'] + end + it 'sets account-type to external' do + @result.should =~ %r{<account-type>external</account-type>} + end + end + context 'with tenant_admin group member' do before do @entry = Net::LDAP::Entry.new("dc=example,dc=com") @entry[:mail] = 'ryan@example.com' @entry[:isMemberOf] = 'cn=Admins,dc=example,dc=com' @@ -86,9 +108,59 @@ it 'sets account-type to member' do @result.should =~ %r{<account-type>member</account-type>} end it 'adds tenant_admin role' do @result.should =~ %r{<role>tenant_admin</role>} + end + end + context 'entry isMemberOf Marketing group' do + before do + @entry = Net::LDAP::Entry.new("dc=example,dc=com") + @entry[:mail] = 'ryan@example.com' + @entry[:isMemberOf] = 'cn=Marketing,dc=example,dc=com' + + Net::LDAP.any_instance.stub(:search).and_yield(@entry) + + @result = '' + Zlib::GzipWriter.stub(:open).and_yield(@result) + File.stub(:open).with(/ldap.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_with_array_permission_mapping.yml'))) + File.stub(:open).with(/users.xml.gz/, anything).and_yield(@result) + File.stub(:open).with(/credentials.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml'))) + + RestClient::Resource.any_instance.stub(:post) + + Socialcast::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml'] + end + it 'sets account-type to member' do + @result.should =~ %r{<account-type>member</account-type>} + end + it 'adds sbi_admin role' do + @result.should =~ %r{<role>sbi_admin</role>} + end + end + context 'entry isMemberOf Engineering group' do + before do + @entry = Net::LDAP::Entry.new("dc=example,dc=com") + @entry[:mail] = 'ryan@example.com' + @entry[:isMemberOf] = 'cn=Engineering,dc=example,dc=com' + + Net::LDAP.any_instance.stub(:search).and_yield(@entry) + + @result = '' + Zlib::GzipWriter.stub(:open).and_yield(@result) + File.stub(:open).with(/ldap.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_with_array_permission_mapping.yml'))) + File.stub(:open).with(/users.xml.gz/, anything).and_yield(@result) + File.stub(:open).with(/credentials.yml/).and_yield(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml'))) + + RestClient::Resource.any_instance.stub(:post) + + Socialcast::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml'] + end + it 'sets account-type to member' do + @result.should =~ %r{<account-type>member</account-type>} + end + it 'adds sbi_admin role' do + @result.should =~ %r{<role>sbi_admin</role>} end end end end