Sha256: 2238a13380e94c2f9e278de95c8a0c1ac3aa10634adc0c9ee3559a5c8d1584c4

Contents?: true

Size: 1.93 KB

Versions: 30

Compression:

Stored size: 1.93 KB

Contents

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

  iam = Fog::AWS[:iam]

  tests('#all').succeeds do
    iam.managed_policies.size == 100
  end

  tests('#each').succeeds do
    policies = []

    iam.managed_policies.each { |policy| policies << policy }

    policies.size > 100
  end

  policy = iam.managed_policies.get("arn:aws:iam::aws:policy/IAMReadOnlyAccess")

  tests("#document").succeeds do
    policy.document == {
      "Version"   => "2012-10-17",
      "Statement" => [
        {
          "Effect"   => "Allow",
          "Action"   => [ "iam:GenerateCredentialReport", "iam:GenerateServiceLastAccessedDetails", "iam:Get*", "iam:List*" ],
          "Resource" => "*"
        }
      ]
    }
  end

  tests("users") do
    user = iam.users.create(:id => uniq_id("fog-test-user"))

    tests("#attach").succeeds do
      user.attach(policy)

      user.attached_policies.map(&:identity) == [policy.identity]
    end

    returns(1) { policy.reload.attachments}

    tests("#detach").succeeds do
      user.detach(policy)

      user.attached_policies.map(&:identity) == []
    end

    user.destroy
  end

  tests("groups") do
    group = iam.groups.create(:name => uniq_id("fog-test-group"))

    tests("#attach").succeeds do
      group.attach(policy)

      group.attached_policies.map(&:identity) == [policy.identity]
    end

    returns(1) { policy.reload.attachments}

    tests("#detach").succeeds do
      group.detach(policy)

      group.attached_policies.map(&:identity) == []
    end

    group.destroy
  end

  tests("roles") do
    role = iam.roles.create(:rolename => uniq_id("fog-test-role"))

    tests("#attach").succeeds do
      role.attach(policy)
      role.attached_policies.map(&:identity) == [policy.identity]
    end

    returns(1) { policy.reload.attachments}

    tests("#detach").succeeds do
      role.detach(policy)
      role.attached_policies.map(&:identity) == []
    end

    role.destroy
  end
end

Version data entries

30 entries across 28 versions & 2 rubygems

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