[Cvs-nserver-commits] CVS: cvs-nserver/acl check_acl.c,1.1.2.1,1.1.2.2
Brought to you by:
tyranny
From: Alexey M. <ty...@us...> - 2001-08-29 17:31:41
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv25082 Modified Files: Tag: NCLI-1-11-1 check_acl.c Log Message: More tests for branch- and dir-level ACLs Index: check_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_acl.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- check_acl.c 2001/08/26 20:44:02 1.1.2.1 +++ check_acl.c 2001/08/29 17:31:38 1.1.2.2 @@ -16,16 +16,94 @@ */ -#include "acl.h" +#include "branch-acl.h" #include <assert.h> +#include <errno.h> +#include <fcntl.h> #include <stdlib.h> +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#define TOP_CHECK_DIR "/tmp/acl-test" + int -main (int argc, char *argv[]) +main (void) { - DIR_ACL *topdir_acl = start_acl_traverse("/tmp/acl-test"); + char *top_dir = TOP_CHECK_DIR; + int fd; + int new_perm; + + DIR_ACL *topdir_acl; + BRANCH_ACL *foo_acl; + + /* check that ACLs don't work for non-existing directory */ + + topdir_acl = start_acl_traverse(top_dir); + assert(topdir_acl == NULL); + assert(errno == ENOENT); + + /* create that directory */ + if (mkdir(TOP_CHECK_DIR, 0755) == -1) { + perror("check_acl"); + exit (1); + } + + /* check that ACLs get created for existing directory */ + topdir_acl = start_acl_traverse(top_dir); assert(topdir_acl != NULL); - check_reading(topdir_acl, "foo"); + /* check that ACLs don't work for non-existing file */ + foo_acl = get_branch_acl(topdir_acl, "foo"); + + assert(foo_acl == NULL); + + /* create that file */ + if ((fd = creat(TOP_CHECK_DIR "/foo", 0644)) == -1) { + perror("check_acl"); + exit (1); + } + if (close(fd) == -1) { + perror("check_acl"); + exit(1); + } + + /* get default permissions for existing file */ + foo_acl = get_branch_acl(topdir_acl, "foo"); + assert(foo_acl != NULL); + + /* default permissions allow to checkin/checkout revision on any branch */ + assert(branch_permission_granted(foo_acl, "trunk", "vasya", + branch_perm_checkout)); + + /* set only checkout permissions for vasya, check it */ + new_perm = set_branch_acl(foo_acl, "trunk", "vasya", branch_perm_checkout); + assert(new_perm == branch_perm_checkout); + + assert(branch_permission_granted(foo_acl, "trunk", "vasya", + branch_perm_checkout)); + + assert(!branch_permission_granted(foo_acl, "trunk", "vasya", + branch_perm_checkin)); + + /* set only checkin permissions for vasya, check it */ + new_perm = set_branch_acl(foo_acl, "trunk", "vasya", branch_perm_checkin); + assert(new_perm == branch_perm_checkin); + + assert(!branch_permission_granted(foo_acl, "trunk", "vasya", + branch_perm_checkout)); + + assert(branch_permission_granted(foo_acl, "trunk", "vasya", + branch_perm_checkin)); + + /* check that petya cannot get to file with ACLs */ + assert(!branch_permission_granted(foo_acl, "trunk", "petya", + branch_perm_checkout)); + + assert(!branch_permission_granted(foo_acl, "trunk", "petya", + branch_perm_checkin)); + + exit (0); } |