Skip to content

Commit cd91610

Browse files
committed
Simplify create_ca_test
Failures are now immediate, rather than accumulated. Resolves: Coverity 1647710 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
1 parent c84d71f commit cd91610

File tree

1 file changed

+16
-44
lines changed

1 file changed

+16
-44
lines changed

test/create_ca_test.c

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,44 +1055,33 @@ main (int argc, char **argv)
10551055

10561056
/* Verify that subject alternative names were properly included */
10571057
printf ("Verifying subject alternative names in service certificate. ");
1058-
int verify_ret = verify_subject_alt_names (cert);
1059-
if (verify_ret != EOK)
1058+
ret = verify_subject_alt_names (cert);
1059+
if (ret != EOK)
10601060
{
10611061
printf ("FAILED.\n");
1062-
ret = verify_ret; /* Store first failure but continue testing */
1063-
}
1064-
else
1065-
{
1066-
printf ("SUCCESS.\n");
1062+
goto done;
10671063
}
1064+
printf ("SUCCESS.\n");
10681065

10691066
/* Test additional SAN verification scenarios */
10701067
printf ("Testing SAN edge cases and validation. ");
1071-
int edge_ret = test_san_edge_cases (cert);
1072-
if (edge_ret != EOK)
1068+
ret = test_san_edge_cases (cert);
1069+
if (ret != EOK)
10731070
{
10741071
printf ("FAILED.\n");
1075-
if (ret == EOK)
1076-
ret = edge_ret; /* Store first failure */
1077-
}
1078-
else
1079-
{
1080-
printf ("SUCCESS.\n");
1072+
goto done;
10811073
}
1074+
printf ("SUCCESS.\n");
10821075

10831076
/* Test IP address netmask handling */
10841077
printf ("Testing IP address netmask stripping functionality. ");
1085-
int netmask_ret = test_ip_netmask_handling (cert);
1086-
if (netmask_ret != EOK)
1078+
ret = test_ip_netmask_handling (cert);
1079+
if (ret != EOK)
10871080
{
10881081
printf ("FAILED.\n");
1089-
if (ret == EOK)
1090-
ret = netmask_ret; /* Store first failure */
1091-
}
1092-
else
1093-
{
1094-
printf ("SUCCESS.\n");
1082+
goto done;
10951083
}
1084+
printf ("SUCCESS.\n");
10961085

10971086
/* ============= CA CERTIFICATE TESTS ============= */
10981087

@@ -1135,30 +1124,13 @@ main (int argc, char **argv)
11351124

11361125
/* Verify name constraints in the CA certificate */
11371126
printf ("Verifying name constraints in CA certificate. ");
1138-
int ca_constraints_ret =
1139-
verify_name_constraints (ca_cert, certinfo->subject_alt_names);
1140-
if (ca_constraints_ret != EOK)
1127+
ret = verify_name_constraints (ca_cert, certinfo->subject_alt_names);
1128+
if (ret != EOK)
11411129
{
11421130
printf ("FAILED.\n");
1143-
if (ret == EOK)
1144-
ret = ca_constraints_ret;
1145-
}
1146-
else
1147-
{
1148-
printf ("SUCCESS.\n");
1131+
goto done;
11491132
}
1150-
1151-
/* Summary of all test results */
1152-
printf ("\n=== TEST SUMMARY ===\n");
1153-
printf ("Service cert SAN verification: %s\n",
1154-
verify_ret == EOK ? "PASS" : "FAIL");
1155-
printf ("Service cert edge case validation: %s\n",
1156-
edge_ret == EOK ? "PASS" : "FAIL");
1157-
printf ("Service cert netmask handling: %s\n",
1158-
netmask_ret == EOK ? "PASS" : "FAIL");
1159-
printf ("CA certificate creation: %s\n", ca_cert ? "PASS" : "FAIL");
1160-
printf ("CA name constraints verification: %s\n",
1161-
ca_constraints_ret == EOK ? "PASS" : "FAIL");
1133+
printf ("SUCCESS.\n");
11621134

11631135
done:
11641136
if (ret != EOK)

0 commit comments

Comments
 (0)