Debian Codegraph @

crt/s2n/tests/unit/s2n_security_policies_rules_test.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include "s2n_test.h"
17 #include "tls/s2n_security_policies.h"
18
19 int main(int argc, char **argv)
20 {
21 BEGIN_TEST();
22
23 DEFER_CLEANUP(struct s2n_security_rule_result result = { 0 },
24 s2n_security_rule_result_free);
25 EXPECT_OK(s2n_security_rule_result_init_output(&result));
26
27 for (size_t i = 0; security_policy_selection[i].version != NULL; i++) {
28 const struct s2n_security_policy *security_policy = security_policy_selection[i].security_policy;
29 EXPECT_NOT_NULL(security_policy);
30 EXPECT_OK(s2n_security_policy_validate_security_rules(security_policy, &result));
31 }
32
33 if (result.found_error) {
34 int output_size = s2n_stuffer_data_available(&result.output);
35 char *output_str = s2n_stuffer_raw_read(&result.output, output_size);
36 EXPECT_NOT_NULL(output_str);
37 fprintf(stdout, "\n%.*s", output_size, output_str);
38 FAIL_MSG("Security policies violate configured policy rules. See stdout for details.");
39 }
40
41 END_TEST();
42 }