aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_C_API.cpp
blob: 37d3c7ff29a87e95cc1c8d0efff4068824807119 (plain)
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
static const int TOO_LONG_STRING = 200;

#include "catch.hpp"

#include <iostream>
#include <string>
#include "log.h"
#include "../NK_C_API.h"

TEST_CASE("C API connect", "[BASIC]") {
  auto login = NK_login_auto();
  REQUIRE(login != 0);
  NK_logout();
  login = NK_login_auto();
  REQUIRE(login != 0);
  NK_logout();
  login = NK_login_auto();
  REQUIRE(login != 0);
}

TEST_CASE("Check retry count", "[BASIC]") {
  REQUIRE(NK_get_admin_retry_count() == 3);
  REQUIRE(NK_get_user_retry_count() == 3);
}

TEST_CASE("Check long strings", "[STANDARD]") {
  char* longPin = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  char *pin = "123123123";
  auto result = NK_change_user_PIN(longPin, pin);
  REQUIRE(result == TOO_LONG_STRING);
  result = NK_change_user_PIN(pin, longPin);
  REQUIRE(result == TOO_LONG_STRING);
  CAPTURE(result);
}