Commit f68487c4 authored by YannGarcia's avatar YannGarcia
Browse files

Finalyze support of titan-test-system-framework

parent 9ce69903
......@@ -13,97 +13,14 @@
module LibItsCommon_Functions {
// LibCommon
// import from LibCommon_Sync all;
// import from LibCommon_VerdictControl all;
import from LibCommon_BasicTypesAndValues all;
// LibIts
import from LibItsCommon_Pixits all;
import from ITS_Container language "ASN.1:1997" all;
// import from DSRC language "ASN.1:1997" all;
group generalFunctions {
/**
* @desc function to generate integer random values
*
* @see ttcn-3 - rnd()
* @param p_lowerbound lowest number in range
* @param p_upperbound highest number in range
* @return random integer
*
*/
function f_random( in integer p_lowerbound,
in integer p_upperbound )
return integer {
//Variables
var integer v_random := 0;
v_random := float2int(int2float(p_upperbound - p_lowerbound +1)*rnd()) + p_lowerbound;
log("*** f_random: INFO: OK - random value = " & int2str(v_random) & " ***");
return v_random;
} // end function f_random
/**
* @desc Computes the absolute value of an integer
* @param p_number the number
* @return Absolute value of the number
*/
function f_abs(in integer p_number)
return integer {
if(p_number < 0) {
return 0 - p_number;
}
return p_number;
}
/**
* @desc Computes the absolute value of an integer
* @param p_number the number
* @return Absolute value of the number
*/
function ff_abs(in float p_number)
return float {
if(p_number < 0.0) {
return 0.0 - p_number;
}
return p_number;
}
/**
* @desc Compares two values and returns the lowest onde
* @param p_a First value
* @param p_b Second value
* @return Lowest value
*/
function f_min(in integer p_a, in integer p_b)
return integer {
if(p_a < p_b) {
return p_a;
}
return p_b;
}
/**
* @desc Removes unsignificant right-most 0 bits of a bitstring
*
* @param p_bitstring Bitstring to be reduced
* @return Reduced bitstring
*
*/
function f_removeUnsignificantBits(in bitstring p_bitstring)
return bitstring {
var integer i, len;
len := lengthof(p_bitstring);
for(i:=len-1; i >=0 and p_bitstring[i] == '0'B; i:=i-1) {}
return substr(p_bitstring, 0, i + 1);
}
/**
* @desc Gets the current time since 01/01/2004
* @return TimestampIts - current time since 01/01/2004 in milliseconds
......@@ -117,19 +34,6 @@ module LibItsCommon_Functions {
return v_timeStamp;
}
/**
* @desc Gets the current time since 01/01/1970 in UTC format
* @return The current time since 01/01/1970 in UTC format in milliseconds
*/
function f_getCurrentTimeUtc() return UInt64 {
var UInt64 v_time := 0;
// log("*** f_getCurrentTimeUtc: INFO: calling fx_getCurrentTimeUtc() ***");
v_time := fx_getCurrentTimeUtc();
return v_time;
}
/**
* @desc Gets the current time since 01/01/2004
* @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time
......@@ -143,32 +47,6 @@ module LibItsCommon_Functions {
return v_timeMark;
}
/**
* @desc Gets the Minute of current UTC year
* @return MinuteOfTheYear - tenths of a second in the current or next hour in units of 1/10th second from UTC time
*/
function f_getMinuteOfTheYear() return UInt16 {
var UInt16 v_minuteOfTheYear := 0;
// log("*** f_getMinuteOfTheYear: INFO: calling fx_getMinuteOfTheYear() ***");
v_minuteOfTheYear := fx_getMinuteOfTheYear();
return v_minuteOfTheYear;
}
/**
* @desc Gets the milliseconds point in the current UTC minute
* @return DSecond - The milliseconds point in the current UTC minute (0..60000)
*/
function f_getDSecond() return UInt16 {
var UInt16 v_dSecond := 0;
// log("*** f_getDSecond: INFO: calling fx_getDSecond() ***");
v_dSecond := fx_getDSecond();
return v_dSecond;
}
} // end generalFunctions
group itsFunctions {
......@@ -246,30 +124,12 @@ module LibItsCommon_Functions {
*/
external function fx_getCurrentTime() return UInt64;
/**
* @desc Gets the current time since 01/01/1970 in UTC format
* @return The current time since 01/01/1970 in UTC format
*/
external function fx_getCurrentTimeUtc() return UInt64;
/**
* @desc Gets the tenths of a second in the current or next hour in units of 1/10th second from UTC time
* @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time
*/
external function fx_getCurrentTimeMark() return UInt32;
/**
* @desc Gets the minutes of current UTC year
* @return MinuteOfTheYear - minutes of current UTC year
*/
external function fx_getMinuteOfTheYear() return UInt16;
/**
* @desc Gets the milliseconds point in the current UTC minute
* @return DSecond - the milliseconds point in the current UTC minute
*/
external function fx_getDSecond() return UInt16;
/**
* @desc External function to compute distance between two points
* @param p_latitudeA Latitude of first point
......
/**
* @author ETSI / STF545
* @version $URL$
* $ID:$
* @desc This module provides the custom binary types for ITS HTTP based protocols.
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
*/
module LibItsHttp_BinaryMessageBodyTypes {
/**
* This file volontary contains a trivial declaration of the type BinaryBodu.
* In accordance with your TTCN-3 module LibItsHttp_XMLTypes, you have to change the BinaryBody typing.
*/
// TODO Add here your custom binary import
// LibIts
import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
import from Ieee1609Dot2 language "ASN.1:1997" all;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941MessagesCa language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
type union BinaryBody {
// TODO Add here your custom variants
Ieee1609Dot2Data ieee1609dot2_data,
Certificate ieee1609dot2_certificate,
octetstring raw
} with {
variant ""
}
} // End of LibItsHttp_BinaryMessageBodyTypes
/**
* @author ETSI / STF545
* @version $URL$
* $ID:$
* @desc This module provides the custom templates for ITS HTTP based protocols.
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
*/
module LibItsHttp_BinaryTemplates {
// LibItsHttp
import from LibItsHttp_BinaryMessageBodyTypes all;
// TODO Add here your custom binary import
// LibIts
import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
import from Ieee1609Dot2 language "ASN.1:1997" all;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941MessagesCa language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
template (value) BinaryBody m_binary_body_raw(
in template (value) octetstring p_raw
) := {
raw := p_raw
} // End of template m_binary_body_raw
template (present) BinaryBody mw_binary_body_raw(
template (present) octetstring p_raw := ?
) := {
raw := p_raw
} // End of template mw_binary_body_raw
// TODO Add here your custom binary template
template (value) BinaryBody m_binary_body_ieee1609dot2_data(
in template (value) Ieee1609Dot2Data p_ieee1609dot2_data
) := {
ieee1609dot2_data := p_ieee1609dot2_data
} // End of template m_binary_body_ieee1609dot2_data
template (present) BinaryBody mw_binary_body_ieee1609dot2_data(
template (present) Ieee1609Dot2Data p_ieee1609dot2_data := ?
) := {
ieee1609dot2_data := p_ieee1609dot2_data
} // End of template mw_binary_body_ieee1609dot2_data
template (value) BinaryBody m_binary_body_ieee1609dot2_certificate(
in template (value) CertificateBase p_ieee1609dot2_certificate
) := {
ieee1609dot2_certificate := p_ieee1609dot2_certificate
} // End of template m_binary_body_ieee1609dot2_certificate
template (present) BinaryBody mw_binary_body_ieee1609dot2_certificate(
template (present) CertificateBase p_ieee1609dot2_certificate := ?
) := {
ieee1609dot2_certificate := p_ieee1609dot2_certificate
} // End of template mw_binary_body_ieee1609dot2_certificate
} // End of module LibItsHttp_BinaryTemplates
module LibItsHttp_BinaryTypes { // FIXME To be removed
/**
* This file is volontary empry. You have to declare all XSD files required by your project
* In addition, the TTCN-3 module LibItsHttp_XmlMessageBodyTypes have to be updated too.
*/
// TODO Add here your custom binary import
} // End of module LibItsHttp_BinaryTypes
module LibItsHttp_EncdecDeclarations {
// LibHttp
import from LibItsHttp_TypesAndValues all;
external function fx_enc_http_message (HttpMessage p) return bitstring
with {extension "prototype(convert) encode(HttpCodec)"}
external function fx_dec_http_message (inout bitstring b, out HttpMessage p) return integer
with {extension "prototype(sliding) decode(HttpCodec)"}
} // End of module LibItsHttp_EncdecDeclarations
module LibItsHttp_Functions {
// LibCommon
import from LibCommon_Time all;
import from LibCommon_VerdictControl all;
import from LibCommon_Sync all;
// LibHttp
import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_Pics all;
import from LibItsHttp_Pixits all;
import from LibItsHttp_TestSystem all;
group http_preambles {
/**
* @desc Setups default configuration
* @param p_certificate_id The certificate identifier the TA shall use in case of secured IUT
*/
function f_cfUp(
in charstring p_certificate_id
) runs on HttpComponent /* TITAN TODO: system HttpTestAdapter */ {
map(self:httpPort, system:httpPort);
f_connect4SelfOrClientSync();
} // End of function f_cfUp
} // End of group http_preambles
group http_postambles {
/**
* @desc Deletes default configuration
*/
function f_cfDown() runs on HttpComponent /* TITAN TODO: system HttpTestAdapter */ {
unmap(self:httpPort, system:httpPort);
f_disconnect4SelfOrClientSync();
} // End of function f_cfDown
} // End of group http_postambles
group http_headers {
function f_init_default_headers_list(
in charstring p_header_content_type := PICS_HEADER_CONTENT_TYPE,
in charstring p_header_content_text := "",
out Headers p_headers
) {
var integer v_i := 0;
p_headers[v_i] := { c_header_host, { PICS_HEADER_HOST } };
v_i := v_i + 1;
p_headers[v_i] := { c_header_content_type, { p_header_content_type } };
v_i := v_i + 1;
if (p_header_content_text != "") {
p_headers[v_i] := { c_header_content_text, { p_header_content_text } };
v_i := v_i + 1;
}
p_headers[v_i] := { c_header_content_length, { "0" } };
v_i := v_i + 1;
p_headers[v_i] := { c_header_connection, { "keep-alive" } };
v_i := v_i + 1;
p_headers[v_i] := { c_header_pragma, { "no-cache" } };
v_i := v_i + 1;
p_headers[v_i] := { c_header_cache_control, { "no-cache" } };
v_i := v_i + 1;
if (PICS_USE_TOKEN_HEADER) {
p_headers[v_i] := { c_header_authorization, { PICS_TOKEN_HEADER } }; // aladdin:opensesame
v_i := v_i + 1;
}
//p_headers[v_i] := { c_header_accept, { "application/x-its-response" } };
if (lengthof(PX_ADDITIONAL_HTTP_HEADERS_KEYS) != 0) {
f_set_headers_list(PX_ADDITIONAL_HTTP_HEADERS_KEYS, PX_ADDITIONAL_HTTP_HEADERS_VALUES, p_headers);
}
} // End of function f_init_default_headers_list
function f_set_headers_list(
in charstring_list p_headers_to_set,
in charstring_list p_headers_value,
inout Headers p_headers
) {
// Sanity checks
if (lengthof(p_headers_to_set) == 0) {
return;
} else if (lengthof(p_headers) == 0) {
return;
}
for (var integer v_idx := 0; v_idx < lengthof(p_headers_to_set); v_idx := v_idx + 1) {
var integer v_jdx;
for (v_jdx := 0; v_jdx < lengthof(p_headers); v_jdx := v_jdx + 1) {
if (p_headers[v_jdx].header_name == p_headers_to_set[v_idx]) {
p_headers[v_jdx].header_value := { p_headers_value[v_idx] }; // NOTE Codec won't encode it
break;
}
} // End of 'for' statement
if (v_jdx == lengthof(p_headers)) {
p_headers[v_jdx].header_name := p_headers_to_set[v_idx];
p_headers[v_jdx].header_value := { p_headers_value[v_idx] };
}
} // End of 'for' statement
} // End of function f_set_headers_list
function f_remove_headers_list(
in charstring_list p_headers_to_remove,
inout Headers p_headers
) {
// Sanity checks
if (lengthof(p_headers_to_remove) == 0) {
return;
} else if (lengthof(p_headers) == 0) {
return;
}
for (var integer v_idx := 0; v_idx < lengthof(p_headers_to_remove); v_idx := v_idx + 1) {
for (var integer v_jdx := 0; v_jdx < lengthof(p_headers); v_jdx := v_jdx + 1) {
if (p_headers[v_jdx].header_name == p_headers_to_remove[v_idx]) {
p_headers[v_jdx].header_value := omit; // NOTE Codec won't encode it
break;
}
} // End of 'for' statement
} // End of 'for' statement
} // End of function f_remove_headers_list
function f_get_header(
in Headers p_headers,
in charstring p_header_name := c_header_content_text,
out charstring_list p_header_value
) {
// Sanity checks
if (lengthof(p_header_name) == 0) {
return;
} else if (lengthof(p_headers) == 0) {
return;
}
for (var integer v_jdx := 0; v_jdx < lengthof(p_headers); v_jdx := v_jdx + 1) {
if (p_headers[v_jdx].header_name == p_header_name) {
p_header_value := p_headers[v_jdx].header_value; // NOTE Codec won't encode it
break;
}
} // End of 'for' statement
} // End of function f_get_header
/**
* @desc Check HTTP response headers
* @param p_headers The HTTP headers
* @param p_value the expected va;ue
* @return true on success, false otherwise
*/
function f_check_headers(
in Headers p_headers,
in charstring p_header_name := "Location",
in template (present) charstring p_value := ?
) return boolean {
// Local variables
var boolean v_header_matched := false;
for (var integer v_idx := 0; v_idx < lengthof(p_headers); v_idx := v_idx + 1) {
if (p_headers[v_idx].header_name == p_header_name) {
if (match(p_headers[v_idx].header_value[0], p_value) == true) {
v_header_matched := true;
} // else, nothing to do
break;
}
} // End of 'for' statement
return v_header_matched;
} // End of function f_check_headers
} // End of group http_headers
} // End of module LibItsHttp_Functions
module LibItsHttp_JSONTypes { // FIXME To be removed
/**
* This file is volontary empry. You have to declare all XSD files required by your project
* In addition, the TTCN-3 module LibItsHttp_XmlMessageBodyTypes have to be updated too.
*/
// TODO Add here your custom RFCs import
} // End of module LibItsHttp_JSONTypes
module LibItsHttp_JsonMessageBodyTypes {
/**
* This file volontary contains a trivial declaration of the type JsonBody.
* In accordance with your TTCN-3 module LibItsHttp_JSONTypes, you have to change the JsonBody typing.
*/
// TODO Add here your custom RFCs import
type union JsonBody {
// TODO Add here your custom variants
universal charstring raw
} with {
variant ""
}
} with {
variant ""
} // End of module LibItsHttp_JsonMessageBodyTypes
/**
* @author ETSI / STF569
* @version $URL$
* $ID:$
* @desc This module provides the custom templates for ITS HTTP based protocols.
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
*/
module LibItsHttp_JsonTemplates {
// TODO Add here your custom RFCs import
// LibItsHttp
import from LibItsHttp_JsonMessageBodyTypes all;
import from LibItsHttp_XMLTypes all;
template (value) JsonBody m_json_body_raw(
in template (value) charstring p_raw
) := {
raw := p_raw
} // End of template m_json_body_raw
template (present) JsonBody mw_json_body_raw(
template (present) charstring p_raw := ?
) := {
raw := p_raw
} // End of template mw_json_body_raw
} // End of module LibItsHttp_JsonTemplates
module LibItsHttp_MessageBodyTypes {
// LibHttp
import from LibItsHttp_XmlMessageBodyTypes all;
import from LibItsHttp_JsonMessageBodyTypes all;
import from LibItsHttp_BinaryMessageBodyTypes all;
type charstring HtmlBody;
type charstring TextBody;
type union HttpMessageBody {
BinaryBody binary_body,
HtmlBody html_body,
XmlBody xml_body,
JsonBody json_body,
TextBody text_body
} with {
variant ""
} // End of type HttpMessageBody
} with {
encode "HttpCodec"
}// End of module LibItsHttp_MessageBodyTypes
module LibItsHttp_Pics {
/**
* @desc HTTP major version
*/
modulepar integer PICS_HTTP_VERSION_MAJOR := 1;
/**
* @desc HTTP minor version
*/
modulepar integer PICS_HTTP_VERSION_MINOR := 1;
/**
* @desc
*/
modulepar charstring PICS_HEADER_HOST := "www.lisp.com";
/**
* @desc
*/
modulepar charstring PICS_HEADER_CONTENT_TYPE := "application/x-its-request";
modulepar charstring PICS_HEADER_CTL_CONTENT_TYPE := "application/x-its-ctl";
modulepar charstring PICS_HEADER_CRL_CONTENT_TYPE := "application/x-its-crl";
/**
* @desc Set to false in TOKEN header shall not be used
*/
modulepar boolean PICS_USE_TOKEN_HEADER := true;
/**
* @desc HTTP TOKEN value
* "YWxhZGRpbjpvcGVuc2VzYW1l==" is the base64 encoding of the login:password "aladdin:opensesame"
*/
modulepar charstring PICS_TOKEN_HEADER := "Basic " & "YWxhZGRpbjpvcGVuc2VzYW1l==" ; // aladdin:opensesame
} // End of module LibItsHttp_Pics