Files
mars_nwe_pcab/tests/test_nds_schema.c

26 lines
1.7 KiB
C

#include "nds_directory.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
int main(int argc,char **argv){
sqlite3 *db=NULL;struct nds_entry e;struct nds_attr a[NDS_ATTR_MAX];size_t n=0;int matched=0;
assert(argc==2&&nds_open(&db,argv[1])==NDS_OK);
assert(nds_resolve(db,"CN=MARS_SYS.OU=SERVERS.O=HOME",&e)==NDS_OK);
assert(nds_attributes(db,e.id,NULL,0,&n)==NDS_BUFFER_SMALL&&n==4);
memset(a,0,sizeof a);assert(nds_attributes(db,e.id,a,1,&n)==NDS_BUFFER_SMALL&&a[0].name==NULL);
assert(nds_attributes(db,e.id,a,NDS_ATTR_MAX,&n)==NDS_OK&&n==4);
assert(!strcmp(a[2].name,"Host Server")&&a[2].kind==NDS_ATTR_DN&&!strcmp(a[2].value,"CN=MARS.OU=SERVERS.O=HOME"));
assert(nds_compare(db,e.id,"host server","mars.servers.home",&matched)==NDS_OK&&matched);
assert(nds_compare(db,e.id,"host server","missing.home",&matched)==NDS_OK&&!matched);
assert(nds_compare(db,e.id,"host resource name","sys",&matched)==NDS_OK&&matched);
assert(nds_compare(db,e.id,"host resource name","DATA",&matched)==NDS_OK&&!matched);
assert(nds_compare(db,e.id,"Password","secret",&matched)==NDS_NOT_FOUND&&!matched);
assert(nds_resolve(db,"CN=ALICE.OU=USERS.O=HOME",&e)==NDS_OK);
assert(nds_compare(db,e.id,"Login Disabled","FALSE",&matched)==NDS_OK&&matched);
assert(nds_compare(db,e.id,"Login Disabled","maybe",&matched)==NDS_INVALID&&!matched);
assert(nds_compare(db,e.id,"Object Class","USER",&matched)==NDS_OK&&matched);
assert(nds_attributes(db,UINT32_MAX,a,NDS_ATTR_MAX,&n)==NDS_INVALID&&n==0);
assert(sqlite3_exec(db,"DELETE FROM mars_nds_volume",NULL,NULL,NULL)==SQLITE_READONLY);
sqlite3_close(db);puts("PASS native attributes, typed DN/bool/string compare, missing attributes, bounds, read-only DB");return 0;
}