OneM2M_Testcases_CSE_Release_2_SEC_STF531.ttcn 8.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
 *  Copyright Notification
 *  No part of this document may be reproduced, in an electronic retrieval system or otherwise, except as authorized by written permission.
 *  The copyright and the foregoing restriction extend to reproduction in all media.
 *  © 2016, oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TSDSI, TTA, TTC).
 *  All rights reserved.
 *  
 *  @author     ETSI
 *  @version    $URL: https://oldforge.etsi.org/svn/oneM2M/branches/Release1/ttcn/OneM2M_Testcases.ttcn $
 *              $Id: OneM2M_Testcases.ttcn 347 2017-08-11 08:48:20Z reinaortega $
 *  @desc       Module containing test cases for oneM2M
 *
 */
module OneM2M_Testcases_CSE_Release_2_SEC_STF531 {

16 17
	import from LibCommon_BasicTypesAndValues all;

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
	import from OneM2M_TestSystem all;
	import from OneM2M_Templates all;
	import from OneM2M_Types all;//{type XSD.ID};
	import from OneM2M_TypesAndValues all;
	import from OneM2M_Pixits all;
	import from LibCommon_Time all;
	import from OneM2M_Pics all;
	import from OneM2M_Functions all;
	import from OneM2M_PermutationFunctions all;
	import from XSD all;
	
	//Demos used for validation purposes
	group oneM2M_demos {
	
		group helpingTestCases {//These are not part of the test suite, just for verification purposes
			
			testcase TC_DELETE_RESOURCES() runs on AeSimu system CseSystem {
				
				timer t_ac := 5.0;
				var integer i; 
				var XSD.ID v_resourceAddress;
				var RequestPrimitive v_request;
				map(self:mcaPort, system:mcaPort); 
					
				for (i:=0; i<lengthof(PX_RESOURCES_TO_BE_DELETED); i:= i+1) {  
					
					v_resourceAddress := f_getResourceAddress() & "/" & PX_RESOURCES_TO_BE_DELETED[i]; 
						
					v_request := valueof(m_delete(v_resourceAddress, PX_SUPER_AE_ID));
					    
					mcaPort.send(m_request(v_request));
					
					t_ac.start;
					alt {
						[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
							t_ac.stop;
							log(__SCOPE__ & ":Resource deleted");
							setverdict(pass);
						}
						[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
							t_ac.stop;
							log(__SCOPE__ & ":Error while deleting resource");
							setverdict(fail);
						}
						[] mcaPort.receive {
							t_ac.stop;
							log(__SCOPE__ & ":Unexpected message received");
							setverdict(inconc);
						}
						[] t_ac.timeout {
							log(__SCOPE__ & ":No answer while deleting resource");
							setverdict(inconc);
						}	
					}	
				}
			
				unmap(self:mcaPort, system:mcaPort); 
				stop;
			}	
		
		}//end group helpingTestCases
	
	}//end group oneM2M_demos
	
82 83 84 85 86 87 88 89
	group AE {
	
		group ESCertKE {
		
		}
	
	}
	
90 91
	group CSE {
		
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
		group DAS {
			
			testcase TC_CSE_DAS_BV_001() runs on AeSimu system CseSystem {
				
				var MsgIn v_response;
				var RequestPrimitive v_requestRetrive;
				var PrimitiveContent v_primitiveContentResponse;
				var integer v_ae1Index, v_contIndex, v_auxAcpIndex;
				var DynAuthDasRequest v_dasRequest;
								
				//Test component configuration
				f_cf01Up();
				
				//Preamble (initial conditions)
				v_auxAcpIndex := f_cse_preamble_createAcpAux( - , int61);
				v_ae1Index := f_cse_preamble_registerAe();
				v_contIndex := f_cse_createResource_withAcpAux(int3, m_createContainerBase, v_ae1Index);
				//TODO => ? and the IUT having registered at least one DAS AE
				
				//TestBody
				v_requestRetrive.to_ := f_getResourceAddress(v_contIndex);
				v_requestRetrive.from_ := f_getOriginator(v_ae1Index);
				
				v_primitiveContentResponse.responsePrimitive.to_ := f_getResourceAddress(v_contIndex);
				v_primitiveContentResponse.responsePrimitive.from_ := f_getOriginator(v_ae1Index);
				
				v_dasRequest.originator := f_getOriginator(v_ae1Index);
				v_dasRequest.targetedResourceType := int3;
				v_dasRequest.operation := int2;
				v_primitiveContentResponse.securityInfo := mw_contentSecurityInfo(int1, - , v_dasRequest);
				
			  	mcaPort.send(m_request(v_requestRetrive));
				
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000,v_primitiveContentResponse)))-> value v_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__ & ": DAS Request received successfully");	
					} 	
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ": Wrong SecurityInfo (securityInfoType ¦¦ dasRequest ) Message received");
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ": Wrong response status code");
					}		
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__& ":INFO: Timeout while awaiting the reception of a message");
					}
				}
				
				f_cse_postamble_deleteResources();
				f_cf01Down();		
			}			
		}
		
		
150
		group ESCertKE {
151
			
152
			testcase TC_CSE_ESC_BV_001() runs on CseSimu system CseSystem {
153
				var MsgIn v_response;
154 155
				var RequestPrimitive v_requestNotify;
				var PrimitiveContent v_primitiveContentResponse;
156
				
157
				//Test component configuration
158
				f_cf02UpCse1();
159 160

				// Test adapter configuration
161
				
162
				// Preamble (initial conditions)
163
				vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
164
				//Preconfiguration => "and the IUT has been provisioned with private key and certificate"
165 166
				
				//TestBody
167 168
				v_requestNotify.to_ := f_getResourceAddress(vc_remoteCseIndex);
				v_requestNotify.from_ := PX_CSE1_ID;
169
				v_requestNotify.primitiveContent := {securityInfo := m_contentSecurityInfo(int6)};
170
				
171 172 173 174
				//Base 64 representation of message (https://www.base64encode.org/) ? ClientHello
				v_requestNotify.primitiveContent.securityInfo.escertkeMessage := str2oct("Q2xpZW50SGVsbG8=");	
				//msg ? ServerHello, Certificate*, ServerKeyExchange*, CertificateRequest*, ServerHelloDone			
 				v_primitiveContentResponse.securityInfo := mw_contentSecurityInfo(int6, str2oct("U2VydmVySGVsbG8sIENlcnRpZmljYXRlKiwgU2VydmVyS2V5RXhjaGFuZ2UqLCBDZXJ0aWZpY2F0ZVJlcXVlc3QqLCBTZXJ2ZXJIZWxsb0RvbmU="));
175 176 177 178
 				
 				mccPort.send(m_request(v_requestNotify));
			 	tc_ac.start;
				alt {
179
					[] mccPort.receive(mw_response(mw_responsePrimitive(int2000,v_primitiveContentResponse)))-> value v_response {
180
						tc_ac.stop;
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
						setverdict(pass, __SCOPE__ & ": ESCertKE Message 2 received successfully");	
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ": Wrong SecurityInfo (securityInfoType ¦¦ escertkeMessage ) Message received");
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ": Wrong response status code");
					}				
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__& ":INFO: Timeout while awaiting the reception of a message");
					}
				}		
						
				f_cse_postamble_deleteResourcesCSE();
				f_cf02DownCseSimuMaster();
			}
			
			testcase TC_CSE_ESC_BV_002() runs on CseSimu system CseSystem {
				var MsgIn v_response;
				var RequestPrimitive v_requestNotify;
				var PrimitiveContent v_primitiveContentResponse;
				
				//Test component configuration
				f_cf02UpCse1();

				// Test adapter configuration
				
				// Preamble (initial conditions)
				vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
				f_handShake();
				//Preconfiguration => "and the IUT has been provisioned with private key and certificate"
				
				//TestBody
				v_requestNotify.to_ := f_getResourceAddress(vc_remoteCseIndex);
				v_requestNotify.from_ := PX_CSE1_ID;
				v_requestNotify.primitiveContent := {securityInfo := m_contentSecurityInfo(int6)};
				
220 221 222 223
				//TODO Base 64 representation of message ? Certificate*, ClientKeyExchange, CertificateVerify*, [ChangeCipherSpec], Finished
				v_requestNotify.primitiveContent.securityInfo.escertkeMessage := str2oct("Q2VydGlmaWNhdGUqLCBDbGllbnRLZXlFeGNoYW5nZSwgQ2VydGlmaWNhdGVWZXJpZnkqLCBbQ2hhbmdlQ2lwaGVyU3BlY10sIEZpbmlzaGVk");
				// Msg: ? [ChangeCipherSpec], Finished
				v_primitiveContentResponse.securityInfo := mw_contentSecurityInfo(int6, str2oct("W0NoYW5nZUNpcGhlclNwZWNdLCBGaW5pc2hlZA=="));
224 225 226 227 228 229
				mccPort.send(m_request(v_requestNotify));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitive(int2000,v_primitiveContentResponse)))-> value v_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__ & ": ESCertKE Message 4 received successfully");	
230 231 232
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
233
						setverdict(fail, __SCOPE__ & ": Wrong SecurityInfo (securityInfoType ¦¦ escertkeMessage ) Message received");
234 235 236 237 238 239
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ": Wrong response status code");
					}				
					[] tc_ac.timeout {
240
						setverdict(inconc, __SCOPE__& ":INFO: Timeout while awaiting the reception of a message");
241 242 243
					}
				}		
						
244 245
				f_cse_postamble_deleteResourcesCSE();
				f_cf02DownCseSimuMaster();
246 247
			}
		
248
		} // end of group ESCertKE
249 250 251 252 253
			
	}//end group CSE

	
}