oldacl.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Dummy ACL tests
  3. Copyright (C) 2001-2003, Joe Orton <[email protected]>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "ne_acl.h"
  17. #include "tests.h"
  18. #include "child.h"
  19. #include "utils.h"
  20. /**** DUMMY TESTS: just makes sure the stuff doesn't dump core. */
  21. static int test_acl(const char *uri, ne_acl_entry *es, int nume)
  22. {
  23. ne_session *sess;
  24. CALL(make_session(&sess, single_serve_string,
  25. "HTTP/1.1 200 OK\r\n"
  26. "Connection: close\r\n\r\n"));
  27. ON(ne_acl_set(sess, uri, es, nume));
  28. return destroy_and_wait(sess);
  29. }
  30. static int grant_all(void)
  31. {
  32. ne_acl_entry e = {0};
  33. e.apply = ne_acl_all;
  34. e.type = ne_acl_grant;
  35. CALL(test_acl("/foo", &e, 1));
  36. return OK;
  37. }
  38. static int deny_all(void)
  39. {
  40. ne_acl_entry e = {0};
  41. e.apply = ne_acl_all;
  42. e.type = ne_acl_deny;
  43. CALL(test_acl("/foo", &e, 1));
  44. return OK;
  45. }
  46. static int deny_one(void)
  47. {
  48. ne_acl_entry e = {0};
  49. e.apply = ne_acl_href;
  50. e.type = ne_acl_deny;
  51. e.principal = "http://webdav.org/users/joe";
  52. CALL(test_acl("/foo", &e, 1));
  53. return OK;
  54. }
  55. static int deny_byprop(void)
  56. {
  57. ne_acl_entry e = {0};
  58. e.apply = ne_acl_property;
  59. e.type = ne_acl_deny;
  60. e.principal = "owner";
  61. CALL(test_acl("/foo", &e, 1));
  62. return OK;
  63. }
  64. ne_test tests[] = {
  65. T(grant_all),
  66. T(deny_all),
  67. T(deny_one),
  68. T(deny_byprop),
  69. T(NULL)
  70. };