/
TS_13_Tests.py
232 lines (185 loc) · 10.9 KB
/
TS_13_Tests.py
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import unittest
import iotdm_api
from onem2m_xml_protocols.ae import ae
from onem2m_xml_protocols.container import cnt
from onem2m_xml_protocols.contentinstance import cin
from onem2m_xml_protocols.subscription import sub
from onem2m_xml_protocols.remotecse import csr
from onem2m_xml_protocols.acp import acp
from onem2m_xml_protocols.group import grp
from onem2m_xml_protocols.node import nod
from onem2m_xml_protocols.firmware import fwr
class TS13(unittest.TestCase):
def setUp(self):
print "Setting up tests"
def tearDown(self):
print "Tearing down tests"
def test_0_CSE_Provisioning(self):
iotdm_api.restConf('http://localhost', 'ODL-oneM2M-Cse', 'admin', 'admin')
def test_TD_M2M_NH_01_Retrieve_CSEBase(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_02_Create_RemoteCSE(self):
remoteCSE = csr()
remoteCSE.set_csi("CSE3219")
remoteCSE.set_rr(True)
remoteCSE.set_rn("RemoteCSE")
payload = remoteCSE.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 16, payload, origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_03_Retrieve_RemoteCSE(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/RemoteCSE", origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_04_Update_RemoteCSE(self):
remoteCSE = csr()
payload = remoteCSE.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse", payload, origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_05_Delete_RemoteCSE(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/RemoteCSE", origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_06_Create_AE(self):
AE = ae()
AE.set_api("Nk836-t071-fc022")
AE.set_rr(True)
AE.set_rn("TestAE")
payload = AE.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 2, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_07_Retrieve_AE(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_08_Update_AE(self):
AE = ae()
AE.set_acpi(["ODL-oneM2M-Cse/TestAE/TestACP"])
payload = AE.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", payload, origin="admin", requestID="12345")
def test_TD_M2M_NH_09_Delete_AE(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_10_Create_Container(self):
container = cnt()
container.set_rn("TestContainer")
payload = container.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", 3, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_11_Retrieve_Container(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_12_Update_Container(self):
container = cnt()
payload = container.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_13_Delete_Container(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_14_Create_ContentInstance(self):
con_instance = cin()
con_instance.set_con("some data")
con_instance.set_rn("TestContentInstance")
payload = con_instance.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 4, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_15_Retrieve_ContentInstance(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestContentInstance", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_17_Delete_ContentInstance(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestContentInstance", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_18_Discovery_of_all_resources(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse?fu=1", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_19_Discovery_with_label_filter_criteria(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse?fu=1&lbl=key1", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_20_Discovery_with_limit_filter_criteria(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse?fu=1&lim=2", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_21_Discovery_with_multiple_filter_criteria(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse?fu=1&lbl=key1&lbl=key2", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_22_Create_Subscription(self):
subscription = sub()
subscription.set_nu(["http://localhost"])
subscription.set_rn("TestSubscription")
payload = subscription.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 23, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_23_Retrieve_Subscription(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_24_Update_Subscription(self):
subscription = sub()
payload = subscription.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_25_Delete_Subscription(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_26_Create_AccessControlPolicy(self):
accessControlRule1 = acr()
accessControlRule1.set_acor(["*"])
accessControlRule1.set_acop(63)
pv_payload = accessControlRule1.to_JSON()
accessControlRule2 = acr()
accessControlRule2.set_acor(["admin"])
accessControlRule2.set_acop(63)
pvs_payload = accessControlRule2.to_JSON()
accessControlPolicy = acp()
accessControlPolicy.set_pv(pv_payload)
accessControlPolicy.set_pvs(pvs_payload)
accessControlPolicy.set_rn("TestACP")
payload = accessControlPolicy.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", 1, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_27_Retrieve_AccessControlPolicy(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestACP", origin="admin", requestID="12345")
def test_TD_M2M_NH_28_Update_AccessControlPolicy(self):
accessControlRule1 = acr()
accessControlRule1.set_acor(["admin"])
accessControlRule1.set_acop(63)
pv_payload = accessControlRule1.to_JSON()
accessControlRule2 = acr()
accessControlRule2.set_acor(["admin"])
accessControlRule2.set_acop(63)
pvs_payload = accessControlRule2.to_JSON()
accessControlPolicy = acp()
accessControlPolicy.set_pv(pv_payload)
accessControlPolicy.set_pvs(pvs_payload)
accessControlPolicy.set_rn("TestACP")
payload = accessControlPolicy.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestACP", payload, origin="admin", requestID="12345")
def test_TD_M2M_NH_29_Delete_AccessControlPolicy(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestACP", origin="admin", requestID="12345")
#Insufficient Access Rights
def test_TD_M2M_NH_30_Unauthorized_operation(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_31_Create_Group(self):
group = grp()
group.set_mt(2)
group.set_mnm(10)
group.set_mid(["a"])
group.set_rn("TestGroup")
payload = group.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 9, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_32_Retrieve_Group(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestGroup", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_33_Update_Group(self):
group = grp()
payload = group.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestGroup", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_34_Delete_Group(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestGroup", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_35_Create_Node(self):
node = nod()
node.set_ni("a")
node.set_rn("TestNode")
payload = node.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 14, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_36_Retrieve_Node(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_37_Update_Node(self):
node = nod()
payload = node.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_38_Delete_Node(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_05_Create_MgmtObj(self):
firmware = fwr()
firmware.set_mgd("1001")
firmware.set_ud(True)
firmware.set_vr("1")
firmware.set_url("localhost")
firmware.set_fwnnam("TestFirmware")
firmware.set_rn("TestFirmware")
payload = firmware.to_JSON()
iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", 13, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_06_Update_MgmtObj(self):
firmware = fwr()
firmware.set_mgd("1001")
firmware.set_ud(False)
payload = firmware.to_JSON()
iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_07_Retrieve_MgmtObj(self):
iotdm_api.retrieve("coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_08_Delete_MgmtObj(self):
iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", origin="CSE3219/C9886", requestID="12345")
if __name__ == '__main__':
unittest.main()