|
5 | 5 |
|
6 | 6 | describe Pooler do
|
7 | 7 | before :each do
|
8 |
| - @abs_url = 'https://abs.example.com' |
| 8 | + @abs_url = 'https://abs.example.com/api/v2' |
9 | 9 | end
|
10 | 10 |
|
11 | 11 | describe '#get_token' do
|
|
15 | 15 | end
|
16 | 16 |
|
17 | 17 | it 'returns a token from vmpooler' do
|
18 |
| - stub_request(:post, 'https://first.last:[email protected]/api/v2/token') |
19 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length' => '0', 'User-Agent' => 'Faraday v0.9.2' }) |
| 18 | + stub_request(:post, "#{@abs_url}/token") |
| 19 | + .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic Zmlyc3QubGFzdDpwYXNzd29yZA==', 'Content-Length'=>'0'}) |
20 | 20 | .to_return(:status => 200, :body => @get_token_response, :headers => {})
|
21 | 21 |
|
22 | 22 | token = Auth.get_token(false, @abs_url, 'first.last', 'password')
|
23 | 23 | expect(token).to eq @token
|
24 | 24 | end
|
25 | 25 |
|
26 | 26 | it 'raises a token error if something goes wrong' do
|
27 |
| - stub_request(:post, 'https://first.last:[email protected]/api/v2/token') |
28 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length' => '0', 'User-Agent' => 'Faraday v0.9.2' }) |
| 27 | + stub_request(:post, "#{@abs_url}/token") |
| 28 | + .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic Zmlyc3QubGFzdDpwYXNzd29yZA==', 'Content-Length'=>'0'}) |
29 | 29 | .to_return(:status => 500, :body => '{"ok":false}', :headers => {})
|
30 | 30 |
|
31 | 31 | expect { Auth.get_token(false, @abs_url, 'first.last', 'password') }.to raise_error(TokenError)
|
|
39 | 39 | end
|
40 | 40 |
|
41 | 41 | it 'deletes the specified token' do
|
42 |
| - stub_request(:delete, 'https://first.last:[email protected]/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') |
43 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Faraday v0.9.2' }) |
44 |
| - .to_return(:status => 200, :body => @delete_token_response, :headers => {}) |
| 42 | + stub_request(:delete, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") |
| 43 | + .with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic Zmlyc3QubGFzdDpwYXNzd29yZA=='}) |
| 44 | + .to_return(:status => 200, :body => @delete_token_response, :headers => {}) |
45 | 45 |
|
46 | 46 | expect(Auth.delete_token(false, @abs_url, 'first.last', 'password', @token)).to eq JSON.parse(@delete_token_response)
|
47 | 47 | end
|
48 | 48 |
|
49 | 49 | it 'raises a token error if something goes wrong' do
|
50 |
| - stub_request(:delete, 'https://first.last:[email protected]/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') |
51 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Faraday v0.9.2' }) |
| 50 | + stub_request(:delete, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") |
| 51 | + .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}) |
52 | 52 | .to_return(:status => 500, :body => '{"ok":false}', :headers => {})
|
53 | 53 |
|
54 | 54 | expect { Auth.delete_token(false, @abs_url, 'first.last', 'password', @token) }.to raise_error(TokenError)
|
|
67 | 67 |
|
68 | 68 | it 'checks the status of a token' do
|
69 | 69 | stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
|
70 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Faraday v0.9.2' }) |
| 70 | + .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}) |
71 | 71 | .to_return(:status => 200, :body => @token_status_response, :headers => {})
|
72 | 72 |
|
73 | 73 | expect(Auth.token_status(false, @abs_url, @token)).to eq JSON.parse(@token_status_response)
|
74 | 74 | end
|
75 | 75 |
|
76 | 76 | it 'raises a token error if something goes wrong' do
|
77 | 77 | stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
|
78 |
| - .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Faraday v0.9.2' }) |
| 78 | + .with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}) |
79 | 79 | .to_return(:status => 500, :body => '{"ok":false}', :headers => {})
|
80 | 80 |
|
81 | 81 | expect { Auth.token_status(false, @abs_url, @token) }.to raise_error(TokenError)
|
|
0 commit comments