From 60819b9a7ef615188571448d7521c26d5c7366e1 Mon Sep 17 00:00:00 2001 From: Scott Schneider Date: Mon, 1 Jun 2015 18:09:04 -0700 Subject: [PATCH] Spec tests for tagfilter --- spec/vmpooler/api/v1_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/vmpooler/api/v1_spec.rb b/spec/vmpooler/api/v1_spec.rb index 687c865..dfcea5f 100644 --- a/spec/vmpooler/api/v1_spec.rb +++ b/spec/vmpooler/api/v1_spec.rb @@ -332,6 +332,23 @@ describe Vmpooler::API::V1 do expect(last_response.status).to eq(400) end + context '(tagfilter configured)' do + let(:config) { { + tagfilter: { 'url' => '(.*)\/' }, + } } + + it 'correctly filters tags' do + expect(redis).to receive(:hset).with("vmpooler__vm__testhost", "tag:url", "foo.com") + + put "#{prefix}/vm/testhost", '{"tags":{"url":"foo.com/something.html"}}' + + expect(last_response).to be_ok + expect(last_response.header['Content-Type']).to eq('application/json') + expect(last_response.body).to eq(JSON.pretty_generate({'ok' => true})) + expect(last_response.status).to eq(200) + end + end + context '(auth not configured)' do let(:config) { { auth: false } }