Sha256: 3f7a6f4b6741d4537a8ee84b9d29587a046817b6c0f659e8e0b715a4b55bb456

Contents?: true

Size: 1.52 KB

Versions: 65

Compression:

Stored size: 1.52 KB

Contents

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

  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.access_keys.map(&:destroy)
  @user.policies.map(&:destroy)
  @user.destroy


end

Version data entries

65 entries across 63 versions & 4 rubygems

Version Path
fog-aws-3.12.0 tests/models/iam/policies_tests.rb
fog-aws-3.11.0 tests/models/iam/policies_tests.rb
fog-aws-3.10.0 tests/models/iam/policies_tests.rb
fog-aws-3.9.0 tests/models/iam/policies_tests.rb
fog-aws-3.8.0 tests/models/iam/policies_tests.rb
fog-aws-3.7.0 tests/models/iam/policies_tests.rb
fog-aws-3.6.7 tests/models/iam/policies_tests.rb
fog-aws-3.6.6 tests/models/iam/policies_tests.rb
fog-aws-3.6.5 tests/models/iam/policies_tests.rb
fog-aws-3.6.4 tests/models/iam/policies_tests.rb
fog-aws-3.6.3 tests/models/iam/policies_tests.rb
fog-aws-3.6.2 tests/models/iam/policies_tests.rb
fog-aws-3.5.2 tests/models/iam/policies_tests.rb
fog-aws-3.5.1 tests/models/iam/policies_tests.rb
fog-aws-3.5.0 tests/models/iam/policies_tests.rb
fog-aws-3.4.0 tests/models/iam/policies_tests.rb
fog-aws-3.3.0 tests/models/iam/policies_tests.rb
fog-aws-3.2.0 tests/models/iam/policies_tests.rb
fog-aws-3.1.0 tests/models/iam/policies_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/tests/models/iam/policies_tests.rb