suricata
detect-tls-version.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2019 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  */
24 
25 #include "detect-engine-build.h"
26 #include "app-layer-parser.h"
27 
28 /**
29  * \test DetectTlsVersionTestParse01 is a test to make sure that we parse the "id"
30  * option correctly when given valid id option
31  */
32 static int DetectTlsVersionTestParse01 (void)
33 {
34  DetectTlsVersionData *tls = NULL;
35  tls = DetectTlsVersionParse(NULL, "1.0");
36  FAIL_IF_NULL(tls);
38  DetectTlsVersionFree(NULL, tls);
39  PASS;
40 }
41 
42 /**
43  * \test DetectTlsVersionTestParse02 is a test to make sure that we parse the "id"
44  * option correctly when given an invalid id option
45  * it should return id_d = NULL
46  */
47 static int DetectTlsVersionTestParse02 (void)
48 {
49  DetectTlsVersionData *tls = NULL;
50  tls = DetectTlsVersionParse(NULL, "2.5");
51  FAIL_IF_NOT_NULL(tls);
52  DetectTlsVersionFree(NULL, tls);
53  PASS;
54 }
55 
56 /**
57  * \brief this function registers unit tests for DetectTlsVersion
58  */
59 static void DetectTlsVersionRegisterTests(void)
60 {
61  UtRegisterTest("DetectTlsVersionTestParse01", DetectTlsVersionTestParse01);
62  UtRegisterTest("DetectTlsVersionTestParse02", DetectTlsVersionTestParse02);
63 }
TLS_VERSION_10
@ TLS_VERSION_10
Definition: app-layer-ssl.h:165
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
FAIL_IF_NOT
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
Definition: util-unittest.h:82
FAIL_IF_NOT_NULL
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
Definition: util-unittest.h:96
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
app-layer-parser.h
detect-engine-build.h
DetectTlsVersionData_::ver
uint16_t ver
Definition: detect-tls-version.h:30
DetectTlsVersionData_
Definition: detect-tls-version.h:29