<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

require 'fog/openstackcore'
require 'fog/openstackcore/services/identity_v2'

describe "services" do
  describe "identity_v2" do

    let(:credentials_tenant_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_username => "admin",
        :openstack_api_key => "stack",
        :openstack_tenant => "admin",
        :openstack_region => "regionone"
      }
    }

    let(:credentials_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_username => "admin",
        :openstack_api_key => "stack",
        # :openstack_tenant => "admin",
        :openstack_region => "regionone"
      }
    }

    let(:auth_token_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_tenant => "admin",
        :openstack_region => "regionone",
        :openstack_auth_token => nil,
        # :service_options => {:proxy => 'http://localhost:8888'}
      }
    }

    describe "#initialize" do

      describe "#rescope_token" do

        describe "invalid auth token", :vcr do

          it "raises an Unauthorized exception" do
            auth_token_hash[:openstack_auth_token] = "invalid-token"
            proc {
              service =
                Fog::OpenStackCore::IdentityV2.new(auth_token_hash)
            }.must_raise Excon::Errors::Unauthorized
          end

        end

        describe "valid auth token", :vcr do

          # 1 - get a valid (unscoped) auth token<commit_msg>rename<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

require 'fog/openstackcore'
require 'fog/openstackcore/services/identity_v2'

describe "services" do
  describe "identity_v2" do

    let(:credentials_tenant_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_username => "admin",
        :openstack_api_key => "stack",
        :openstack_tenant => "admin",
        :openstack_region => "regionone"
      }
    }

    let(:credentials_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_username => "admin",
        :openstack_api_key => "stack",
        # :openstack_tenant => "admin",
        :openstack_region => "regionone"
      }
    }

    let(:auth_token_hash) {
      {
        :openstack_auth_url => "http://devstack.local:5000",
        :openstack_tenant => "admin",
        :openstack_region => "regionone",
        :openstack_auth_token => nil
        # :connection_options => {:proxy => 'http://localhost:8888'}
      }
    }

    describe "#initialize" do

      describe "#rescope_token" do

        describe "invalid auth token", :vcr do

          it "raises an Unauthorized exception" do
            auth_token_hash[:openstack_auth_token] = "invalid-token"
            proc {
              service =
                Fog::OpenStackCore::IdentityV2.new(auth_token_hash)
            }.must_raise Excon::Errors::Unauthorized
          end

        end

        describe "valid auth token", :vcr do

          # 1 - get a valid (unscoped) auth token
{'fraction_non_alphanumeric': 0.12599174865122184, 'fraction_numerical': 0.012694382735639479, 'mean_word_length': 2.3496280552603612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2754026', 'n_tokens_mistral': 998, 'n_tokens_neox': 956, 'n_words': 173}