Skip to content

Commit 816dba7

Browse files
committed
adding pending tests
1 parent 18bff1b commit 816dba7

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.gem
33
*.rbc
44
/.config
5+
/.vscode
56
/coverage/
67
/InstalledFiles
78
/pkg/

spec/integration/api/auth_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,42 @@ module Vault
258258
subject.auth.aws_iam('a_rolename', credentials_provider, 'iam_header_canary', 'https://sts.cn-north-1.amazonaws.com.cn')
259259
end
260260
end
261+
262+
describe "#gcp", vault: ">= 0.8.1" do
263+
before(:context) do
264+
vault_test_client.sys.enable_auth("gcp", "gcp", nil)
265+
vault_test_client.post("/v1/auth/gcp/config", JSON.fast_generate("service_account" => "rspec_service_account"))
266+
vault_test_client.post("/v1/auth/gcp/role/rspec_wrong_role", JSON.fast_generate("name" => "rspec_role", "project_id" => "wrong_project_id", "bound_service_accounts" => "\*", "type" => "iam"))
267+
vault_test_client.post("/v1/auth/gcp/role/rspec_role", JSON.fast_generate("name" => "rspec_role", "project_id" => "project_id", "bound_service_accounts" => "\*", "type" => "iam"))
268+
end
269+
270+
after(:context) do
271+
vault_test_client.sys.disable_auth("gcp")
272+
end
273+
274+
let!(:old_token) { subject.token }
275+
276+
let(:jwt) do
277+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJwcm9qZWN0X2lkIjoicHJvamVjdF9pZCJ9.TmuiSHtbLMZuw_LOzKWQ2vnC7BUvu2b4CeBXdxCDCXQ"
278+
end
279+
280+
after do
281+
subject.token = old_token
282+
end
283+
284+
it "does not authenticate if project_id does not match" do
285+
pending "gcp auth requires real resources and keys"
286+
287+
expect do
288+
subject.auth.gcp("rspec_wrong_role", jwt)
289+
end.to raise_error(Vault::HTTPClientError, /project_id doesn't match/)
290+
end
291+
292+
it "authenticates and saves the token on the client" do
293+
pending "gcp auth requires real resources and keys"
294+
295+
subject.auth.gcp("rspec_role", jwt)
296+
end
297+
end
261298
end
262299
end

0 commit comments

Comments
 (0)