-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_people.sh
executable file
·83 lines (65 loc) · 2.42 KB
/
test_people.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Cleanup resources
function cleanup {
EXIT_CODE=$?
set +e
docker compose down
exit $EXIT_CODE
}
trap cleanup EXIT
echo "[INTEGRATION TESTS for PEOPLE commands]"
# Start Alfresco
docker compose up -d
echo "Starting Alfresco ..."
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/alfresco/s/api/server)" != "200" ]]; do sleep 5; done'
# Alfresco CLI program location
ALF="../alfresco"
# Configure Alfresco CLI for a local ACS in port 8080 with default credentials (admin/admin)
# ACS must be up & ready before running this script
$ALF config set -s http://localhost:8080/alfresco -u admin -p admin
echo "Credentials stored"
# Get Name for user "admin"
ADMIN_NAME=$($ALF people list | grep admin | awk -F ' ' '{print $2}')
echo "Retrieved admin name using "list": $ADMIN_NAME"
if [[ "$ADMIN_NAME" != "Administrator" ]]; then
echo "Got $ADMIN_NAME but expecting Administrator"
exit -1
fi
# Create user "alfresco"
ALFRESCO_USER_ID=$($ALF people create -i alfresco --password alfresco -f Alfresco -l Hyland -e [email protected] -o id)
echo "Created new user alfresco using "get": $ALFRESCO_USER_ID"
if [[ "$ALFRESCO_USER_ID" != "alfresco" ]]; then
echo "Got $ALFRESCO_USER_ID but expecting alfresco"
exit -1
fi
# Modify user "alfresco"
ALFRESCO_USER_NAME=$($ALF people update -i alfresco -f Hyland | grep alfresco | awk -F ' ' '{print $2}')
echo "Modified user alfresco name using "update": $ALFRESCO_USER_NAME"
ALFRESCO_USER_NAME=$($ALF people get -i alfresco | grep alfresco | awk -F ' ' '{print $2}')
if [[ "$ALFRESCO_USER_NAME" != "Hyland" ]]; then
echo "Got $ALFRESCO_USER_NAME but expecting Hyland"
exit -1
fi
# Get groups from user "alfresco"
ALFRESCO_USER_GROUPS_COUNT=$($ALF people group -i alfresco -o id | wc -l | xargs)
if [[ "$ALFRESCO_USER_GROUPS_COUNT" != "1" ]]; then
echo "Got $ALFRESCO_USER_GROUPS_COUNT but expecting 1"
exit -1
fi
# Remove user "alfresco"
$ALF people delete -i $ALFRESCO_USER_ID
echo "Person $ALFRESCO_USER_ID has been deleted"
# Verify the person has been effectively removed (it will provoke an error)
set +o errexit
GET_NEW_NODE_ERROR=$($ALF people get -i $ALFRESCO_USER_ID)
set -o errexit
if [[ "${GET_NEW_NODE_ERROR}" != *"404"* ]]; then
echo "Got $GET_NEW_NODE_ERROR but expecting 404 (Not Found)"
exit -1
fi
echo "Person $ALFRESCO_USER_ID delete verification ok"
# Stop Alfresco
docker compose down