Skip to content
Permalink
Browse files

Add single test single message functional test

  • Loading branch information
keithmendozasr committed Nov 12, 2019
1 parent a1a07a3 commit bd051d4037c0878724890d587c7a8f3f624d470f
@@ -8,6 +8,7 @@ addons:
- g++-8
- libssl1.1
- cmake-data
- python3-pip

cache:
directories:
@@ -22,6 +23,7 @@ before_install:
- eval ${MATRIX_EVAL}

install:
- pip3 install robotframework
- travis_retry wget https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz
- tar zxvf yaml-cpp-0.6.2.tar.gz
- cd yaml-cpp-yaml-cpp-0.6.2
@@ -15,7 +15,7 @@
cmake_minimum_required (VERSION 3.10)
include(FindPkgConfig)

project (tlslookieloo VERSION 0.2.1)
project (tlslookieloo VERSION 0.3.0)
enable_testing()
configure_file(include/version.h.in ${CMAKE_BINARY_DIR}/include/version.h)

@@ -13,3 +13,4 @@
# limitations under the License.

add_subdirectory(unit)
add_subdirectory(functional)
@@ -0,0 +1,21 @@
# Copyright 2019-present tlslookieloo authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

configure_file(commonvars.py.in commonvars.py)
configure_file(payloads/single_target_test_1.yaml payloads/single_target_test_1.yaml)

add_test(NAME single_target
COMMAND robot --variablefile ${CMAKE_CURRENT_BINARY_DIR}/commonvars.py
${CMAKE_CURRENT_SOURCE_DIR}/single_target.robot
)
@@ -0,0 +1,77 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
1d:91:86:86:1d:f3:66:e6:bf:27:0e:dd:fd:18:24:1c:26:a5:4b:46
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=California, L=Tustin, O=tlslookieloo, CN=tlslookieloo test certificate
Validity
Not Before: Oct 28 02:56:55 2019 GMT
Not After : Oct 25 02:56:55 2029 GMT
Subject: C=US, ST=California, O=homepluspower.info, OU=Research, CN=tlslookieloo
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Modulus:
00:b1:44:0e:67:66:b7:fa:07:84:4d:39:5a:e3:ee:
0e:95:d3:b7:ac:60:a4:90:00:63:27:e2:6d:9e:ce:
c6:8c:84:14:d6:ad:0b:20:49:68:17:2d:cc:c9:df:
ce:b0:70:e2:1f:4a:af:b6:87:06:00:44:90:f3:bf:
8d:e1:9f:62:55:30:98:c8:81:83:ab:06:6c:90:04:
70:c6:41:2e:a7:2e:1a:4f:3a:31:6a:2f:31:44:95:
7e:94:1d:4d:c4:75:76:66:5d:cb:d3:cb:85:18:ec:
5f:17:c0:a5:3d:0b:dc:c5:8d:c9:dd:f8:28:55:09:
5f:ec:47:74:aa:94:1a:04:9b:43:64:20:22:dc:e5:
80:e1:a0:79:46:42:50:82:48:ba:d8:8e:d1:35:c2:
1d:13:fa:8c:c0:c0:62:32:43:fd:47:63:af:3a:05:
64:e5:e4:f0:bc:f0:62:3b:40:bd:3d:07:49:81:69:
3f:04:fe:c7:b8:8b:09:f8:b3:4c:e0:f6:7f:cb:83:
c6:84:07:b2:4b:c2:da:73:6e:12:8d:3f:fb:68:15:
8a:7a:e0:53:20:54:aa:ce:05:0f:59:e3:41:e4:f4:
fc:be:5d:8f:ae:20:32:5f:d9:9f:3b:af:0e:68:bc:
41:90:63:72:e2:87:4f:75:b2:1d:41:b4:aa:d3:e3:
f2:fb
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Alternative Name:
DNS:localhost
Signature Algorithm: sha256WithRSAEncryption
b4:22:6a:c9:0c:23:ed:57:5a:1a:90:1a:95:dd:a0:1b:9d:2d:
8b:e3:8b:6d:fd:ba:70:84:7e:8c:15:21:87:49:de:f5:4b:ea:
a0:7e:53:2e:dd:d3:61:5c:09:c7:a7:31:f0:1c:ef:52:82:0e:
85:7c:1c:80:01:b5:c4:90:49:6c:fa:37:3a:f0:dc:cd:69:9e:
92:45:6c:9c:f7:8b:c6:b1:5f:b7:57:97:16:f7:ab:27:e6:0b:
a4:92:5c:94:ad:c7:4a:3c:44:65:9d:30:79:6a:dc:58:5e:33:
6b:0e:2d:36:69:cf:9b:d4:64:ff:c0:d2:fd:7b:d0:85:6e:fd:
a7:9e:b6:d8:ae:db:8c:df:71:3c:eb:65:2b:cd:e6:1b:f3:23:
cf:40:7c:e0:d0:95:e6:fa:0c:87:9c:d6:a4:6a:3a:a4:f5:4e:
2e:31:f7:8b:5e:45:d4:9e:ea:cf:45:ac:75:7f:ad:3e:12:db:
d4:d9:be:14:bf:f1:38:e9:b9:1b:78:bc:d0:09:0d:40:c2:8a:
57:03:d8:e7:b8:63:91:d3:45:44:86:33:67:29:26:f6:07:79:
0d:4b:3f:75:91:96:7f:f6:09:a9:2f:fe:ac:d6:be:02:6b:ec:
57:47:db:94:13:77:df:05:09:c0:d5:a9:d4:21:f6:d8:00:66:
aa:c3:3a:7c
-----BEGIN CERTIFICATE-----
MIIDjzCCAnegAwIBAgIUHZGGhh3zZua/Jw7d/RgkHCalS0YwDQYJKoZIhvcNAQEL
BQAwcjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExDzANBgNVBAcM
BlR1c3RpbjEVMBMGA1UECgwMdGxzbG9va2llbG9vMSYwJAYDVQQDDB10bHNsb29r
aWVsb28gdGVzdCBjZXJ0aWZpY2F0ZTAeFw0xOTEwMjgwMjU2NTVaFw0yOTEwMjUw
MjU2NTVaMGkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRswGQYD
VQQKDBJob21lcGx1c3Bvd2VyLmluZm8xETAPBgNVBAsMCFJlc2VhcmNoMRUwEwYD
VQQDDAx0bHNsb29raWVsb28wggEiMA0GCSqGSIb3DQEBAQUAA4IBD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
pautQ8tA/7cOGUYSC7sTJQh3EV83jDjLCv9P9dwyVTPphJqONZGyiGSLo6uzJPI5
pRWf4y1tRGHgLDQvMJByEv7/PiViCgq8CiAk4ZuRXQBHOJJF69nRD14PBDDmgFaR
mB/dQyLB8kF+NtPi28MLI7qW/FK1ds0yYYbyM8VpAoGBAMAuVUvHgNHjuRR8mVTf
7nGqEeMMH2SOMBNo+z+33yxXVr+xeiXFLYfyZZomhb4uz7oE6z5jnf/I2WP8Inb6
X33EFPAEx6SLSh3f3vlcfwG3bTTfQ3D6F8HTZF3WwPvWWlSaiFJphSCKdFRqtKPr
+5AQ4kbbdQ2+2XafoBc4ClQC
-----END PRIVATE KEY-----
@@ -0,0 +1,9 @@
TLSLOOKIELOO = "${CMAKE_BINARY_DIR}/src/tlslookieloo"
CERT_PATH = "${CMAKE_CURRENT_SOURCE_DIR}/certs"
SERVER_CERT = CERT_PATH + "/tlslookieloo_server.pem"
SERVER_KEY = CERT_PATH + "/tlslookieloo_server_priv.pem"
TIMESTAMP_TAG = "===\\d{4}(-\\d{2}){2} \\d{2}(:\\d{2}){2} "
STOC_HEADER_LINE = TIMESTAMP_TAG + "BEGIN server-->client==="
CTOS_HEADER_LINE = TIMESTAMP_TAG + "BEGIN client-->server==="
END_TAG = "===END==="
PAYLOAD_DIR = "${CMAKE_CURRENT_BINARY_DIR}/payloads"
@@ -0,0 +1,44 @@
*** Settings ***
Library Process
Library OperatingSystem

*** Variables ***
${openssl} = /usr/bin/openssl

*** Keyword ***
Log Process Failed Start
[Arguments] ${handle} ${procname}
Terminate Process ${handle}
${rslt} = Get Process Result ${handle}
Log ${procname} failed to start exit Code: ${rslt.rc} Console output: ${rslt.stdout}\n${rslt.stderr} ERROR
Fail

Start tlslookieloo
[Arguments] ${target_file}
${sut} = Start Process ${TLSLOOKIELOO} -t ${target_file} alias=testprocess
Sleep 500ms
${rslt} = Is Process Running handle=${sut}
Run Keyword If ${rslt} == ${False} Log Process Failed Start ${sut} tlslookieloo
[Return] ${sut}

Start server
[Arguments] ${listen_port} ${cert} ${key}
${server} = Start Process ${openssl} s_server -ign_eof -quiet -cert ${cert} -key ${key} -port +${listen_port}
Sleep 1
${rslt} = Is Process Running ${server}
Run Keyword If ${rslt} == ${False} Log Process Failed Start ${server} s_server
${server_obj} = Get Process Object ${server}
[Return] ${server} ${server_obj}

Start client
[Arguments] ${host}
${client} = Start Process ${openssl} s_client -ign_eof -quiet -connect ${host}
Sleep 1
${rslt} = Is Process Running ${client}
Run Keyword If ${rslt} == ${False} Log Process Failed Start ${client} s_client
${client_obj} = Get Process Object ${client}
[Return] ${client} ${client_obj}

Check Data Clear
Directory Should Not Exist data/ \"data\" directory present from previous test
Create Directory data
@@ -0,0 +1,8 @@
- name: App1
clientport: 9900
clientcert: ${CMAKE_CURRENT_SOURCE_DIR}/certs/tlslookieloo_server.pem
clientkey: ${CMAKE_CURRENT_SOURCE_DIR}/certs/tlslookieloo_server_priv.pem
serverhost: localhost
serverport: 9901
recordfile: data/single_target_test1.msgs
serverinsecure: true
@@ -0,0 +1,58 @@
*** Settings ***
Library String
Resource functional.resource

Suite Setup Check Data Clear
Test Teardown Run Keyword And Ignore Error Terminate All Processes

*** Test Cases ***
Single Message
[Timeout] 25s
${server} ${server_obj} = Start Server 9901 ${SERVER_CERT} ${SERVER_KEY}
${sut} = Start tlslookieloo ${PAYLOAD_DIR}/single_target_test_1.yaml
${client} ${client_obj} = Start Client localhost:9900

${msg} = Encode String To Bytes Hello from server ASCII
${retval} = Call Method ${server_obj.stdin} write ${msg}
Log server write returned: ${retval}
Call Method ${server_obj.stdin} flush

${rslt} = Call Method ${client_obj.stdout} read ${17}
Log Message from server: ${rslt}

${msg} = Encode String To Bytes Hello from client ASCII
${retval} = Call Method ${client_obj.stdin} write ${msg}
Log write returned: ${retval}
Call Method ${client_obj.stdin} flush

${rslt} = Call Method ${server_obj.stdout} read ${11}
Log Message from client: ${rslt}

${rslt} = Terminate Process ${sut}
Log tlslookieloo exit code: ${rslt.rc}
Log tlslookieloo stdout: ${rslt.stdout}
Log tlslookieloo stderr: ${rslt.stderr}

${data_file} = Set Variable data/single_target_test1.msgs
Should Exist ${data_file}
${file_data} = Get File ${data_file}
${num_lines} = Get Line Count ${file_data}
Should Be Equal ${6} ${num_lines}

${line} = Get Line ${file_data} 0
Should Match Regexp ${line} ${STOC_HEADER_LINE}

${line} = Get Line ${file_data} 1
Should Be Equal As Strings ${line} Hello from server

${line} = Get Line ${file_data} 2
Should Be Equal As Strings ${line} ${END_TAG}

${line} = Get Line ${file_data} 3
Should Match Regexp ${line} ${CTOS_HEADER_LINE}

${line} = Get Line ${file_data} 4
Should Be Equal As Strings ${line} Hello from client

${line} = Get Line ${file_data} 5
Should Be Equal As Strings ${line} ${END_TAG}

0 comments on commit bd051d4

Please sign in to comment.
You can’t perform that action at this time.