From 13562aeb0687040b3464718e7f70b7bfb8e36ee6 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 30 Jul 2018 13:56:54 +0300 Subject: [PATCH] Move file to another folder --- .../registrant/registrant_api_domains_test.rb | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) rename test/{system => integration}/api/registrant/registrant_api_domains_test.rb (51%) diff --git a/test/system/api/registrant/registrant_api_domains_test.rb b/test/integration/api/registrant/registrant_api_domains_test.rb similarity index 51% rename from test/system/api/registrant/registrant_api_domains_test.rb rename to test/integration/api/registrant/registrant_api_domains_test.rb index 36a9def35..bcf11cfc0 100644 --- a/test/system/api/registrant/registrant_api_domains_test.rb +++ b/test/integration/api/registrant/registrant_api_domains_test.rb @@ -1,6 +1,7 @@ require 'test_helper' +require 'auth_token/auth_token_creator' -class RegistrantApiDomainsTest < ApplicationSystemTestCase +class RegistrantApiDomainsTest < ActionDispatch::IntegrationTest def setup super @@ -28,7 +29,24 @@ class RegistrantApiDomainsTest < ApplicationSystemTestCase assert_equal({errors: ['Domain not found']}, response_json) end - def test_get_non_registrar_domain_details_by_uuid - # no op + def test_root_returns_domain_list + get '/api/v1/registrant/domains', {}, @auth_headers + assert_equal(200, response.status) + end + + def test_root_returns_401_without_authorization + get '/api/v1/registrant/domains', {}, {} + assert_equal(401, response.status) + json_body = JSON.parse(response.body, symbolize_names: true) + + assert_equal({ errors: ['Not authorized'] }, json_body) + end + + private + + def auth_token + token_creator = AuthTokenCreator.create_with_defaults(@user) + hash = token_creator.token_in_hash + "Bearer #{hash[:access_token]}" end end