Skip to content

Commit

Permalink
Merge pull request #2715 from sf2ne/sfaruk/tokenval
Browse files Browse the repository at this point in the history
Node and Agbot Tokens Updated to match new password constraints
  • Loading branch information
dabooz authored Aug 6, 2021
2 parents 612d5d7 + 32ac4a7 commit acd1541
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ AGBOT_API ?= http://agbot:8080
AGBOT2_API ?= http://agbot2:8080
AGBOT_SAPI_URL ?= https://agbot:8083
AGBOT_NAME ?= agbot
AGBOT_TOKEN ?= abcdefg
AGBOT_TOKEN ?= Abcdefghijklmno1

# exchange
DOCKER_EXCH_CNAME = exchange-api
Expand Down
4 changes: 2 additions & 2 deletions test/gov/add_test_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ NUM=1

while :
do
ADD=$(curl -sLX PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"abcdefg","name":"anaxdev${NUM}","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1Ccj6TOUxvVUoIlqyrZUjR3RSdOiBWbWUsgbkhWHcWMNMxD7Y/sLqTl1kZCayFE+bqBvdRmJ4KV7p2g4i/Q+IhBk6Ea+rjVuk5Rwq1OXG2xNRCDX/I9Xc6udoC5qFjf0WG9PAGAqkTSkCpK2wDEvSNAEI8nEXh4l4fPQTCGPDiXxZNCdvi3GAxdw3FN6H89CQRQ7MwO/QiDg11bK5hHb0pVhMOmoYUxFxKeJMEF0kg88dbDrty1lrhI/pf+ZzHZ1BqjDSrazpYieCU2Et2cowsiAyBBTRrIIxy4n5pzWPfAay5tBx1UJDzbJPk2ut1yGWMrHhk+QpXpqgXDBnAfWCQIDAQAB","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an12345${NUM}")
ADD=$(curl -sLX PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev${NUM}","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1Ccj6TOUxvVUoIlqyrZUjR3RSdOiBWbWUsgbkhWHcWMNMxD7Y/sLqTl1kZCayFE+bqBvdRmJ4KV7p2g4i/Q+IhBk6Ea+rjVuk5Rwq1OXG2xNRCDX/I9Xc6udoC5qFjf0WG9PAGAqkTSkCpK2wDEvSNAEI8nEXh4l4fPQTCGPDiXxZNCdvi3GAxdw3FN6H89CQRQ7MwO/QiDg11bK5hHb0pVhMOmoYUxFxKeJMEF0kg88dbDrty1lrhI/pf+ZzHZ1BqjDSrazpYieCU2Et2cowsiAyBBTRrIIxy4n5pzWPfAay5tBx1UJDzbJPk2ut1yGWMrHhk+QpXpqgXDBnAfWCQIDAQAB","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an12345${NUM}")

echo $ADD

HB=$(curl -sLX POST --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/an12345${NUM}:abcdefg" -d '{"changeId":0,"maxRecords":1000,"orgList":["userdev"]}' "${EXCH_URL}/orgs/userdev/changes")
HB=$(curl -sLX POST --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/an12345${NUM}:Abcdefghijklmno1" -d '{"changeId":0,"maxRecords":1000,"orgList":["userdev"]}' "${EXCH_URL}/orgs/userdev/changes")

# echo $HB

Expand Down
4 changes: 2 additions & 2 deletions test/gov/gov-combined.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function set_exports {
export DEVICE_ID="an12345"
export DEVICE_NAME="anaxdev1"
export DEVICE_ORG="[email protected]"
export TOKEN="abcdefg"
export TOKEN="Abcdefghijklmno1"

export HZN_AGENT_PORT=8510
export ANAX_API="http://localhost:${HZN_AGENT_PORT}"
Expand Down Expand Up @@ -170,7 +170,7 @@ then
export HZN_AGENT_PORT=8510
export ANAX_API="http://localhost:${HZN_AGENT_PORT}"
export EXCH="${EXCH_APP_HOST}"
export TOKEN="abcdefg"
export TOKEN="Abcdefghijklmno1"

if [ ${CERT_LOC} -eq "1" ]; then
export HZN_MGMT_HUB_CERT_PATH="/certs/css.crt"
Expand Down
14 changes: 7 additions & 7 deletions test/gov/hzn_reg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fi

## test registering node with both flags and positional arguments, conflict
echo -e "${PREFIX} Testing 'hzn register' with conflicting inputs"
cmd="hzn register -u $USERDEV_ADMIN_AUTH -n an12345:abcdefghijk -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json [email protected] sns"
cmd="hzn register -u $USERDEV_ADMIN_AUTH -n an12345:Abcdefghijklmno1 -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json [email protected] sns"
echo -e "$cmd"
ret=`$cmd 2>&1`
if [ $? -eq 0 ]; then
Expand All @@ -208,13 +208,13 @@ fi

## test registering policy based node, update token
echo -e "${PREFIX} Testing 'hzn register' with policy."
cmd="hzn register -u $USERDEV_ADMIN_AUTH -n an12345:abcdefghijk -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json"
cmd="hzn register -u $USERDEV_ADMIN_AUTH -n an12345:Abcdefghijklmno1 -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json"
reg_node "$cmd"
verify_agreements "userdev" "userdevadmin:userdevadminpw"

## test register while the node is registered
echo -e "${PREFIX} Testing 'hzn register' while the node is registered."
ret=$(hzn register -u $USERDEV_ADMIN_AUTH -n an12345:abcdefg -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json 2>&1)
ret=$(hzn register -u $USERDEV_ADMIN_AUTH -n an12345:Abcdefghijklmno1 -o userdev -f /tmp/reg_userinput.json --policy /tmp/node_policy.json 2>&1)
if [ $? -eq 0 ]; then
echo -e "${PREFIX} 'hzn register' should have failed because the node is registered already."
exit 1
Expand All @@ -231,21 +231,21 @@ unreg_node
hzn exchange -u e2edevadmin:e2edevadminpw -o [email protected] node remove an12345 -f

echo -e "${PREFIX} Testing 'hzn register' with pattern sns."
cmd="hzn register -u e2edevadmin:e2edevadminpw -n an12345:abcdefg -f /tmp/reg_userinput.json -o [email protected] -p [email protected]/sns"
cmd="hzn register -u e2edevadmin:e2edevadminpw -n an12345:Abcdefghijklmno1 -f /tmp/reg_userinput.json -o [email protected] -p [email protected]/sns"
reg_node "$cmd"
verify_agreements "[email protected]" "e2edevadmin:e2edevadminpw"

## register pattern sns using positional argument, node already exists
unreg_node
echo -e "${PREFIX} Testing 'hzn register' with pattern sns using positional argument."
cmd="hzn register -n [email protected]/an12345:abcdefg -f /tmp/reg_userinput.json [email protected] sns"
cmd="hzn register -n [email protected]/an12345:Abcdefghijklmno1 -f /tmp/reg_userinput.json [email protected] sns"
reg_node "$cmd"
verify_agreements "[email protected]" "e2edevadmin:e2edevadminpw"

## test registering node with both sns pattern and policy
unreg_node
echo -e "${PREFIX} Testing 'hzn register' with both pattern sns and policy."
cmd="hzn register -n an12345:abcdefg -o [email protected] -f /tmp/reg_userinput.json -p sns --policy /tmp/node_policy.json"
cmd="hzn register -n an12345:Abcdefghijklmno1 -o [email protected] -f /tmp/reg_userinput.json -p sns --policy /tmp/node_policy.json"
reg_node "$cmd"

# make sure node has pattern associated.
Expand All @@ -261,7 +261,7 @@ verify_agreements "[email protected]" "e2edevadmin:e2edevadminpw"
unreg_node
export [email protected]
echo -e "${PREFIX} Testing 'hzn register' with pattern sall with HZN_ORG_ID"
cmd="hzn register -n an12345:abcdefg -f /tmp/reg_userinput_all.json -p sall"
cmd="hzn register -n an12345:Abcdefghijklmno1 -f /tmp/reg_userinput_all.json -p sall"
reg_node "$cmd"

ORG_ID="[email protected]" ADMIN_AUTH="e2edevadmin:e2edevadminpw" ./verify_agreements.sh
Expand Down
18 changes: 9 additions & 9 deletions test/gov/init_exchange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ echo "$CR8IBM"

# Register agreement bot user in the exchange
echo "Creating Agbot user..."
CR8AGBOT=$(curl -sLX POST $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "root/root:${EXCH_ROOTPW}" -d '{"password":"agbot1pw","email":"me%40gmail.com","admin":false}' "${EXCH_URL}/orgs/IBM/users/agbot1" | jq -r '.msg')
CR8AGBOT=$(curl -sLX POST $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "root/root:${EXCH_ROOTPW}" -d '{"password":"Abcdefghijklmno1","email":"me%40gmail.com","admin":false}' "${EXCH_URL}/orgs/IBM/users/agbot1" | jq -r '.msg')
echo "$CR8AGBOT"

# Register users in the exchange
Expand All @@ -156,37 +156,37 @@ CR8UANAX=$(curl -sLX POST $CERT_VAR --header 'Content-Type: application/json' --
echo "$CR8UANAX"

echo "Registering Anax device1..."
REGANAX1=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/an12345" | jq -r '.msg')
REGANAX1=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/an12345" | jq -r '.msg')
echo "$REGANAX1"

echo "Registering Anax device2..."
REGANAX2=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/an54321" | jq -r '.msg')
REGANAX2=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/an54321" | jq -r '.msg')
echo "$REGANAX2"

# register an anax devices for userdev in order to test the case where the pattern is from a different org than the device org.
echo "Registering Anax device1 in userdev org..."
REGUANAX1=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an12345" | jq -r '.msg')
REGUANAX1=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an12345" | jq -r '.msg')
echo "$REGUANAX1"

echo "Registering Anax device2 in userdev org..."
REGUANAX2=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an54321" | jq -r '.msg')
REGUANAX2=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/an54321" | jq -r '.msg')
echo "$REGUANAX2"

echo "Registering Anax device1 in customer org..."
REGANAX1C=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "Customer1/icpadmin:icpadminpw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/Customer1/nodes/an12345" | jq -r '.msg')
REGANAX1C=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "Customer1/icpadmin:icpadminpw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/Customer1/nodes/an12345" | jq -r '.msg')
echo "$REGANAX1C"

DEVICE_NUM=6
NUM_AGENTS=$((${MULTIAGENTS}+$DEVICE_NUM))
while [ ${DEVICE_NUM} -lt ${NUM_AGENTS} ]; do
echo "Registering Anax device${DEVICE_NUM}..."
REGANAXMUL=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
REGANAXMUL=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "[email protected]/anax1:anax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/[email protected]/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
echo "$REGANAXMUL"
echo "Registering Anax device${DEVICE_NUM} in userdev org..."
REGUANAXMULU=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
REGUANAXMULU=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "userdev/useranax1:useranax1pw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/userdev/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
echo "$REGUANAXMULU"
echo "Registering Anax device${DEVICE_NUM} in customer org..."
REGANAXMULC=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "Customer1/icpadmin:icpadminpw" -d '{"token":"abcdefg","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/Customer1/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
REGANAXMULC=$(curl -sLX PUT $CERT_VAR --header 'Content-Type: application/json' --header 'Accept: application/json' -u "Customer1/icpadmin:icpadminpw" -d '{"token":"Abcdefghijklmno1","name":"anaxdev","registeredServices":[],"msgEndPoint":"","softwareVersions":{},"publicKey":"","pattern":"","arch":"${ARCH}"}' "${EXCH_URL}/orgs/Customer1/nodes/anaxdevice${DEVICE_NUM}" | jq -r '.msg')
echo "$REGANAXMULC"
let DEVICE_NUM=DEVICE_NUM+1
done
Expand Down
2 changes: 1 addition & 1 deletion test/gov/start_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# export DEVICE_NAME="anaxdev1"
# export ANAX_API="http://localhost:${HZN_AGENT_PORT}"
# export EXCH="${EXCH_APP_HOST}"
# export TOKEN="abcdefg"
# export TOKEN="Abcdefghijklmno1"
# This env var can be changed to whatever pattern you want to run.
# export PATTERN="sall"

Expand Down
4 changes: 2 additions & 2 deletions test/gov/sync_service_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ then
fi

# Test what happens when a valid node tries to access an API
KNODE=$(curl -sLX GET -w "%{http_code}" $CERT_VAR -u userdev/susehello/an12345:abcdefg "${CSS_URL}/api/v1/destinations/userdev")
KNODE=$(curl -sLX GET -w "%{http_code}" $CERT_VAR -u userdev/susehello/an12345:Abcdefghijklmno1 "${CSS_URL}/api/v1/destinations/userdev")

if [ "$KNODE" != "Unauthorized403" ]
then
Expand Down Expand Up @@ -1019,7 +1019,7 @@ verifyUserAccessForPublicObject $USER_ORG $USER_REG_USERNAME $USER_REG_USERPWD $

# node [email protected]/an12345 has READ and WRITE access to all object types in [email protected] org
NODE_ID="an12345"
NODE_TOKEN="abcdefg"
NODE_TOKEN="Abcdefghijklmno1"
TARGET_NUM_OBJS=0
testUserNotHaveAccessToPrivateObjects $USER_ORG $NODE_ID $NODE_TOKEN $TARGET_NUM_OBJS "test" "test_user_access"
verifyUserAccessForPublicObject $USER_ORG $NODE_ID $NODE_TOKEN $PUBLIC_OBJ_ORG $PUBLIC_OBJ_TYPE $PUBLIC_OBJ_ID
Expand Down

0 comments on commit acd1541

Please sign in to comment.