-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
syl-p
committed
Feb 23, 2024
1 parent
3b2ece2
commit 120c0f5
Showing
4 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'test_helper' | ||
require 'authorization_helper' | ||
|
||
class OauthControllerTest < ActionDispatch::IntegrationTest | ||
include AuthorizationHelper | ||
include Devise::Test::IntegrationHelpers | ||
|
||
setup do | ||
if ENV['ENABLE_AUTHENTICATION'].present? | ||
|
||
end | ||
@pia = FactoryBot.create(:pia) | ||
@admin = FactoryBot.create(:user_admin, identifier: "admin") | ||
@doorkeeper_token = doorkeeper_token | ||
@auth = FactoryBot.create(:access_token) | ||
@auth_tokens = nil | ||
end | ||
|
||
test "should not access to pia because is not logged" do | ||
get pias_url | ||
assert_response :unauthorized | ||
end | ||
|
||
test "admin authentification and get pias" do | ||
@auth_tokens = auth_tokens_for_user(@admin, @auth) | ||
@doorkeeper_token = @auth_tokens['access_token'] | ||
|
||
get pias_url, headers: { 'Authorization' => "Bearer #{@doorkeeper_token}" }, as: :json | ||
assert_response :success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters