Skip to content
Extraits de code Groupes Projets
Valider 98fd1807 rédigé par theworldbright's avatar theworldbright
Parcourir les fichiers

Add test for expired access token

parent 6e1a6734
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......@@ -50,8 +50,6 @@ module Api
end
}
end
# TODO: buildResponseType(req)
end
end
end
......
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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter