Skip to content

Commit

Permalink
Add a mocked out integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
maschwenk committed Jan 9, 2018
1 parent 11a5cde commit 6217a9f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/integration/api/auth_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "spec_helper"
require "aws-sigv4"

module Vault
describe Auth do
Expand Down Expand Up @@ -211,5 +212,39 @@ module Vault
}.to_not change { subject.token }
end
end

describe "#aws_iam" do
before(:context) do
vault_test_client.sys.enable_auth("aws", "aws", nil)
end

after(:context) do
vault_test_client.sys.disable_auth("aws")
end

let!(:old_token) { subject.token }
let(:credentials_provider) do
double(
credentials:
double(access_key_id: 'very', secret_access_key: 'secure', session_token: 'thing')
)
end
let(:secret) { double(auth: double(client_token: 'a great token')) }

after do
subject.token = old_token
end

it "authenticates and saves the token on the client", vault: "> 0.7.3" do
expect(subject).to receive(:post).and_return 'huzzah!'
expect(Secret).to receive(:decode).and_return secret
expect(::Aws::Sigv4::Signer).to(
receive(:new).with(
service: 'sts', region: 'cn-north-1', credentials_provider: credentials_provider
).and_call_original
)
subject.auth.aws_iam('yabba', credentials_provider, 'canary_header', 'https://sts.cn-north-1.amazonaws.com.cn')
end
end
end
end

0 comments on commit 6217a9f

Please sign in to comment.