8#include <cgreen/cgreen.h>
9#include <cgreen/mocks.h>
27 uri_cpe =
"cpe:/a:microsoft:internet_explorer:8.0.6001:beta";
30 assert_that (cpe.
part, is_equal_to_string (
"a"));
31 assert_that (cpe.
vendor, is_equal_to_string (
"microsoft"));
32 assert_that (cpe.
product, is_equal_to_string (
"internet_explorer"));
33 assert_that (cpe.
version, is_equal_to_string (
"8\\.0\\.6001"));
34 assert_that (cpe.
update, is_equal_to_string (
"beta"));
35 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
36 assert_that (cpe.
language, is_equal_to_string (
"ANY"));
39 uri_cpe =
"cpe:/a:microsoft:internet_explorer:8.%2a:sp%3f";
42 assert_that (cpe.
part, is_equal_to_string (
"a"));
43 assert_that (cpe.
vendor, is_equal_to_string (
"microsoft"));
44 assert_that (cpe.
product, is_equal_to_string (
"internet_explorer"));
45 assert_that (cpe.
version, is_equal_to_string (
"8\\.\\*"));
46 assert_that (cpe.
update, is_equal_to_string (
"sp\\?"));
47 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
48 assert_that (cpe.
language, is_equal_to_string (
"ANY"));
51 uri_cpe =
"cpe:/a:hp:insight_diagnostics:7.4.0.1570::~~online~win2003~x64~";
54 assert_that (cpe.
part, is_equal_to_string (
"a"));
55 assert_that (cpe.
vendor, is_equal_to_string (
"hp"));
56 assert_that (cpe.
product, is_equal_to_string (
"insight_diagnostics"));
57 assert_that (cpe.
version, is_equal_to_string (
"7\\.4\\.0\\.1570"));
58 assert_that (cpe.
update, is_equal_to_string (
"ANY"));
59 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
60 assert_that (cpe.
sw_edition, is_equal_to_string (
"online"));
61 assert_that (cpe.
target_sw, is_equal_to_string (
"win2003"));
62 assert_that (cpe.
target_hw, is_equal_to_string (
"x64"));
63 assert_that (cpe.
other, is_equal_to_string (
"ANY"));
64 assert_that (cpe.
language, is_equal_to_string (
"ANY"));
68 "cpe:/a:hp:insight_diagnostics:7.4.0.1570::~~online~win2003~x64~other";
71 assert_that (cpe.
part, is_equal_to_string (
"a"));
72 assert_that (cpe.
vendor, is_equal_to_string (
"hp"));
73 assert_that (cpe.
product, is_equal_to_string (
"insight_diagnostics"));
74 assert_that (cpe.
version, is_equal_to_string (
"7\\.4\\.0\\.1570"));
75 assert_that (cpe.
update, is_equal_to_string (
"ANY"));
76 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
77 assert_that (cpe.
sw_edition, is_equal_to_string (
"online"));
78 assert_that (cpe.
target_sw, is_equal_to_string (
"win2003"));
79 assert_that (cpe.
target_hw, is_equal_to_string (
"x64"));
80 assert_that (cpe.
other, is_equal_to_string (
"other"));
81 assert_that (cpe.
language, is_equal_to_string (
"ANY"));
86 "a:hp:insight_diagnostics:7.4.0.1570::~~online~win2003~x64~other:english";
89 assert_that (cpe.
part, is_equal_to_string (
"a"));
90 assert_that (cpe.
vendor, is_equal_to_string (
"hp"));
91 assert_that (cpe.
product, is_equal_to_string (
"insight_diagnostics"));
92 assert_that (cpe.
version, is_equal_to_string (
"7\\.4\\.0\\.1570"));
93 assert_that (cpe.
update, is_equal_to_string (
"ANY"));
94 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
95 assert_that (cpe.
sw_edition, is_equal_to_string (
"online"));
96 assert_that (cpe.
target_sw, is_equal_to_string (
"win2003"));
97 assert_that (cpe.
target_hw, is_equal_to_string (
"x64"));
98 assert_that (cpe.
other, is_equal_to_string (
"other"));
99 assert_that (cpe.
language, is_equal_to_string (
"english"));
102 uri_cpe =
"This is a ~:SIGNAL:~ test.";
113 fs_cpe =
"cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*";
116 assert_that (cpe.
part, is_equal_to_string (
"a"));
117 assert_that (cpe.
vendor, is_equal_to_string (
"microsoft"));
118 assert_that (cpe.
product, is_equal_to_string (
"internet_explorer"));
119 assert_that (cpe.
version, is_equal_to_string (
"8\\.0\\.6001"));
120 assert_that (cpe.
update, is_equal_to_string (
"beta"));
121 assert_that (cpe.
edition, is_equal_to_string (
"ANY"));
122 assert_that (cpe.
language, is_equal_to_string (
"ANY"));
123 assert_that (cpe.
sw_edition, is_equal_to_string (
"ANY"));
124 assert_that (cpe.
target_sw, is_equal_to_string (
"ANY"));
125 assert_that (cpe.
target_hw, is_equal_to_string (
"ANY"));
126 assert_that (cpe.
other, is_equal_to_string (
"ANY"));
129 fs_cpe =
"This is a ~:SIGNAL:~ test.";
143 cpe.
product =
"internet_explorer";
149 assert_that (uri_cpe, is_equal_to_string (
150 "cpe:/a:microsoft:internet_explorer:8.0.6001:beta"));
162 cpe.
product =
"internet_explorer";
171 "cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*"));
177 char *uri_cpe =
"cpe:/a:microsoft:internet_explorer:8.0.6001:beta";
182 "cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*"));
185 uri_cpe =
"cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win2003~x64~";
188 is_equal_to_string (
"cpe:2.3:a:hp:insight_diagnostics:7.4.0."
189 "1570:-:*:*:online:win2003:x64:*"));
192 uri_cpe =
"This is a ~:SIGNAL:~ test.";
200 "cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*";
202 assert_that (uri_cpe, is_equal_to_string (
203 "cpe:/a:microsoft:internet_explorer:8.0.6001:beta"));
207 "cpe:2.3:a:hp:insight_diagnostics:7.4.0.1570:-:*:*:online:win2003:x64:*";
212 "cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win2003~x64~"));
216 "cpe:2.3:a:hp:insight_diagnostics:7\\:4.0.1570:-:*:*:online:win2003:x64:*";
221 "cpe:/a:hp:insight_diagnostics:7%3A4.0.1570:-:~~online~win2003~x64~"));
225 "cpe:2.3:a:hp:insight_diagnostics:7.4.0.1570:-:*:*:online:win\\:2003:x64:*";
230 "cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win%3A2003~x64~"));
233 fs_cpe =
"cpe:2.3:a:hp:insight_diagnostics:7.4.0.1570:-:*:*:online:win\\:\\:"
240 "a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win%3A%3A2003~x64~"));
243 fs_cpe =
"cpe:2.3:a:hp:insight_diagnostics:7.4.0.1570:-:*:*:online:"
249 "cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win2003%5C~x64~"));
252 fs_cpe =
"This is a ~:SIGNAL:~ test.";
260 char *fs_cpe1, *fs_cpe2;
262 fs_cpe1 =
"cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*";
267 fs_cpe2 =
"cpe:2.3:a:microsoft:internet_explorer:*:beta:*:*:*:*:*:*";
274 fs_cpe2 =
"cpe:2.3:a:microsoft:internet_explorer:*:-:*:*:*:*:*:*";
289 uri_cpe =
"cpe:/a:hp:insight_diagnostics:7.4.0.1570:-:~~online~win2003~x64~";
292 assert_string_equal (uri_product,
"cpe:/a:hp:insight_diagnostics");
293 g_free (uri_product);
303 suite = create_test_suite ();
315 ret = run_single_test (suite, argv[1], create_text_reporter ());
317 ret = run_test_suite (suite, create_text_reporter ());
319 destroy_test_suite (suite);
Functions to convert different CPE notations into each other.
char * fs_cpe_to_uri_cpe(const char *fs_cpe)
Convert a formatted string CPE to a URI CPE.
gboolean cpe_struct_match(cpe_struct_t *source, cpe_struct_t *target)
Returns if source is a match for target. That means that source is a superset of target.
char * uri_cpe_to_fs_cpe(const char *uri_cpe)
Convert a URI CPE to a formatted string CPE.
char * cpe_struct_to_fs_cpe(const cpe_struct_t *cpe)
Convert a CPE struct into a formatted string CPE.
void fs_cpe_to_cpe_struct(const char *fs_cpe, cpe_struct_t *cpe)
Read a formatted string CPE into the CPE struct.
char * cpe_struct_to_uri_cpe(const cpe_struct_t *cpe)
Convert a CPE struct into a URI CPE.
void cpe_struct_init(cpe_struct_t *cpe)
Initialize a CPE struct.
void cpe_struct_free(cpe_struct_t *cpe)
Free a CPE struct.
char * uri_cpe_to_uri_product(const char *uri_cpe)
Convert a URI CPE to a formatted string product.
void uri_cpe_to_cpe_struct(const char *uri_cpe, cpe_struct_t *cpe)
Read a URI CPE into the CPE struct.
int main(int argc, char **argv)
Ensure(cpeutils, uri_cpe_to_cpe_struct)