feat: distinct git:auth-status exit codes for netrc state
The `git:auth-status` command returned `1` both when a host had no `netrc` entry and when it had one that differed, so tooling wanting to tell a credential that would be created apart from one that would be replaced had to issue a second call with no username purely to find out which of the two it was. A host with no entry now exits `1`, a host whose entry differs from what was passed exits `2`, and invalid arguments exit `3`, leaving `0` to mean the stored state already matches. Called without a username the requested state is that no entry exists, so an existing entry is reported as `2` and `1` is never returned. Callers that only test zero versus non-zero are unaffected.
This commit is contained in:
3 files changed
+86
-15
No files matched your search
+62
-9
@@ -185,12 +185,18 @@ teardown() {
|
||||
run /bin/bash -c "dokku git:auth-status"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 3
|
||||
assert_output_contains "Please supply a git host"
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_exit_status 0
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 1
|
||||
|
||||
run /bin/bash -c "dokku git:auth github.com username password"
|
||||
echo "output: $output"
|
||||
@@ -200,38 +206,85 @@ teardown() {
|
||||
run /bin/bash -c "dokku git:auth-status github.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 2
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_exit_status 0
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com username wrong-password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 2
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com other-username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 2
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status github.com username"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 3
|
||||
assert_output_contains "Missing password for netrc auth entry"
|
||||
|
||||
run /bin/bash -c "printf 'password' | dokku git:auth-status github.com username"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_exit_status 0
|
||||
|
||||
run /bin/bash -c "printf 'wrong-password' | dokku git:auth-status github.com username"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
assert_exit_status 2
|
||||
}
|
||||
|
||||
@test "(git:auth-status) distinguishes a missing entry from a differing entry" {
|
||||
run /bin/bash -c "dokku git:auth auth-status.example.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 1
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 0
|
||||
|
||||
run /bin/bash -c "dokku git:auth auth-status.example.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 0
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com username other-password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 2
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 2
|
||||
|
||||
run /bin/bash -c "dokku git:auth auth-status.example.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:auth-status auth-status.example.com username password"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_exit_status 1
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [errors]" {
|
||||
|
||||
Reference in new issue
Block a user