From cbd4567454b9f04efb51cc3adac3f8650a8b26d9 Mon Sep 17 00:00:00 2001 From: "kirby@puppetlabs.com" Date: Wed, 27 Jun 2018 14:41:27 -0700 Subject: [PATCH] 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. --- spec/integration/api/v1/token_spec.rb | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/spec/integration/api/v1/token_spec.rb b/spec/integration/api/v1/token_spec.rb index d386457..983dac6 100644 --- a/spec/integration/api/v1/token_spec.rb +++ b/spec/integration/api/v1/token_spec.rb @@ -1,16 +1,6 @@ require 'spec_helper' 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 include Rack::Test::Methods @@ -39,7 +29,15 @@ describe Vmpooler::API::V1 do end 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 get "#{prefix}/token" @@ -69,7 +67,13 @@ describe Vmpooler::API::V1 do end context '(auth configured)' do - let(:config) { { auth: true } } + let(:config) { + { + auth: { + 'provider' => 'dummy' + } + } + } it 'returns a 401 if not authed' do post "#{prefix}/token" @@ -146,7 +150,13 @@ describe Vmpooler::API::V1 do end context '(auth configured)' do - let(:config) { { auth: true } } + let(:config) { + { + auth: { + 'provider' => 'dummy' + } + } + } it 'returns a 401 if not authed' do delete "#{prefix}/token/this"