mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(QENG-2995) Display associated VMs in GET /token/:token endpoint
This commit is contained in:
parent
12da1e07d2
commit
e0356968df
3 changed files with 33 additions and 8 deletions
|
|
@ -120,11 +120,12 @@ describe Vmpooler::API::V1 do
|
|||
end
|
||||
|
||||
context '(auth configured)' do
|
||||
before do
|
||||
allow(redis).to receive(:hgetall).and_return 'atoken'
|
||||
end
|
||||
|
||||
let(:config) { { auth: true } }
|
||||
let(:config) { {
|
||||
auth: true,
|
||||
pools: [
|
||||
{'name' => 'pool1', 'size' => 5}
|
||||
]
|
||||
} }
|
||||
|
||||
it 'returns a 401 if not authed' do
|
||||
get "#{prefix}/token/this"
|
||||
|
|
@ -133,11 +134,17 @@ describe Vmpooler::API::V1 do
|
|||
end
|
||||
|
||||
it 'returns a token if authed' do
|
||||
expect(redis).to receive(:hgetall).with('vmpooler__token__this').and_return({'user' => 'admin'})
|
||||
expect(redis).to receive(:smembers).with('vmpooler__running__pool1').and_return(['vmhostname'])
|
||||
expect(redis).to receive(:hget).with('vmpooler__vm__vmhostname', 'token:token').and_return('this')
|
||||
|
||||
authorize 'admin', 's3cr3t'
|
||||
|
||||
get "#{prefix}/token/this"
|
||||
|
||||
expect(last_response.body).to include('"this": "atoken"')
|
||||
expect(JSON.parse(last_response.body)['ok']).to eq(true)
|
||||
expect(JSON.parse(last_response.body)['this']['user']).to eq('admin')
|
||||
expect(JSON.parse(last_response.body)['this']['vms']['running']).to include('vmhostname')
|
||||
|
||||
expect_json(ok = true, http = 200)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue