summaryrefslogtreecommitdiff
path: root/test/acl3744.c
blob: 5f0bf8bf649ec80a72087d9ff3ca11f6084fd4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* 
   Dummy ACL tests
   Copyright (C) 2001-2007, Joe Orton <joe@manyfish.co.uk>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "ne_acl3744.h"

#include "tests.h"
#include "child.h"
#include "utils.h"

/**** DUMMY TESTS: just makes sure the stuff doesn't dump core. */

static int test_acl(const char *uri, ne_acl_entry *es, int nume)
{
    ne_session *sess;

    CALL(make_session(&sess, single_serve_string, 
		      "HTTP/1.1 200 OK\r\n"
		      "Connection: close\r\n\r\n"));
    
    ON(ne_acl3744_set(sess, uri, es, nume));
    
    CALL(await_server());
    ne_session_destroy(sess);
    
    return OK;
}

static int grant_all(void)
{
    ne_acl_entry e = {0};

    e.target = ne_acl_all;
    e.type = ne_acl_grant;
    e.privileges = NE_ACL_ALL;

    CALL(test_acl("/foo", &e, 1));

    return OK;
}

static int deny_all(void)
{
    ne_acl_entry e = {0};

    e.target = ne_acl_all;
    e.type = ne_acl_deny;
    e.privileges = NE_ACL_ALL;

    CALL(test_acl("/foo", &e, 1));

    return OK;
}

static int deny_one(void)
{
    ne_acl_entry e = {0};

    e.target = ne_acl_href;
    e.tname = "http://webdav.org/users/joe";
    e.type = ne_acl_deny;
    e.privileges = NE_ACL_ALL;

    CALL(test_acl("/foo", &e, 1));

    return OK;
}       

static int deny_byprop(void)
{
    ne_acl_entry e = {0};

    e.target = ne_acl_property;
    e.type = ne_acl_deny;
    e.tname = "owner";
    e.privileges = NE_ACL_ALL;

    CALL(test_acl("/foo", &e, 1));

    return OK;
}

ne_test tests[] = {
    T(grant_all),
    T(deny_all),
    T(deny_one),
    T(deny_byprop),
    T(NULL)
};