Skip to content

Commit

Permalink
Add 'default' account when no name is provided
Browse files Browse the repository at this point in the history
Resolves #2082
  • Loading branch information
szh committed Oct 13, 2021
1 parent 47a0422 commit c4dac0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions bin/conjur-cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@
be read from STDIN. If the flag is not provided, the "admin" user API key
will be outputted to STDOUT.
The 'name' flag or command argument must be present. It will specify the
name of the account that will be created.
The 'name' flag or command argument will specify the name of the account
that will be created. If it is not provided, the account name will be
'default'.
Example:
$ conjurctl account create [--password-from-stdin] --name myorg
$ conjurctl account create [--password-from-stdin] [--name myorg]
DESC
cgrp.arg(:name, :optional)
cgrp.command :create do |c|
Expand Down
3 changes: 2 additions & 1 deletion bin/conjur-cli/commands/account/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module Account
]
) do
def call
raise "No account name was provided" unless @account
# Create a new account named 'default' if no name is provided
@account ||= 'default'

# Ensure the database is available
@connect_database.call
Expand Down
9 changes: 6 additions & 3 deletions spec/conjurctl/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ def delete_account(name)
system("conjurctl account delete #{name}")
end

it "no account name provided" do
_, stderr_str, = Open3.capture3(
it "creates default account when no name provided" do
stdout_str, = Open3.capture3(
"conjurctl account create"
)
expect(stderr_str).to include("No account name was provided")
expect(stdout_str).to include("API key for admin")
expect(Slosilo["authn:default"]).to be
expect(Role["default:user:admin"]).to be
delete_account("default")
end

context "create with name demo" do
Expand Down

0 comments on commit c4dac0f

Please sign in to comment.