Sha256: 1d573b577f5a195b6eb36fd2d53395a9b88cf798131905dd9893b3439d18baab

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

Shindo.tests('Fog::Rackspace::Identity | tokens', ['rackspace']) do
  ROLE_FORMAT = {
    'id' => String,
    'name' => String,
    'description' => String
  }

  ENDPOINT_FORMAT = {
    'tenantId' => String,
    'publicURL' => Fog::Nullable::String,
    'internalURL' => Fog::Nullable::String,
    'region' => Fog::Nullable::String,
    'versionId' => Fog::Nullable::String,
    'versionInfo' => Fog::Nullable::String,
    'versionList' => Fog::Nullable::String
  }

  SERVICE_FORMAT = {
    'name' => String,
    'type' => String,
    'endpoints' => [ENDPOINT_FORMAT]
  }

  ACCESS_FORMAT = {
    'access' => {
      'token' => {
        'id' => String,
        'expires' => String,
        'tenant' => {
          'id' => String,
          'name' => String
        }
      },
      'user' => {
        'id' => String,
        'name' => String,
        'roles' => [ROLE_FORMAT]
      },
      'serviceCatalog' => [SERVICE_FORMAT]
    }
  }

  service = Fog::Rackspace::Identity.new

  tests('success') do
    credentials = Fog.credentials
    username = credentials[:rackspace_username]
    api_key = credentials[:rackspace_api_key]

    tests('#create_token').formats(ACCESS_FORMAT) do
      service.create_token(username, api_key).body
    end

    tests('uses connection options').returns(true) do
      pending if Fog.mocking?
      identity_service = Fog::Rackspace::Identity.new(:connection_options => { :ssl_verify_peer => true })

      connection = identity_service.instance_variable_get("@connection")
      excon = connection.instance_variable_get("@excon")
      data = excon.instance_variable_get("@data")
      data.has_key?(:ssl_verify_peer)
    end
  end

  tests('failure') do
    tests('#create_token(invalidname, invalidkey').raises(Excon::Errors::HTTPStatusError) do
      service.create_token('baduser', 'badkey')
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
fog-1.22.0 tests/rackspace/requests/identity/token_tests.rb
fog-1.21.0 tests/rackspace/requests/identity/token_tests.rb
fog-maestrodev-1.20.0.20140305101839 tests/rackspace/requests/identity/token_tests.rb
fog-maestrodev-1.20.0.20140305101305 tests/rackspace/requests/identity/token_tests.rb
fog-1.20.0 tests/rackspace/requests/identity/token_tests.rb