Sha256: 9d583a8c64c632094331b9deee021bab5c133179a756c69754caaf5962f90eff

Contents?: true

Size: 1.5 KB

Versions: 75

Compression:

Stored size: 1.5 KB

Contents

Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do

  Fog.mock!
  iam = Fog::AWS[:iam]
  
  @username = 'fake_user'
  @user = iam.users.create(:id => @username)
  @policy_document = {"Statement"=>[{"Action"=>["sqs:*"], "Effect"=>"Allow", "Resource"=>"*"}]}
  @policy_name = 'fake-sqs-policy'
  
  tests('#all', 'there is no policies').succeeds do
    @user.policies.empty?
  end
  
  tests('#create') do 
    tests('a valid policy').succeeds do
      policy = @user.policies.create(:id => @policy_name, :document => @policy_document)
      policy.id == @policy_name
      policy.username == @username
      policy.document == @policy_document
    end
    
    # The mocking doesn't validate the document policy
    #tests('an invalid valid policy').succeeds do
    #  raises(Fog::AWS::IAM::Error) { @user.policies.create(id: 'non-valid-document', document: 'invalid json blob') }
    #end
  end
  
  @user.policies.create(:id => 'another-policy', :document => {})
  
  tests('#all','there are two policies').succeeds do
    @user.policies.size == 2
  end
  
  tests('#get') do
    tests('a valid policy').succeeds do
      policy = @user.policies.get(@policy_name)
      policy.id == @polic_name
      policy.username == @username
      policy.document == @policy_document   
    end
    
    tests('an invalid policy').succeeds do
      @user.policies.get('non-existing') == nil
    end
  end
  
  tests('#destroy').succeeds do
    @user.policies.get(@policy_name).destroy
  end
  
  # clean up
  @user.destroy

  
end

Version data entries

75 entries across 75 versions & 10 rubygems

Version Path
fog-maestrodev-1.15.0.20130927082724 tests/aws/models/iam/policies_tests.rb
fog-maestrodev-1.15.0.20130829165835 tests/aws/models/iam/policies_tests.rb
fog-1.15.0 tests/aws/models/iam/policies_tests.rb
gapinc-fog-1.14.0 tests/aws/models/iam/policies_tests.rb
fog-maestrodev-1.14.0.20130806165225 tests/aws/models/iam/policies_tests.rb
fog-1.14.0 tests/aws/models/iam/policies_tests.rb
fog-1.13.0 tests/aws/models/iam/policies_tests.rb
gapinc-fog-1.12.1.2 tests/aws/models/iam/policies_tests.rb
gapinc-fog-1.12.1.1 tests/aws/models/iam/policies_tests.rb
gapinc-fog-1.12.1a tests/aws/models/iam/policies_tests.rb
gapinc-fog-1.12.1 tests/aws/models/iam/policies_tests.rb
fog-1.12.1 tests/aws/models/iam/policies_tests.rb
fog-1.12.0 tests/aws/models/iam/policies_tests.rb
hpfog-0.0.20 tests/aws/models/iam/policies_tests.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/tests/aws/models/iam/policies_tests.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/tests/aws/models/iam/policies_tests.rb
fog-nirvanix-1.8.2 tests/aws/models/iam/policies_tests.rb
fog-1.11.1 tests/aws/models/iam/policies_tests.rb
fog-1.11.0 tests/aws/models/iam/policies_tests.rb
fog-nirvanix-1.8.1 tests/aws/models/iam/policies_tests.rb