Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddriddle committed Oct 4, 2024
1 parent 0c152c7 commit a8bc393
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion src/integration_tests/tests/login_configure.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ load 'base'
assert_output "$ERROR_MESG"
}

@test "Configure default profile" {
@test "Configure nonexistent default profile" {
configure_default_profile
test_default_profile
}

configure_default_profile() {
run aws login configure <<- EOF # NOTA BENE: <<- strips tabs
https://shibboleth.illinois.edu/idp/profile/SAML2/SOAP/ECP$CR
netid$CR
Expand All @@ -25,7 +30,9 @@ load 'base'
EOF
assert_output "ECP Endpoint URL [None]: Username [None]: Enable Keyring [False]: Duo Factor [None]: Role ARN [None]: "
}

test_default_profile() {
assert_exists "$AWSCLI_LOGIN_ROOT/.aws-login/config"
! read -r -d '' CONFIG_FILE <<- EOF # NOTA BENE: <<- strips tabs
[default]$CR
Expand All @@ -35,3 +42,51 @@ load 'base'
EOF
assert_equal "$(<$AWSCLI_LOGIN_ROOT/.aws-login/config)" "$CONFIG_FILE"
}

# Regression test for issue #212
@test "Configure empty default profile" {
cat <<- EOF > $AWS_SHARED_CREDENTIALS_FILE
[default]
aws_access_key_id =
aws_secret_access_key =
aws_session_token =
aws_security_token =
EOF

configure_default_profile
test_default_profile
}

create_nonempty_default_profile() {
cat <<- EOF > $AWS_SHARED_CREDENTIALS_FILE
[default]
aws_access_key_id = foo
aws_secret_access_key = bar
EOF
}

@test "Configure nonempty default profile" {
create_nonempty_default_profile

run aws login configure <<- EOF # NOTA BENE: <<- strips tabs
YES
https://shibboleth.illinois.edu/idp/profile/SAML2/SOAP/ECP$CR
netid$CR
$CR
push$CR
EOF
assert_output "WARNING: Profile 'default' contains credentials.
Overwrite profile 'default' to enable login? ECP Endpoint URL [None]: Username [None]: Enable Keyring [False]: Duo Factor [None]: Role ARN [None]: "
test_default_profile
}

@test "Do not configure nonempty default profile" {
create_nonempty_default_profile
run aws login configure <<- EOF # NOTA BENE: <<- strips tabs
No
EOF
assert_output "WARNING: Profile 'default' contains credentials.
Overwrite profile 'default' to enable login? "
assert_not_exists "$AWSCLI_LOGIN_ROOT/.aws-login/config"
}

0 comments on commit a8bc393

Please sign in to comment.