acl3744.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Dummy ACL tests
  3. Copyright (C) 2001-2007, 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_acl3744.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_acl3744_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.target = ne_acl_all;
  34. e.type = ne_acl_grant;
  35. e.privileges = NE_ACL_ALL;
  36. CALL(test_acl("/foo", &e, 1));
  37. return OK;
  38. }
  39. static int deny_all(void)
  40. {
  41. ne_acl_entry e = {0};
  42. e.target = ne_acl_all;
  43. e.type = ne_acl_deny;
  44. e.privileges = NE_ACL_ALL;
  45. CALL(test_acl("/foo", &e, 1));
  46. return OK;
  47. }
  48. static int deny_one(void)
  49. {
  50. ne_acl_entry e = {0};
  51. e.target = ne_acl_href;
  52. e.tname = "http://webdav.org/users/joe";
  53. e.type = ne_acl_deny;
  54. e.privileges = NE_ACL_ALL;
  55. CALL(test_acl("/foo", &e, 1));
  56. return OK;
  57. }
  58. static int deny_byprop(void)
  59. {
  60. ne_acl_entry e = {0};
  61. e.target = ne_acl_property;
  62. e.type = ne_acl_deny;
  63. e.tname = "owner";
  64. e.privileges = NE_ACL_ALL;
  65. CALL(test_acl("/foo", &e, 1));
  66. return OK;
  67. }
  68. ne_test tests[] = {
  69. T(grant_all),
  70. T(deny_all),
  71. T(deny_one),
  72. T(deny_byprop),
  73. T(NULL)
  74. };