Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entity/entity alias primitives #41

Merged
merged 12 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
George Jahad committed Oct 2, 2024
commit d8a4d74e38e5d94fbd69d53854790d0089db75ee
2 changes: 1 addition & 1 deletion app/lib/clients/vault/entity_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def read_entity_alias_id(entity_name, alias_name)
raise "no such entity #{entity_name}"
end
aliases = e.data[:aliases]
a = aliases.find { |a| a[:name] == alias_name}
a = aliases.find { |a| a[:name] == alias_name }
if a.nil?
raise "no such alias #{alias_name}"
end
Expand Down
9 changes: 4 additions & 5 deletions test/lib/clients/vault_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,29 @@ class VaultTest < ActiveSupport::TestCase
@client.delete_entity(@entity_name)
entity = @client.read_entity(@entity_name)
assert_nil entity

end

test "#entity_alias" do
#confirm no entity yet
# confirm no entity yet
err = assert_raises RuntimeError do
@client.read_entity_alias(@entity_name, @alias_name)
end
assert_match /no such entity/, err.message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice


#confirm no alias yet
# confirm no alias yet
@client.put_entity(@entity_name, @policies)
err = assert_raises RuntimeError do
@client.read_entity_alias(@entity_name, @alias_name)
end
assert_match /no such alias/, err.message

#create alias
# create alias
auth_method = "token"
@client.put_entity_alias(@entity_name, @alias_name, auth_method)
entity_alias = @client.read_entity_alias(@entity_name, @alias_name)
assert_equal entity_alias.data[:mount_type], auth_method
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think in general the first argument is the expectation, and the second is the actual being tested -- reversed here and in other test above.
https://ruby-doc.org/stdlib-3.0.0/libdoc/minitest/rdoc/Minitest/Assertions.html


#confirm deleted alias
# confirm deleted alias
assert_equal @client.delete_entity_alias(@entity_name, @alias_name), true
err = assert_raises RuntimeError do
@client.delete_entity_alias(@entity_name, @alias_name)
Expand Down
Loading