mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Provide valid configuration for auth
This commit removes a additional authenticate method that is defined in the token_spec tests. Instead, authenticate is used from api/helpers. To support this change the config provided is updated to specify a dummy provider. Without this change authenticate cannot be tested along with token_spec because token_spec redefines authenticate.
This commit is contained in:
parent
9fa27af8e5
commit
cbd4567454
1 changed files with 23 additions and 13 deletions
|
|
@ -1,16 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'rack/test'
|
require 'rack/test'
|
||||||
|
|
||||||
module Vmpooler
|
|
||||||
class API
|
|
||||||
module Helpers
|
|
||||||
def authenticate(auth, username_str, password_str)
|
|
||||||
username_str == 'admin' and password_str == 's3cr3t'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe Vmpooler::API::V1 do
|
describe Vmpooler::API::V1 do
|
||||||
include Rack::Test::Methods
|
include Rack::Test::Methods
|
||||||
|
|
||||||
|
|
@ -39,7 +29,15 @@ describe Vmpooler::API::V1 do
|
||||||
end
|
end
|
||||||
|
|
||||||
context '(auth configured)' do
|
context '(auth configured)' do
|
||||||
let(:config) { { auth: true } }
|
let(:config) {
|
||||||
|
{
|
||||||
|
auth: {
|
||||||
|
'provider' => 'dummy'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let(:username_str) { 'admin' }
|
||||||
|
let(:password_str) { 's3cr3t' }
|
||||||
|
|
||||||
it 'returns a 401 if not authed' do
|
it 'returns a 401 if not authed' do
|
||||||
get "#{prefix}/token"
|
get "#{prefix}/token"
|
||||||
|
|
@ -69,7 +67,13 @@ describe Vmpooler::API::V1 do
|
||||||
end
|
end
|
||||||
|
|
||||||
context '(auth configured)' do
|
context '(auth configured)' do
|
||||||
let(:config) { { auth: true } }
|
let(:config) {
|
||||||
|
{
|
||||||
|
auth: {
|
||||||
|
'provider' => 'dummy'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
it 'returns a 401 if not authed' do
|
it 'returns a 401 if not authed' do
|
||||||
post "#{prefix}/token"
|
post "#{prefix}/token"
|
||||||
|
|
@ -146,7 +150,13 @@ describe Vmpooler::API::V1 do
|
||||||
end
|
end
|
||||||
|
|
||||||
context '(auth configured)' do
|
context '(auth configured)' do
|
||||||
let(:config) { { auth: true } }
|
let(:config) {
|
||||||
|
{
|
||||||
|
auth: {
|
||||||
|
'provider' => 'dummy'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
it 'returns a 401 if not authed' do
|
it 'returns a 401 if not authed' do
|
||||||
delete "#{prefix}/token/this"
|
delete "#{prefix}/token/this"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue