Sha256: f59e8b7550f4d9ac98a4de3f546fbfbb60f6014ae4e24c019179c25e4ba17a56

Contents?: true

Size: 825 Bytes

Versions: 13

Compression:

Stored size: 825 Bytes

Contents

require "spec_helper"
require "gds-sso/bearer_token"

describe GDS::SSO::BearerToken do
  describe ".locate" do
    it "creates a new user for a token" do
      response = double(body: {
        user: {
          uid: "asd",
          email: "user@example.com",
          name: "A Name",
          permissions: %w[signin],
          organisation_slug: "hmrc",
          organisation_content_id: "67a2b78d-eee3-45b3-80e2-792e7f71cecc",
        },
      }.to_json)

      allow_any_instance_of(OAuth2::AccessToken).to receive(:get).and_return(response)

      created_user = GDS::SSO::BearerToken.locate("MY-API-TOKEN")

      expect(created_user.email).to eql("user@example.com")

      same_user_again = GDS::SSO::BearerToken.locate("MY-API-TOKEN")

      expect(same_user_again.id).to eql(created_user.id)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gds-sso-19.1.0 spec/unit/bearer_token_spec.rb
gds-sso-19.0.0 spec/unit/bearer_token_spec.rb
gds-sso-18.1.0 spec/unit/bearer_token_spec.rb
gds-sso-18.0.0 spec/unit/bearer_token_spec.rb
gds-sso-17.1.1 spec/unit/bearer_token_spec.rb
gds-sso-17.1.0 spec/unit/bearer_token_spec.rb
gds-sso-17.0.0 spec/unit/bearer_token_spec.rb
gds-sso-16.1.0 spec/unit/bearer_token_spec.rb
gds-sso-16.0.2 spec/unit/bearer_token_spec.rb
gds-sso-16.0.1 spec/unit/bearer_token_spec.rb
gds-sso-16.0.0 spec/unit/bearer_token_spec.rb
gds-sso-15.1.0 spec/unit/bearer_token_spec.rb
gds-sso-15.0.1 spec/unit/bearer_token_spec.rb