Repository navigation
Expand file tree
/
Copy pathglance_schemas_test.sh
More file actions
executable file
·88 lines (75 loc) · 2.22 KB
/
Copy pathglance_schemas_test.sh
File metadata and controls
executable file
·88 lines (75 loc) · 2.22 KB
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
84
85
86
87
88
#!/bin/bash
# Glance schema endpoints test
# Tests member and members schema endpoints
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Base URLs
AUTH_URL="${OS_AUTH_URL:-http://localhost:5001/v3}"
GLANCE_URL="${OS_IMAGE_URL:-http://localhost:9292}"
echo "=== Glance Schema Endpoints Test ==="
# Get auth token
echo "Authenticating..."
TOKEN=$(curl -s -i -X POST "$AUTH_URL/auth/tokens" \
-H "Content-Type: application/json" \
-d '{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "admin",
"domain": {"name": "Default"},
"password": "secret"
}
}
},
"scope": {
"project": {
"name": "default",
"domain": {"name": "Default"}
}
}
}
}' | grep -i '^x-subject-token' | cut -d' ' -f2 | tr -d '\r\n')
if [ -z "$TOKEN" ]; then
echo -e "${RED}FAIL${NC}: Authentication failed"
exit 1
fi
echo -e "${GREEN}OK${NC}: Authenticated"
# Test 1: GET /v2/schemas/member
echo "Test 1: GET member schema"
RESPONSE=$(curl -s -X GET "$GLANCE_URL/v2/schemas/member" \
-H "X-Auth-Token: $TOKEN")
echo "$RESPONSE" | jq -e '.name == "member"' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}PASS${NC}: Member schema has correct name"
else
echo -e "${RED}FAIL${NC}: Member schema name incorrect"
fi
echo "$RESPONSE" | jq -e '.properties' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}PASS${NC}: Member schema has properties"
else
echo -e "${RED}FAIL${NC}: Member schema missing properties"
fi
# Test 2: GET /v2/schemas/members
echo "Test 2: GET members schema"
RESPONSE=$(curl -s -X GET "$GLANCE_URL/v2/schemas/members" \
-H "X-Auth-Token: $TOKEN")
echo "$RESPONSE" | jq -e '.name == "members"' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}PASS${NC}: Members schema has correct name"
else
echo -e "${RED}FAIL${NC}: Members schema name incorrect"
fi
echo "$RESPONSE" | jq -e '.properties' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}PASS${NC}: Members schema has properties"
else
echo -e "${RED}FAIL${NC}: Members schema missing properties"
fi
echo "=== Test Summary ==="
echo "All Glance schema tests completed"