Skip to content

Commit 43cb021

Browse files
committed
add serviceaccount login test
1 parent c93f914 commit 43cb021

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/cmd/login.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ os::cmd::expect_failure_and_text 'oc get pods' '"system:anonymous" cannot list p
8787
# os::cmd::expect_failure_and_text "oc login '${KUBERNETES_MASTER}' -u test -p test '--config=${templocation}/file' --insecure-skip-tls-verify" 'KUBECONFIG is set to a file that cannot be created or modified'
8888
echo "login warnings: ok"
8989

90+
# login and create serviceaccount and test login and logout with a service account token
91+
os::cmd::expect_success "oc login ${KUBERNETES_MASTER} --certificate-authority='${MASTER_CONFIG_DIR}/ca.crt' -u test-user -p anything --api-version=v1"
92+
os::cmd::expect_success_and_text "oc create sa testserviceaccount" "serviceaccount \"testserviceaccount\" created"
93+
os::cmd::expect_success_and_text "oc login --token=$(oc sa get-token testserviceaccount)" "system:serviceaccount:project-foo:testserviceaccount"
94+
# attempt to logout, expect error from the server, and success removing user token from local config
95+
os::cmd::expect_failure_and_text "oc logout" "Successfully removed user token from local config"
96+
9097
# log in and set project to use from now on
9198
os::cmd::expect_success "oc login --server=${KUBERNETES_MASTER} --certificate-authority='${MASTER_CONFIG_DIR}/ca.crt' -u test-user -p anything"
9299
os::cmd::expect_success 'oc get projects'

0 commit comments

Comments
 (0)