diff options
Diffstat (limited to 'contrib/ntp/tests/libntp/authkeys.c')
-rw-r--r-- | contrib/ntp/tests/libntp/authkeys.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/contrib/ntp/tests/libntp/authkeys.c b/contrib/ntp/tests/libntp/authkeys.c index b949628..6a10c01 100644 --- a/contrib/ntp/tests/libntp/authkeys.c +++ b/contrib/ntp/tests/libntp/authkeys.c @@ -17,16 +17,26 @@ u_long current_time = 4; int counter = 0; - -// old code from google test framework, moved to SetUp() for unity -void setUp(void) +void setUp(void); +void tearDown(void); +void AddTrustedKey(keyid_t keyno); +void AddUntrustedKey(keyid_t keyno); +void test_AddTrustedKeys(void); +void test_AddUntrustedKey(void); +void test_HaveKeyCorrect(void); +void test_HaveKeyIncorrect(void); +void test_AddWithAuthUseKey(void); +void test_EmptyKey(void); + + +void +setUp(void) { -// init_lib(); - if(counter ==0){ - counter++; - init_auth(); //causes segfault if called more than once + if (counter == 0) { + counter++; + init_auth(); // causes segfault if called more than once } -/* + /* * init_auth() is called by tests_main.cpp earlier. It * does not initialize global variables like * authnumkeys, so let's reset them to zero here. @@ -41,20 +51,18 @@ void setUp(void) cache_flags = 0; cache_secret = NULL; cache_secretsize = 0; - } -void tearDown(void) +void +tearDown(void) { -} +} static const int KEYTYPE = KEY_TYPE_MD5; - - - -void AddTrustedKey(keyid_t keyno) { +void +AddTrustedKey(keyid_t keyno) { /* * We need to add a MD5-key in addition to setting the * trust, because authhavekey() requires type != 0. @@ -64,11 +72,13 @@ void AddTrustedKey(keyid_t keyno) { authtrust(keyno, TRUE); } -void AddUntrustedKey(keyid_t keyno) { +void +AddUntrustedKey(keyid_t keyno) { authtrust(keyno, FALSE); } -void test_AddTrustedKeys() { +void +test_AddTrustedKeys(void) { const keyid_t KEYNO1 = 5; const keyid_t KEYNO2 = 8; @@ -79,7 +89,8 @@ void test_AddTrustedKeys() { TEST_ASSERT_TRUE(authistrusted(KEYNO2)); } -void test_AddUntrustedKey() { +void +test_AddUntrustedKey(void) { const keyid_t KEYNO = 3; AddUntrustedKey(KEYNO); @@ -87,7 +98,8 @@ void test_AddUntrustedKey() { TEST_ASSERT_FALSE(authistrusted(KEYNO)); } -void test_HaveKeyCorrect() { +void +test_HaveKeyCorrect(void) { const keyid_t KEYNO = 3; AddTrustedKey(KEYNO); @@ -96,21 +108,24 @@ void test_HaveKeyCorrect() { TEST_ASSERT_TRUE(authhavekey(KEYNO)); } -void test_HaveKeyIncorrect() { +void +test_HaveKeyIncorrect(void) { const keyid_t KEYNO = 2; TEST_ASSERT_FALSE(auth_havekey(KEYNO)); TEST_ASSERT_FALSE(authhavekey(KEYNO)); } -void test_AddWithAuthUseKey() { +void +test_AddWithAuthUseKey(void) { const keyid_t KEYNO = 5; const char* KEY = "52a"; TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (u_char*)KEY)); } -void test_EmptyKey() { +void +test_EmptyKey(void) { const keyid_t KEYNO = 3; const char* KEY = ""; |