summaryrefslogtreecommitdiff
path: root/tests/test_security_events.c
diff options
context:
space:
mode:
authorMichael L. Young <elgueromexicano@gmail.com>2012-05-03 19:36:33 +0000
committerMichael L. Young <elgueromexicano@gmail.com>2012-05-03 19:36:33 +0000
commitfdf3cd0e2ef0ae84e24adf93639671e6a5096543 (patch)
tree37fb22e2743aff6d644354011071350617902966 /tests/test_security_events.c
parent69e2a2b265b249cb64fa7f0fc927977dba760c1d (diff)
Update security events unit tests
The security events framework API was changed in Asterisk 10 but the unit tests were not updated at the same time. This patch does the following: * Adds two more security events that were added to the API * Add challenge, received_challenge and received_hash in the inval_password security event unit test (Closes issue ASTERISK-19760) Reported by: Michael L. Young Tested by: Michael L. Young Patches: issue-asterisk-19760-trunk.diff uploaded by Michael L. Young (license 5026) Review: https://reviewboard.asterisk.org/r/1897/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_security_events.c')
-rw-r--r--tests/test_security_events.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/test_security_events.c b/tests/test_security_events.c
index 0604f4962..4f2510f14 100644
--- a/tests/test_security_events.c
+++ b/tests/test_security_events.c
@@ -51,6 +51,8 @@ static void evt_gen_successful_auth(void);
static void evt_gen_unexpected_addr(void);
static void evt_gen_chal_resp_failed(void);
static void evt_gen_inval_password(void);
+static void evt_gen_chal_sent(void);
+static void evt_gen_inval_transport(void);
typedef void (*evt_generator)(void);
static const evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
@@ -67,6 +69,8 @@ static const evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
[AST_SECURITY_EVENT_UNEXPECTED_ADDR] = evt_gen_unexpected_addr,
[AST_SECURITY_EVENT_CHAL_RESP_FAILED] = evt_gen_chal_resp_failed,
[AST_SECURITY_EVENT_INVAL_PASSWORD] = evt_gen_inval_password,
+ [AST_SECURITY_EVENT_CHAL_SENT] = evt_gen_chal_sent,
+ [AST_SECURITY_EVENT_INVAL_TRANSPORT] = evt_gen_inval_transport,
};
static void evt_gen_failed_acl(void)
@@ -548,6 +552,9 @@ static void evt_gen_inval_password(void)
.addr = &addr_remote,
.transport = AST_SECURITY_EVENT_TRANSPORT_TCP,
},
+ .challenge = "GoOdChAlLeNgE",
+ .received_challenge = "BaDcHaLlEnGe",
+ .received_hash = "3ad9023adf309",
};
char localaddr[53];
@@ -562,6 +569,80 @@ static void evt_gen_inval_password(void)
ast_security_event_report(AST_SEC_EVT(&inval_password));
}
+static void evt_gen_chal_sent(void)
+{
+ struct ast_sockaddr addr_local = { {0,} };
+ struct ast_sockaddr addr_remote = { {0,} };
+
+ struct timeval session_tv = ast_tvnow();
+ struct ast_security_event_chal_sent chal_sent = {
+ .common.event_type = AST_SECURITY_EVENT_CHAL_SENT,
+ .common.version = AST_SECURITY_EVENT_CHAL_SENT_VERSION,
+ .common.service = "TEST",
+ .common.module = AST_MODULE,
+ .common.account_id = "AccountIDGoesHere",
+ .common.session_id = "SessionIDGoesHere",
+ .common.session_tv = &session_tv,
+ .common.local_addr = {
+ .addr = &addr_local,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TCP,
+ },
+ .common.remote_addr = {
+ .addr = &addr_remote,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TCP,
+ },
+ .challenge = "IcHaLlEnGeYoU",
+ };
+
+ char localaddr[53];
+ char remoteaddr[53];
+
+ ast_copy_string(localaddr, "10.200.10.30:5392", sizeof(localaddr));
+ ast_copy_string(remoteaddr, "10.200.10.31:1443", sizeof(remoteaddr));
+
+ ast_sockaddr_parse(&addr_local, localaddr, 0);
+ ast_sockaddr_parse(&addr_remote, remoteaddr, 0);
+
+ ast_security_event_report(AST_SEC_EVT(&chal_sent));
+}
+
+static void evt_gen_inval_transport(void)
+{
+ struct ast_sockaddr addr_local = { {0,} };
+ struct ast_sockaddr addr_remote = { {0,} };
+
+ struct timeval session_tv = ast_tvnow();
+ struct ast_security_event_inval_transport inval_transport = {
+ .common.event_type = AST_SECURITY_EVENT_INVAL_TRANSPORT,
+ .common.version = AST_SECURITY_EVENT_INVAL_TRANSPORT_VERSION,
+ .common.service = "TEST",
+ .common.module = AST_MODULE,
+ .common.account_id = "AccountIDGoesHere",
+ .common.session_id = "SessionIDGoesHere",
+ .common.session_tv = &session_tv,
+ .common.local_addr = {
+ .addr = &addr_local,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TCP,
+ },
+ .common.remote_addr = {
+ .addr = &addr_remote,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TCP,
+ },
+ .transport = "UDP",
+ };
+
+ char localaddr[53];
+ char remoteaddr[53];
+
+ ast_copy_string(localaddr, "10.200.103.45:8223", sizeof(localaddr));
+ ast_copy_string(remoteaddr, "10.200.103.44:1039", sizeof(remoteaddr));
+
+ ast_sockaddr_parse(&addr_local, localaddr, 0);
+ ast_sockaddr_parse(&addr_remote, remoteaddr, 0);
+
+ ast_security_event_report(AST_SEC_EVT(&inval_transport));
+}
+
static void gen_events(struct ast_cli_args *a)
{
unsigned int i;