diff options
| author | mokha <mokha@cisco.com> | 2018-11-10 09:35:35 -0700 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2018-11-10 09:36:05 -0700 |
| commit | e544e7f72a42ed72243f4651cac8f0e78a960e36 (patch) | |
| tree | 9af158e6b54fafcd6eceba3706fd9ca51e73f548 /test/net/client_test.rb | |
| parent | 0ce5728f61bb0c5df1f1c612538b028aae41ac8c (diff) | |
add helper to generate basic auth credentials.
Diffstat (limited to 'test/net/client_test.rb')
| -rw-r--r-- | test/net/client_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/net/client_test.rb b/test/net/client_test.rb index c71943c..51ac57b 100644 --- a/test/net/client_test.rb +++ b/test/net/client_test.rb @@ -58,6 +58,22 @@ class ClientTest < Minitest::Test assert_equal response.class, Net::HTTPCreated end + def test_get_with_basic_auth_headers + VCR.use_cassette('post_basic_auth') do + uri = URI.parse('http://localhost:3000/oauth/tokens') + client_id = "79a1c787-5cac-4cc5-b00e-374f5a909ef8" + client_password = "za9NeRkm9YbqKDa6GreUmo6V" + authorization_code = "NGooUnxYq5f5DHvJqyzDhSft" + headers = { 'Authorization' => Net::Hippie.basic_auth(client_id, client_password) } + body = { grant_type: 'authorization_code', code: authorization_code } + response = subject.post(uri, headers: headers, body: body) + refute_nil response + json = JSON.parse(response.body, symbolize_names: true) + assert_equal('Bearer', json[:token_type]) + assert(json[:token_type]) + end + end + def test_get_with_body uri = URI.parse('https://haveibeenpwned.com/api/breaches') body = { 'hello' => 'world' } |
