-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_device_mapping.sh
More file actions
120 lines (108 loc) · 3.8 KB
/
test_device_mapping.sh
File metadata and controls
120 lines (108 loc) · 3.8 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
echo "=== Testing Device Mapping Service ==="
echo "Your LFDI: 2D176C15902F9D9732E1960F813A1C3049675A42"
echo ""
# Test 1: Send a MeterReading with an LFDI (highest priority device identifier)
echo "=== Test 1: MeterReading with LFDI device identifier ==="
curl -v --http1.1 \
--cert ./out/my-client-chain.pem \
--key ./out/my-client.key \
--cacert ./out/rootca-chain.pem \
--tlsv1.2 \
--ciphers ECDHE-ECDSA-AES128-GCM-SHA256 \
-H "Content-Type: application/sep+xml" \
-H "Accept: application/sep+xml" \
--insecure \
-d '<MeterReading xmlns="urn:ieee:std:2030.5:ns">
<lfdi>DEVICE001LFDI1234567890ABCDEF1234567890</lfdi>
<value>12345</value>
<timestamp>1234567890</timestamp>
</MeterReading>' \
https://localhost:8443/mr
echo -e "\n\n"
# Test 2: Send a Reading with mRID device identifier
echo "=== Test 2: Reading with mRID device identifier ==="
curl -v --http1.1 \
--cert ./out/my-client-chain.pem \
--key ./out/my-client.key \
--cacert ./out/rootca-chain.pem \
--tlsv1.2 \
--ciphers ECDHE-ECDSA-AES128-GCM-SHA256 \
-H "Content-Type: application/sep+xml" \
-H "Accept: application/sep+xml" \
--insecure \
-d '<Reading xmlns="urn:ieee:std:2030.5:ns">
<mRID>550e8400-e29b-41d4-a716-446655440001</mRID>
<value>67890</value>
<timestamp>1234567891</timestamp>
</Reading>' \
https://localhost:8443/mr
echo -e "\n\n"
# Test 3: Send a UsagePoint with deviceId
echo "=== Test 3: UsagePoint with deviceId ==="
curl -v --http1.1 \
--cert ./out/my-client-chain.pem \
--key ./out/my-client.key \
--cacert ./out/rootca-chain.pem \
--tlsv1.2 \
--ciphers ECDHE-ECDSA-AES128-GCM-SHA256 \
-H "Content-Type: application/sep+xml" \
-H "Accept: application/sep+xml" \
--insecure \
-d '<UsagePoint xmlns="urn:ieee:std:2030.5:ns">
<deviceId>SMART_METER_12345</deviceId>
<description>Main electricity meter</description>
<status>1</status>
</UsagePoint>' \
https://localhost:8443/upt
echo -e "\n\n"
# Test 4: Send an EndDevice with multiple identifiers (test precedence)
echo "=== Test 4: EndDevice with multiple identifiers (test precedence) ==="
curl -v --http1.1 \
--cert ./out/my-client-chain.pem \
--key ./out/my-client.key \
--cacert ./out/rootca-chain.pem \
--tlsv1.2 \
--ciphers ECDHE-ECDSA-AES128-GCM-SHA256 \
-H "Content-Type: application/sep+xml" \
-H "Accept: application/sep+xml" \
--insecure \
-d '<EndDevice xmlns="urn:ieee:std:2030.5:ns">
<serialNumber>SN123456789</serialNumber>
<deviceId>DEVICE_XYZ_999</deviceId>
<lfdi>HIGHPRIORITYLFDI567890ABCDEF1234567890AB</lfdi>
<mRID>550e8400-e29b-41d4-a716-446655440002</mRID>
<deviceCategory>0</deviceCategory>
<enabled>true</enabled>
</EndDevice>' \
https://localhost:8443/edev
echo -e "\n\n"
# Test 5: Send a DERProgram with hwIdentifier
echo "=== Test 5: DERProgram with hwIdentifier ==="
curl -v --http1.1 \
--cert ./out/my-client-chain.pem \
--key ./out/my-client.key \
--cacert ./out/rootca-chain.pem \
--tlsv1.2 \
--ciphers ECDHE-ECDSA-AES128-GCM-SHA256 \
-H "Content-Type: application/sep+xml" \
-H "Accept: application/sep+xml" \
--insecure \
-d '<DERProgram xmlns="urn:ieee:std:2030.5:ns">
<hwIdentifier>HW_INVERTER_ABC123</hwIdentifier>
<description>Solar inverter program</description>
<primacy>1</primacy>
</DERProgram>' \
https://localhost:8443/derp
echo -e "\n\n"
echo "=== Testing Complete ==="
echo ""
echo "What to look for in the logs:"
echo "1. 'Aggregator device mapping' messages"
echo "2. 'Successfully extracted device identifier from aggregator'"
echo "3. 'Successfully stored device mapping' messages"
echo "4. Device extraction metrics"
echo ""
echo "Check Redis for stored mappings:"
echo "redis-cli KEYS 'device_mapping:*'"
echo "redis-cli KEYS 'aggregator_devices:*'"