Skip to content

Commit

Permalink
Label oidc pkce and v2 unit tests
Browse files Browse the repository at this point in the history
Fixed PKCE strategy spec not being run because its file name ended in *_rspec.rb.

```bash
rspec -f d --color --dry-run --tag @type:unit
rspec -f d --color --dry-run --tag @review

\# No integration tests added yet
rspec -f d --color --dry-run --tag @type:integ
```
  • Loading branch information
codihuston committed Jan 26, 2023
1 parent 0ca7cf4 commit f607512
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end
end

describe '.callback' do
describe '.callback', :type => 'unit' do
context 'when credentials are valid' do
it 'returns a valid JWT token', vcr: 'authenticators/authn-oidc/pkce_support_feature/client_callback-valid_oidc_credentials' do
# Because JWT tokens have an expiration timeframe, we need to hold
Expand Down Expand Up @@ -149,7 +149,7 @@
end
end

describe '.discovery_information', vcr: 'authenticators/authn-oidc/pkce_support_feature/discovery_endpoint-valid_oidc_credentials' do
describe '.discovery_information', :type => 'unit', vcr: 'authenticators/authn-oidc/pkce_support_feature/discovery_endpoint-valid_oidc_credentials' do
context 'when credentials are valid' do
it 'endpoint returns valid data' do
discovery_information = client.discovery_information(invalidate: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

let(:authenticator) { described_class.new(**args) }

describe '.scope' do
describe '.scope', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.scope).to eq('openid email profile') }
end
Expand Down Expand Up @@ -50,7 +50,7 @@
end
end

describe '.name' do
describe '.name', :type => 'unit' do
context 'when name is missing' do
it { expect(authenticator.name).to eq('My Authenticator') }
end
Expand All @@ -60,19 +60,19 @@
end
end

describe '.resource_id' do
describe '.resource_id', :type => 'unit' do
context 'correctly renders' do
it { expect(authenticator.resource_id).to eq('default:webservice:conjur/authn-oidc/my-authenticator') }
end
end

describe '.response_type' do
describe '.response_type', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.response_type).to eq('code') }
end
end

describe '.token_ttl' do
describe '.token_ttl', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.token_ttl).to eq(8.minutes) }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Authentication::AuthnOidc::PkceSupportFeature::ResolveIdentity.new
end

describe('#call') do
describe('#call', :type => 'unit') do
let(:valid_role) do
instance_double(::Role).tap do |double|
allow(double).to receive(:id).and_return('rspec:user:alice')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

require 'spec_helper'

RSpec.describe(' Authentication::AuthnOidc::PkceSupportFeature::Strategy') do

RSpec.describe('Authentication::AuthnOidc::PkceSupportFeature::Strategy') do
let(:jwt) { double(raw_attributes: { claim_mapping: "alice" }) }

let(:authenticator) do
Expand Down Expand Up @@ -38,7 +37,7 @@
)
end

describe('#callback') do
describe('#callback', :type => 'unit', :review => true) do
context 'when a role_id matches the identity exist' do
let(:mapping) { "claim_mapping" }
it 'returns the role' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
end
end

describe('#call') do
describe('#call', :type => 'unit', :review => true) do
context 'when provider context is given multiple authenticators' do
it 'returns the providers object with the redirect urls' do
expect(provider_context.call(authenticators: authenticators))
Expand Down
6 changes: 3 additions & 3 deletions spec/app/domain/authentication/authn-oidc/v2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
end

describe '.callback' do
describe '.callback', :type => 'unit', :review => true do
context 'when credentials are valid' do
it 'returns a valid JWT token', vcr: 'authenticators/authn-oidc/v2/client_callback-valid_oidc_credentials' do
# Because JWT tokens have an expiration timeframe, we need to hold
Expand Down Expand Up @@ -99,7 +99,7 @@
end
end

describe '.oidc_client' do
describe '.oidc_client', :type => 'unit', :review => true do
context 'when credentials are valid' do
it 'returns a valid oidc client', vcr: 'authenticators/authn-oidc/v2/client_initialization' do
oidc_client = client.oidc_client
Expand All @@ -118,7 +118,7 @@
end
end

describe '.discovery_information', vcr: 'authenticators/authn-oidc/v2/discovery_endpoint-valid_oidc_credentials' do
describe '.discovery_information', :type => 'unit', :review => true, vcr: 'authenticators/authn-oidc/v2/discovery_endpoint-valid_oidc_credentials' do
context 'when credentials are valid' do
it 'endpoint returns valid data' do
discovery_information = client.discovery_information(invalidate: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

let(:authenticator) { described_class.new(**args) }

describe '.scope' do
describe '.scope', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.scope).to eq('openid email profile') }
end
Expand Down Expand Up @@ -47,7 +47,7 @@
end
end

describe '.name' do
describe '.name', :type => 'unit' do
context 'when name is missing' do
it { expect(authenticator.name).to eq('My Authenticator') }
end
Expand All @@ -57,19 +57,19 @@
end
end

describe '.resource_id' do
describe '.resource_id', :type => 'unit' do
context 'correctly renders' do
it { expect(authenticator.resource_id).to eq('default:webservice:conjur/authn-oidc/my-authenticator') }
end
end

describe '.response_type' do
describe '.response_type', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.response_type).to eq('code') }
end
end

describe '.token_ttl' do
describe '.token_ttl', :type => 'unit' do
context 'with default initializer' do
it { expect(authenticator.token_ttl).to eq(8.minutes) }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe(' Authentication::AuthnOidc::V2::ResolveIdentity') do
RSpec.describe('Authentication::AuthnOidc::V2::ResolveIdentity', :type => 'unit') do
let(:resolve_identity) do
Authentication::AuthnOidc::V2::ResolveIdentity.new
end
Expand Down Expand Up @@ -91,6 +91,5 @@
)
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

require 'spec_helper'

RSpec.describe(' Authentication::AuthnOidc::V2::Strategy') do

RSpec.describe('Authentication::AuthnOidc::V2::Strategy') do
let(:jwt) { double(raw_attributes: { claim_mapping: "alice" }) }

let(:authenticator) do
Expand Down Expand Up @@ -41,7 +40,7 @@
)
end

describe('#callback') do
describe('#callback', :type => 'unit', :review => true) do
context 'when a role_id matches the identity exist' do
let(:mapping) { "claim_mapping" }
it 'returns the role' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
)
end

describe('#call') do
describe('#call', :type => 'unit', :review => true) do
context 'when provider context is given multiple authenticators' do
it 'returns the providers object with the redirect urls' do
expect(provider_context.call(authenticators: authenticators))
Expand All @@ -84,4 +84,3 @@
end
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe(Authentication::Util::NamespaceSelector) do
describe '#select' do
describe '#select', :type => 'unit' do
context 'when type is a supported authenticator type' do
context 'when type is `authn-oidc`' do
context 'when pkce support feature flag is enabled' do
Expand Down

0 comments on commit f607512

Please sign in to comment.