diff --git a/app/models/api/openid_connect/authorization.rb b/app/models/api/openid_connect/authorization.rb index 90a225845b2a027eddec19fd28a2ad00c6d49ced..8ca7c8e41942ea2dba560fb0eb4dad8b1deb4b7f 100644 --- a/app/models/api/openid_connect/authorization.rb +++ b/app/models/api/openid_connect/authorization.rb @@ -57,7 +57,6 @@ module Api auth.code = nil if auth # Remove auth code if found so it can't be reused auth end - # TODO: Consider splitting into subclasses by flow type end end end diff --git a/lib/api/openid_connect/authorization_point/endpoint.rb b/lib/api/openid_connect/authorization_point/endpoint.rb index 29d010f9188acfc84447326987dcd8528babead9..38ccb5f993a795f8a6fae6a8aa02d405661510ce 100644 --- a/lib/api/openid_connect/authorization_point/endpoint.rb +++ b/lib/api/openid_connect/authorization_point/endpoint.rb @@ -50,8 +50,6 @@ module Api end } end - - # TODO: buildResponseType(req) end end end diff --git a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb index ec819f13eda82cb9011b0dec52eb8954dd864dac..0d1f9eaa37d629f2d9bd7e747c16af5c5172ac8f 100644 --- a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb +++ b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb @@ -1,12 +1,15 @@ require "spec_helper" - describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do let(:auth_with_read) { FactoryGirl.create(:auth_with_read) } let!(:access_token_with_read) { auth_with_read.create_access_token.to_s } + let!(:expired_access_token) do + access_token = auth_with_read.o_auth_access_tokens.create! + access_token.expires_at = Time.zone.now - 100 + access_token.save + access_token.bearer_token.to_s + end let(:invalid_token) { SecureRandom.hex(32).to_s } - # TODO: Add tests for expired access tokens - context "when valid access token is provided" do before do get api_openid_connect_user_info_path, access_token: access_token_with_read @@ -17,6 +20,19 @@ describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do end end + context "when access token is expired" do + before do + get api_openid_connect_user_info_path, access_token: expired_access_token + end + + it "should respond with a 401 Unauthorized response" do + expect(response.status).to be(401) + end + it "should have an auth-scheme value of Bearer" do + expect(response.headers["WWW-Authenticate"]).to include("Bearer") + end + end + context "when no access token is provided" do before do get api_openid_connect_user_info_path