-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline some testing bits, add destroy_secret kv support
- Loading branch information
Showing
6 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "test_helper" | ||
|
||
class SecretsTest < ActionDispatch::IntegrationTest | ||
test "#create unauthorized" do | ||
post secrets_path | ||
assert_response :unauthorized | ||
end | ||
|
||
test "#create with faulty token (encoded with different signing key)" do | ||
post secrets_path, headers: { "Authorization" => "Bearer #{jwt_unauthorized}" } | ||
assert_response :unauthorized | ||
end | ||
|
||
test "#create or update a secret" do | ||
create_secret | ||
end | ||
|
||
test "#show" do | ||
create_secret | ||
# view the secret | ||
get secret_path("top/secret/key"), headers: { "Authorization" => "Bearer #{jwt_authorized}" } | ||
assert_response :success | ||
%w[ data metadata lease_id ].each do |key| | ||
assert_includes response.parsed_body["secret"].keys, key | ||
end | ||
end | ||
|
||
test "#delete" do | ||
create_secret | ||
# delete the secret | ||
delete destroy_secret_path("top/secret/key"), headers: { "Authorization" => "Bearer #{jwt_authorized}" } | ||
assert_response :success | ||
end | ||
|
||
def create_secret | ||
# create the secret | ||
post secrets_path, headers: { "Authorization" => "Bearer #{jwt_authorized}" }, | ||
params: { secret: { path: "top/secret/key", data: { password: "sicr3t" } } } | ||
assert_response :success | ||
%w[ data metadata lease_id ].each do |key| | ||
assert_includes response.parsed_body["secret"].keys, key | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters