Skip unusable integration tests when testing a NEO

This commit is contained in:
Trevor Bentley
2017-10-31 15:40:51 +01:00
parent c939cff518
commit 7818b49e7d
2 changed files with 22 additions and 11 deletions
+10 -8
View File
@@ -435,6 +435,16 @@ END_TEST
START_TEST(test_pin_policy_always) {
ykpiv_rc res;
{
ykpiv_devmodel model;
model = ykpiv_util_devicemodel(g_state);
// Only works with YK4. NEO should skip.
if (model != DEVTYPE_YK4) {
fprintf(stderr, "WARNING: Not supported with Yubikey NEO. Test skipped.\n");
return;
}
}
{
unsigned char pp = YKPIV_PINPOLICY_ALWAYS;
unsigned char tp = YKPIV_TOUCHPOLICY_DEFAULT;
@@ -597,14 +607,6 @@ START_TEST(test_generate_key) {
}
END_TEST
START_TEST(test_read_write_mscmap) {
}
END_TEST
START_TEST(test_read_write_msroots) {
}
END_TEST
START_TEST(test_authenticate) {
ykpiv_rc res;
const char *default_mgm_key = "010203040506070801020304050607080102030405060708";
+12 -3
View File
@@ -107,10 +107,11 @@ static void test_initalize() {
}
static void test_token_info() {
static int test_token_info() {
const CK_CHAR_PTR TOKEN_LABEL = "YubiKey PIV";
const CK_CHAR_PTR TOKEN_MODEL = "YubiKey "; // Skip last 3 characters (version dependent)
const CK_CHAR_PTR TOKEN_MODEL_YK4 = "YubiKey YK4";
const CK_CHAR_PTR TOKEN_SERIAL = "1234";
const CK_FLAGS TOKEN_FLAGS = CKF_RNG | CKF_LOGIN_REQUIRED | CKF_USER_PIN_INITIALIZED | CKF_TOKEN_INITIALIZED;
const CK_VERSION HW = {0, 0};
@@ -135,6 +136,12 @@ static void test_token_info() {
asrt(info.ulFreePublicMemory, CK_UNAVAILABLE_INFORMATION, "FREE_PUB_MEM");
asrt(info.ulTotalPrivateMemory, CK_UNAVAILABLE_INFORMATION, "TOTAL_PVT_MEM");
asrt(info.ulFreePrivateMemory, CK_UNAVAILABLE_INFORMATION, "FREE_PVT_MEM");
if (strncmp(info.model, TOKEN_MODEL_YK4, strlen(TOKEN_MODEL_YK4)) != 0) {
dprintf(0, "\n\n** WARNING: Only YK4 supported. Skipping remaining tests.\n\n");
return -1;
}
asrt(info.hardwareVersion.major, HW.major, "HW_MAJ");
asrt(info.hardwareVersion.minor, HW.minor, "HW_MIN");
@@ -144,7 +151,7 @@ static void test_token_info() {
asrt(strncmp(info.utcTime, TOKEN_TIME, sizeof(info.utcTime)), 0, "TOKEN_TIME");
asrt(funcs->C_Finalize(NULL), CKR_OK, "FINALIZE");
return 0;
}
static void test_mechanism_list_and_info() {
@@ -652,7 +659,9 @@ int main(void) {
exit(77); // exit code 77 == skipped tests
test_initalize();
test_token_info();
// Require YK4 to continue. Skip if different model found.
if (test_token_info() != 0)
exit(77);
test_mechanism_list_and_info();
test_session();
test_login();