[asterisk-commits] elguero: trunk r365248 - /trunk/tests/test_security_events.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 3 14:36:38 CDT 2012


Author: elguero
Date: Thu May  3 14:36:33 2012
New Revision: 365248

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365248
Log:
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/

Modified:
    trunk/tests/test_security_events.c

Modified: trunk/tests/test_security_events.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_security_events.c?view=diff&rev=365248&r1=365247&r2=365248
==============================================================================
--- trunk/tests/test_security_events.c (original)
+++ trunk/tests/test_security_events.c Thu May  3 14:36:33 2012
@@ -51,6 +51,8 @@
 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 @@
 	[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 @@
 			.addr = &addr_remote,
 			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
 		},
+		.challenge          = "GoOdChAlLeNgE",
+		.received_challenge = "BaDcHaLlEnGe",
+		.received_hash      = "3ad9023adf309",
 	};
 
 	char localaddr[53];
@@ -560,6 +567,80 @@
 	ast_sockaddr_parse(&addr_remote, remoteaddr, 0);
 
 	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)




More information about the asterisk-commits mailing list