|
3 | 3 | describe BitBucket::Authorization do |
4 | 4 | let(:oauth_api) { BitBucket::API.new(oauth_token: 'example_oauth_token') } |
5 | 5 | let(:basic_auth_api) { BitBucket::API.new(basic_auth: 'example_login:example_password') } |
| 6 | + let(:basic_auth_api_hash) do |
| 7 | + BitBucket::API.new( |
| 8 | + basic_auth: { login: 'example_login', password: 'example_password' }) |
| 9 | + end |
6 | 10 | let(:login_and_password_api) do |
7 | 11 | BitBucket::API.new( |
8 | 12 | login: 'example_login', |
|
12 | 16 | end |
13 | 17 |
|
14 | 18 | describe '#authenticated?' do |
15 | | - context 'context: oauth authentication' do |
16 | | - it 'should return true of oauth is used' do |
| 19 | + context 'oauth authentication' do |
| 20 | + it 'should return true if oauth is used' do |
17 | 21 | expect(oauth_api.authenticated?).to eq(true) |
18 | 22 | end |
19 | 23 | end |
20 | 24 |
|
21 | | - context 'context: basic authentication' do |
| 25 | + context 'basic authentication' do |
22 | 26 | it 'should return true if basic authentication is used' do |
23 | 27 | expect(basic_auth_api.authenticated?).to eq(true) |
24 | 28 | end |
25 | 29 | end |
26 | 30 | end |
27 | 31 |
|
28 | 32 | describe '#basic_authed?' do |
29 | | - context 'context: with basic_auth' do |
| 33 | + context 'with basic_auth' do |
30 | 34 | it 'should return true if basic_auth is set' do |
31 | 35 | expect(basic_auth_api.basic_authed?).to eq(true) |
| 36 | + expect(basic_auth_api_hash.basic_authed?).to eq(true) |
32 | 37 | end |
33 | 38 | end |
34 | 39 |
|
35 | | - context 'context: with login and password' do |
| 40 | + context 'with login and password' do |
36 | 41 | it 'should return true if a login and password are set' do |
37 | 42 | expect(login_and_password_api.basic_authed?).to eq(true) |
38 | 43 | end |
39 | 44 | end |
40 | 45 | end |
41 | 46 |
|
42 | 47 | describe '#authentication' do |
43 | | - context 'context: with basic_auth' do |
| 48 | + context 'with basic_auth as a string' do |
44 | 49 | it 'should return a hash containing the value for :basic_auth' do |
45 | 50 | expectation = { basic_auth: 'example_login:example_password' } |
46 | 51 |
|
47 | 52 | expect(basic_auth_api.authentication).to eq(expectation) |
48 | 53 | end |
49 | 54 | end |
50 | 55 |
|
51 | | - context 'context: with login and password' do |
| 56 | + context 'with basic_auth as a hash' do |
| 57 | + it 'should return a hash containing the value for :basic_auth' do |
| 58 | + expectation = { basic_auth: { login: 'example_login', password: 'example_password'} } |
| 59 | + |
| 60 | + expect(basic_auth_api_hash.authentication).to eq(expectation) |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + context 'with login and password' do |
52 | 65 | it 'should return a hash containing values for :login and :password' do |
53 | 66 | expectation = { login: 'example_login', password: 'example_password' } |
54 | 67 |
|
|
0 commit comments