[asterisk-commits] elguero: branch 10 r365014 - /branches/10/tests/test_security_events.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 2 11:16:07 CDT 2012


Author: elguero
Date: Wed May  2 11:16:03 2012
New Revision: 365014

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

(issue ASTERISK-19760)
Reported by: Michael L. Young
Tested by: Michael L. Young
Patches:
issue-asterisk-19760-branch10.diff uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/1877/

Modified:
    branches/10/tests/test_security_events.c

Modified: branches/10/tests/test_security_events.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/tests/test_security_events.c?view=diff&rev=365014&r1=365013&r2=365014
==============================================================================
--- branches/10/tests/test_security_events.c (original)
+++ branches/10/tests/test_security_events.c Wed May  2 11:16:03 2012
@@ -50,6 +50,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] = {
@@ -66,6 +68,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)
@@ -552,6 +556,9 @@
 			.sin = &sin_remote,
 			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
 		},
+		.challenge          = "GoOdChAlLeNgE",
+		.received_challenge = "BaDcHaLlEnGe",
+		.received_hash      = "3ad9023adf309",
 	};
 
 	inet_aton("10.200.100.30", &sin_local.sin_addr);
@@ -561,6 +568,82 @@
 	sin_remote.sin_port = htons(1234);
 
 	ast_security_event_report(AST_SEC_EVT(&inval_password));
+}
+
+static void evt_gen_chal_sent(void)
+{
+	struct sockaddr_in sin_local = {
+		.sin_family = AF_INET
+	};
+	struct sockaddr_in sin_remote = {
+		.sin_family = AF_INET
+	};
+
+	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 = {
+			.sin  = &sin_local,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.common.remote_addr = {
+			.sin = &sin_remote,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.challenge         = "IcHaLlEnGeYoU",
+	};
+
+	inet_aton("10.200.10.30", &sin_local.sin_addr);
+	sin_local.sin_port = htons(5392);
+
+	inet_aton("10.200.10.31", &sin_remote.sin_addr);
+	sin_remote.sin_port = htons(1443);
+
+	ast_security_event_report(AST_SEC_EVT(&chal_sent));
+}
+
+static void evt_gen_inval_transport(void)
+{
+	struct sockaddr_in sin_local = {
+		.sin_family = AF_INET
+	};
+	struct sockaddr_in sin_remote = {
+		.sin_family = AF_INET
+	};
+
+	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 = {
+			.sin  = &sin_local,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.common.remote_addr = {
+			.sin = &sin_remote,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_TCP,
+		},
+		.transport          = "UDP",
+	};
+
+	inet_aton("10.200.103.45", &sin_local.sin_addr);
+	sin_local.sin_port = htons(8223);
+
+	inet_aton("10.200.103.44", &sin_remote.sin_addr);
+	sin_remote.sin_port = htons(1039);
+
+	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