Skip to content

Commit

Permalink
Unit test for SHA-256 auth header
Browse files Browse the repository at this point in the history
  • Loading branch information
Maratk1n authored and orgads committed Jan 14, 2024
1 parent 184d20e commit 925e67a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,20 @@ TEST(DigestAuth, BasicVerification) {
free(header);
}

#if defined(USE_SHA256)
TEST(DigestAuth, BasicVerificationSHA256) {
char* header = strdup(("Digest \r\n"
" realm=\"[email protected]\",\r\n"
" nonce=\"ZaGxV2WhsCtREI2EsiD1LR0RYd\"\r\n,"
" algorithm=SHA-256"));
char result[255];
createAuthHeader("testuser", "secret", "REGISTER", "sip:example.com", "hello world", header, NULL, NULL, NULL, 1, result, 255);
EXPECT_STREQ("Digest username=\"testuser\",realm=\"[email protected]\",uri=\"sip:sip:example.com\",nonce=\"ZaGxV2WhsCtREI2EsiD1LR0RYd\",response=\"91b58523b983191b52d14455a2599631990110c974ed2e4b4b49bc6053af04ce\",algorithm=SHA-256", result);
EXPECT_EQ(1, verifyAuthHeader("testuser", "secret", "REGISTER", result, "hello world"));
free(header);
}
#endif

TEST(DigestAuth, qop) {
char result[1024];
char* header = strdup(("Digest \r\n"
Expand Down

0 comments on commit 925e67a

Please sign in to comment.