1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include "../test.h"
#include "soap.c"
static int test_string2isds_otp_resolution(const char *string,
const isds_otp_resolution correct_resolution) {
isds_otp_resolution new_resolution;
new_resolution = string2isds_otp_resolution(string);
if (new_resolution != correct_resolution)
FAIL_TEST("string2isds_otp_resolution() returned unexpected value: "
"expected=%d got=%d", correct_resolution, new_resolution);
PASS_TEST;
}
int main(int argc, char **argv) {
int i;
const char *hotp_strings[] = {
"authentication.error.userIsNotAuthenticated",
"authentication.error.intruderDetected",
"authentication.error.paswordExpired",
"authentication.error.badRole"
};
const isds_otp_resolution hotp_resolutions[] = {
OTP_RESOLUTION_BAD_AUTHENTICATION,
OTP_RESOLUTION_ACCESS_BLOCKED,
OTP_RESOLUTION_PASSWORD_EXPIRED,
OTP_RESOLUTION_UNAUTHORIZED
};
const char *totp_strings[] = {
"authentication.info.totpSended",
"authentication.error.userIsNotAuthenticated",
"authentication.error.intruderDetected",
"authentication.error.paswordExpired",
"authentication.info.cannotSendQuickly",
"authentication.error.badRole",
"authentication.info.totpNotSended"
};
const isds_otp_resolution totp_resolutions[] = {
OTP_RESOLUTION_TOTP_SENT,
OTP_RESOLUTION_BAD_AUTHENTICATION,
OTP_RESOLUTION_ACCESS_BLOCKED,
OTP_RESOLUTION_PASSWORD_EXPIRED,
OTP_RESOLUTION_TO_FAST,
OTP_RESOLUTION_UNAUTHORIZED,
OTP_RESOLUTION_TOTP_NOT_SENT
};
INIT_TEST("OTP X-Response-message-Code string to isds_otp_resolution "
"conversion");
/* HOTP */
for (i = 0; i < sizeof(hotp_strings)/sizeof(hotp_strings[0]); i++) {
TEST(hotp_strings[i], test_string2isds_otp_resolution,
hotp_strings[i], hotp_resolutions[i]);
}
/* TOTP */
for (i = 0; i < sizeof(totp_strings)/sizeof(totp_strings[0]); i++) {
TEST(totp_strings[i], test_string2isds_otp_resolution,
totp_strings[i], totp_resolutions[i]);
}
/* Corner cases */
TEST("Unknown value", test_string2isds_otp_resolution, "X-Unknown value",
OTP_RESOLUTION_UNKNOWN);
TEST("Empty string", test_string2isds_otp_resolution, "",
OTP_RESOLUTION_UNKNOWN);
TEST("NULL pointer", test_string2isds_otp_resolution, NULL,
OTP_RESOLUTION_UNKNOWN);
SUM_TEST();
}
|