-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π§βπ» login command - print selected username to avoid ambiguity
- Loading branch information
π₯Hedi Ghediri
committed
Jul 31, 2024
1 parent
015911a
commit a496e21
Showing
9 changed files
with
113 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
# required environment varibale | ||
# CL_PATH | ||
# CL_HOME | ||
# OUTPUT_DIR | ||
|
||
SCRIPT_DIR=${1:-$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )} | ||
|
||
# First copy the dropin packages for test | ||
rm -rf $CL_HOME/dropins | ||
mkdir -p $CL_HOME/dropins | ||
cp -R $SCRIPT_DIR/../packages-src/login $CL_HOME/dropins | ||
|
||
|
||
### | ||
# login without -u | ||
### | ||
RESULT=$(echo | $CL_PATH login -p test-password) # The echo simulates an empty input from the user | ||
echo -e "Actual:\n$RESULT" | ||
EXPECTED_USERNAME_PROMPT="Please enter your user name [$(whoami)]: " | ||
TEST_DESCRIPTION="should prompt '$EXPECTED_USERNAME_PROMPT'" | ||
if ! grep -qF "$EXPECTED_USERNAME_PROMPT" <(echo "$RESULT"); then | ||
echo "KO - $TEST_DESCRIPTION" | ||
exit 1 | ||
else | ||
echo "OK - $TEST_DESCRIPTION" | ||
fi | ||
|
||
RESULT=$($CL_PATH print-credentials) | ||
echo -e "Actual:\n$RESULT" | ||
EXPECTED_USERNAME="CL_USERNAME: $(whoami)" | ||
TEST_DESCRIPTION="should have username $(whoami)" | ||
if ! grep -qF "$EXPECTED_USERNAME" <(echo "$RESULT"); then | ||
echo "KO - $TEST_DESCRIPTION" | ||
exit 1 | ||
else | ||
echo "OK - $TEST_DESCRIPTION" | ||
fi | ||
|
||
|
||
### | ||
# login with -u | ||
### | ||
RESULT=$($CL_PATH login -u test-user -p test-password) | ||
echo -e "Actual:\n$RESULT" | ||
EXPECTED_USERNAME_PROMPT="Please enter your user name [test-user]: " | ||
TEST_DESCRIPTION="should prompt '$EXPECTED_USERNAME_PROMPT'" | ||
if ! grep -qF "$EXPECTED_USERNAME_PROMPT" <(echo "$RESULT"); then | ||
echo "KO - $TEST_DESCRIPTION" | ||
exit 1 | ||
else | ||
echo "OK - $TEST_DESCRIPTION" | ||
fi | ||
|
||
RESULT=$($CL_PATH print-credentials) | ||
echo -e "Actual:\n$RESULT" | ||
EXPECTED_USERNAME="CL_USERNAME: test-user" | ||
TEST_DESCRIPTION="should have username test-user" | ||
if ! grep -qF "$EXPECTED_USERNAME" <(echo "$RESULT"); then | ||
echo "KO - $TEST_DESCRIPTION" | ||
exit 1 | ||
else | ||
echo "OK - $TEST_DESCRIPTION" | ||
fi |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
{ | ||
"pkgName": "bonjour", | ||
"pkgName": "print-credentials", | ||
"version": "1.0.0", | ||
"cmds": [ | ||
{ | ||
"name": "bonjour-consent", | ||
"name": "print-credentials-with-consent", | ||
"type": "executable", | ||
"short": "print bonjour from command launcher", | ||
"executable": "{{.PackageDir}}/bonjour.{{if eq .Os \"windows\"}}bat{{else}}sh{{end}}", | ||
"short": "print credentials from command launcher", | ||
"executable": "{{.PackageDir}}/print-credentials.{{if eq .Os \"windows\"}}bat{{else}}sh{{end}}", | ||
"args": [], | ||
"requiredFlags": [ | ||
"name\t n\t greeting name", | ||
"language\t l\tgreeting language" | ||
], | ||
"checkFlags": true, | ||
"requestedResources": [ "USERNAME", "PASSWORD", "AUTH_TOKEN" ] | ||
}, | ||
{ | ||
"name": "print-credentials", | ||
"type": "executable", | ||
"short": "print credentials from command launcher", | ||
"executable": "{{.PackageDir}}/print-credentials.{{if eq .Os \"windows\"}}bat{{else}}sh{{end}}", | ||
"args": [], | ||
"requiredFlags": [ | ||
"name\t n\t greeting name", | ||
"language\t l\tgreeting language" | ||
], | ||
"checkFlags": true | ||
} | ||
] | ||
} |
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,5 @@ | ||
@ECHO off | ||
|
||
ECHO CL_USERNAME: %CL_USERNAME% | ||
ECHO CL_PASSWORD: %CL_PASSWORD% | ||
ECHO CL_AUTH_TOKEN: %CL_AUTH_TOKEN% |
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,5 @@ | ||
#!/bin/sh | ||
|
||
echo "CL_USERNAME: $CL_USERNAME" | ||
echo "CL_PASSWORD: $CL_PASSWORD" | ||
echo "CL_AUTH_TOKEN: $CL_AUTH_TOKEN" |