Deleted Added
full compact
test_acl_nfs4.c (313570) test_acl_nfs4.c (315432)
1/*-
2 * Copyright (c) 2003-2010 Tim Kientzle
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 145 unchanged lines hidden (view full) ---

154 int i;
155
156 /* Create a simple archive_entry. */
157 assert((ae = archive_entry_new()) != NULL);
158 archive_entry_set_pathname(ae, "file");
159 archive_entry_set_mode(ae, S_IFREG | 0777);
160
161 /* Store and read back some basic ACL entries. */
1/*-
2 * Copyright (c) 2003-2010 Tim Kientzle
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 145 unchanged lines hidden (view full) ---

154 int i;
155
156 /* Create a simple archive_entry. */
157 assert((ae = archive_entry_new()) != NULL);
158 archive_entry_set_pathname(ae, "file");
159 archive_entry_set_mode(ae, S_IFREG | 0777);
160
161 /* Store and read back some basic ACL entries. */
162 archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
162 assertEntrySetAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
163
164 /* Check that entry contains only NFSv4 types */
165 assert((archive_entry_acl_types(ae) &
166 ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0);
167 assert((archive_entry_acl_types(ae) &
168 ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0);
169
170 assertEqualInt(4,
171 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
163
164 /* Check that entry contains only NFSv4 types */
165 assert((archive_entry_acl_types(ae) &
166 ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0);
167 assert((archive_entry_acl_types(ae) &
168 ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0);
169
170 assertEqualInt(4,
171 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
172 archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
172 assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
173 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
174
175 /* A more extensive set of ACLs. */
173 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
174
175 /* A more extensive set of ACLs. */
176 archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
176 assertEntrySetAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
177 assertEqualInt(32,
178 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
177 assertEqualInt(32,
178 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
179 archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
179 assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
180 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
181
182 /*
183 * Check that clearing ACLs gets rid of them all by repeating
184 * the first test.
185 */
180 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
181
182 /*
183 * Check that clearing ACLs gets rid of them all by repeating
184 * the first test.
185 */
186 archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
186 assertEntrySetAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
187 failure("Basic ACLs shouldn't be stored as extended ACLs");
188 assertEqualInt(4,
189 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
190
191 /*
192 * Different types of malformed ACL entries that should
193 * fail when added to existing NFS4 ACLs.
194 */
187 failure("Basic ACLs shouldn't be stored as extended ACLs");
188 assertEqualInt(4,
189 archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
190
191 /*
192 * Different types of malformed ACL entries that should
193 * fail when added to existing NFS4 ACLs.
194 */
195 archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
195 assertEntrySetAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
196 for (i = 0; i < (int)(sizeof(acls_bad)/sizeof(acls_bad[0])); ++i) {
197 struct archive_test_acl_t *p = &acls_bad[i];
198 failure("Malformed ACL test #%d", i);
199 assertEqualInt(ARCHIVE_FAILED,
200 archive_entry_acl_add_entry(ae,
201 p->type, p->permset, p->tag, p->qual, p->name));
202 failure("Malformed ACL test #%d", i);
203 assertEqualInt(32,
204 archive_entry_acl_reset(ae,
205 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
206 }
207 archive_entry_free(ae);
208}
196 for (i = 0; i < (int)(sizeof(acls_bad)/sizeof(acls_bad[0])); ++i) {
197 struct archive_test_acl_t *p = &acls_bad[i];
198 failure("Malformed ACL test #%d", i);
199 assertEqualInt(ARCHIVE_FAILED,
200 archive_entry_acl_add_entry(ae,
201 p->type, p->permset, p->tag, p->qual, p->name));
202 failure("Malformed ACL test #%d", i);
203 assertEqualInt(32,
204 archive_entry_acl_reset(ae,
205 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
206 }
207 archive_entry_free(ae);
208}