Merge pull request #26354 from KingEmet/fixbranch
make GetAll use client.List as the source of truth Upstream-commit: 67b85f9d26f1b0b2b240f2d794748fac0f45243c Component: engine
This commit is contained in:
@ -2,29 +2,51 @@
|
||||
|
||||
set -e
|
||||
|
||||
listFile=shell_test_list.json
|
||||
|
||||
case $1 in
|
||||
"store")
|
||||
in=$(</dev/stdin)
|
||||
server=$(echo "$in" | jq --raw-output ".ServerURL" | sha1sum - | awk '{print $1}')
|
||||
server=$(echo "$in" | jq --raw-output ".ServerURL")
|
||||
serverHash=$(echo "$server" | sha1sum - | awk '{print $1}')
|
||||
|
||||
username=$(echo "$in" | jq --raw-output ".Username")
|
||||
password=$(echo "$in" | jq --raw-output ".Secret")
|
||||
echo "{ \"Username\": \"${username}\", \"Secret\": \"${password}\" }" > $TEMP/$server
|
||||
echo "{ \"Username\": \"${username}\", \"Secret\": \"${password}\" }" > $TEMP/$serverHash
|
||||
# add the server to the list file
|
||||
if [[ ! -f $TEMP/$listFile ]]; then
|
||||
echo "{ \"${server}\": \"${username}\" }" > $TEMP/$listFile
|
||||
else
|
||||
list=$(<$TEMP/$listFile)
|
||||
echo "$list" | jq ". + {\"${server}\": \"${username}\"}" > $TEMP/$listFile
|
||||
fi
|
||||
;;
|
||||
"get")
|
||||
in=$(</dev/stdin)
|
||||
server=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||
if [[ ! -f $TEMP/$server ]]; then
|
||||
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||
if [[ ! -f $TEMP/$serverHash ]]; then
|
||||
echo "credentials not found in native keychain"
|
||||
exit 1
|
||||
fi
|
||||
payload=$(<$TEMP/$server)
|
||||
payload=$(<$TEMP/$serverHash)
|
||||
echo "$payload"
|
||||
;;
|
||||
"erase")
|
||||
in=$(</dev/stdin)
|
||||
server=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||
rm -f $TEMP/$server
|
||||
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||
rm -f $TEMP/$serverHash
|
||||
|
||||
# Remove the server from the list
|
||||
list=$(<$TEMP/$listFile)
|
||||
echo "$list" | jq "del(.\"${in}\")" > $TEMP/$listFile
|
||||
;;
|
||||
"list")
|
||||
if [[ ! -f $TEMP/$listFile ]]; then
|
||||
echo "{}"
|
||||
else
|
||||
payload=$(<$TEMP/$listFile)
|
||||
echo "$payload"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "unknown credential option"
|
||||
|
||||
Reference in New Issue
Block a user