[asterisk-commits] mmichelson: branch mmichelson/acl-v6 r276264 - /team/mmichelson/acl-v6/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 13 18:22:40 CDT 2010
Author: mmichelson
Date: Tue Jul 13 18:22:29 2010
New Revision: 276264
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276264
Log:
Add v6 permit all and deny all ACL tests to test_acl.
Next will be to add some trickier IPv6 ACLs to the test.
Modified:
team/mmichelson/acl-v6/tests/test_acl.c
Modified: team/mmichelson/acl-v6/tests/test_acl.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/acl-v6/tests/test_acl.c?view=diff&rev=276264&r1=276263&r2=276264
==============================================================================
--- team/mmichelson/acl-v6/tests/test_acl.c (original)
+++ team/mmichelson/acl-v6/tests/test_acl.c Tue Jul 13 18:22:29 2010
@@ -116,8 +116,10 @@
AST_TEST_DEFINE(acl)
{
- struct acl permitall = { "0.0.0.0/0", "permit" };
- struct acl denyall = { "0.0.0.0/0", "deny" };
+ struct acl permitallv4 = { "0.0.0.0/0", "permit" };
+ struct acl denyallv4 = { "0.0.0.0/0", "deny" };
+ struct acl permitallv6 = { "::/0", "permit" };
+ struct acl denyallv6 = { "::/0", "deny" };
struct acl acl1[] = {
{ "0.0.0.0/0.0.0.0", "deny" },
{ "10.0.0.0/255.0.0.0", "permit" },
@@ -143,8 +145,10 @@
{ "172.16.0.1", AST_SENSE_DENY, AST_SENSE_ALLOW },
};
- struct ast_ha *permit_ha = NULL;
- struct ast_ha *deny_ha = NULL;
+ struct ast_ha *permit_hav4 = NULL;
+ struct ast_ha *deny_hav4 = NULL;
+ struct ast_ha *permit_hav6 = NULL;
+ struct ast_ha *deny_hav6 = NULL;
struct ast_ha *ha1 = NULL;
struct ast_ha *ha2 = NULL;
enum ast_test_result_state res = AST_TEST_PASS;
@@ -163,13 +167,25 @@
break;
}
- if (!(permit_ha = ast_append_ha(permitall.access, permitall.host, permit_ha, &err))) {
+ if (!(permit_hav4 = ast_append_ha(permitallv4.access, permitallv4.host, permit_hav4, &err))) {
ast_test_status_update(test, "Failed to create permit_all ACL\n");
res = AST_TEST_FAIL;
goto acl_cleanup;
}
- if (!(deny_ha = ast_append_ha(denyall.access, denyall.host, deny_ha, &err))) {
+ if (!(deny_hav4 = ast_append_ha(denyallv4.access, denyallv4.host, deny_hav4, &err))) {
+ ast_test_status_update(test, "Failed to create deny_all ACL\n");
+ res = AST_TEST_FAIL;
+ goto acl_cleanup;
+ }
+
+ if (!(permit_hav6 = ast_append_ha(permitallv6.access, permitallv6.host, permit_hav6, &err))) {
+ ast_test_status_update(test, "Failed to create permit_all ACL\n");
+ res = AST_TEST_FAIL;
+ goto acl_cleanup;
+ }
+
+ if (!(deny_hav6 = ast_append_ha(denyallv6.access, denyallv6.host, deny_hav6, &err))) {
ast_test_status_update(test, "Failed to create deny_all ACL\n");
res = AST_TEST_FAIL;
goto acl_cleanup;
@@ -195,26 +211,44 @@
for (i = 0; i < ARRAY_LEN(acl_tests); ++i) {
struct ast_sockaddr addr;
- int permit_res;
- int deny_res;
+ int permit_resv4;
+ int permit_resv6;
+ int deny_resv4;
+ int deny_resv6;
int acl1_res;
int acl2_res;
ast_sockaddr_parse(&addr, acl_tests[i].test_address, PARSE_PORT_FORBID);
- permit_res = ast_apply_ha(permit_ha, &addr);
- deny_res = ast_apply_ha(deny_ha, &addr);
+ permit_resv4 = ast_apply_ha(permit_hav4, &addr);
+ deny_resv4 = ast_apply_ha(deny_hav4, &addr);
+ permit_resv6 = ast_apply_ha(permit_hav6, &addr);
+ deny_resv6 = ast_apply_ha(deny_hav6, &addr);
acl1_res = ast_apply_ha(ha1, &addr);
acl2_res = ast_apply_ha(ha2, &addr);
- if (permit_res != AST_SENSE_ALLOW) {
+ if (permit_resv4 != AST_SENSE_ALLOW) {
ast_test_status_update(test, "Access denied to %s on permit_all ACL\n",
acl_tests[i].test_address);
res = AST_TEST_FAIL;
goto acl_cleanup;
}
- if (deny_res != AST_SENSE_DENY) {
+ if (deny_resv4 != AST_SENSE_DENY) {
+ ast_test_status_update(test, "Access allowed to %s on deny_all ACL\n",
+ acl_tests[i].test_address);
+ res = AST_TEST_FAIL;
+ goto acl_cleanup;
+ }
+
+ if (permit_resv6 != AST_SENSE_ALLOW) {
+ ast_test_status_update(test, "Access denied to %s on permit_all ACL\n",
+ acl_tests[i].test_address);
+ res = AST_TEST_FAIL;
+ goto acl_cleanup;
+ }
+
+ if (deny_resv6 != AST_SENSE_DENY) {
ast_test_status_update(test, "Access allowed to %s on deny_all ACL\n",
acl_tests[i].test_address);
res = AST_TEST_FAIL;
@@ -237,11 +271,17 @@
}
acl_cleanup:
- if (permit_ha) {
- ast_free_ha(permit_ha);
- }
- if (deny_ha) {
- ast_free_ha(deny_ha);
+ if (permit_hav4) {
+ ast_free_ha(permit_hav4);
+ }
+ if (deny_hav4) {
+ ast_free_ha(deny_hav4);
+ }
+ if (permit_hav6) {
+ ast_free_ha(permit_hav6);
+ }
+ if (deny_hav6) {
+ ast_free_ha(deny_hav6);
}
if (ha1) {
ast_free_ha(ha1);
More information about the asterisk-commits
mailing list