mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Create base controller class
This commit is contained in:
parent
65676ae637
commit
8f234a5852
5 changed files with 67 additions and 23 deletions
|
@ -35,6 +35,11 @@ class AuthTokenDecryptorTest < ActiveSupport::TestCase
|
|||
refute(faulty_decryptor.decrypt_token)
|
||||
end
|
||||
|
||||
def test_decrypt_token_return_false_when_token_is_nil
|
||||
faulty_decryptor = AuthTokenDecryptor.new(nil, @key)
|
||||
refute(faulty_decryptor.decrypt_token)
|
||||
end
|
||||
|
||||
def test_valid_returns_true_for_valid_token
|
||||
decryptor = AuthTokenDecryptor.new(@access_token, @key)
|
||||
decryptor.decrypt_token
|
||||
|
|
29
test/system/api/registrant/registrant_api_domains_test.rb
Normal file
29
test/system/api/registrant/registrant_api_domains_test.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'test_helper'
|
||||
require 'auth_token/auth_token_creator'
|
||||
|
||||
class RegistrantApiDomainsTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:registrant)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
def test_root_returns_domain_list
|
||||
get '/api/v1/registrant/domains', {}, @auth_headers
|
||||
assert_equal(200, response.status)
|
||||
end
|
||||
|
||||
def test_root_returns_403_without_authorization
|
||||
get '/api/v1/registrant/domains', {}, {}
|
||||
assert_equal(403, response.status)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def auth_token
|
||||
token_creator = AuthTokenCreator.create_with_defaults(@user)
|
||||
hash = token_creator.token_in_hash
|
||||
"Bearer #{hash[:access_token]}"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue