summaryrefslogtreecommitdiffstats
path: root/lib/libaccess/utest/acltest.cpp
blob: c643f87302bb21f3022521874504297dd67575d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
#include	<stdio.h>
#include	<netsite.h>
#include	<base/session.h>
#include	<base/daemon.h>
#include	<base/systhr.h>
#include	<libaccess/nserror.h>
#include	<libaccess/acl.h>
#include	"../aclpriv.h"
#include	<libaccess/aclproto.h>
#include	"../aclcache.h"
#include	<libaccess/las.h>


extern	ACLListHandle_t *ACL_ParseFile(NSErr_t *errp, char *filename);

int
TestEvalFunc(NSErr_t *errp, char *attr, CmpOp_t comparator,
             char *attr_pattern, ACLCachable_t *cachable,
             void **las_cookie, PList_t subject, PList_t resource,
             PList_t auth_info, PList_t global_auth)
{
	return 0;
}

void
TestFlushFunc(void **cookie)
{
	return;
}

static int parse_dburl (NSErr_t *errp, ACLDbType_t dbtype,
			const char *dbname, const char *url,
			PList_t plist, void **db)
{
    *db = strdup(url);
    return 0;
}


main()
{
	ACLListHandle_t	*acl_list;
	int		result;
	ACLCachable_t cachable = 0;
	void	*las_cookie=NULL;
	ACLEvalHandle_t	eval;
	char	*rights[3];
	char	filename[20];
	char	newfilename[25];
	int		i;
	char	*map_generic[7];
	LASEvalFunc_t	Eval_funcp;
	LASFlushFunc_t	Flush_funcp;
	char	*bong;
	char	*bong_type;
	char	*acl_tag;
	int	expr_num;
	int	ii;
	char	**name_list;
	ACLMethod_t	method=NULL;
	ACLDbType_t	dbtype=NULL;
	int	rv;
	ACLAttrGetterList_t aglist;
	ACLAttrGetter_t *agptr;
	char **names;
	int cnt;
	
	systhread_init("acl_utest");

        char	*acl_file_list[3] = {"aclfile6", "aclfile7", NULL};
        char	*new_filename = "merge6_7";
        char	*acl_name_list[3] = {"aclfile6", "aclfile7", NULL};
        char	*new_aclname = "merge6_7";
        char	*bad_acl_file_list[3] = {"bad_aclfile6", "bad_aclfile7", NULL};

        if ( ACL_FileMergeFile(NULL, new_filename, bad_acl_file_list, 0) < 0 ) {
            printf("Failed ACL_FileMergeFile() test.\n");
        }

        if ( ACL_FileMergeFile(NULL, new_filename, acl_file_list, 0) < 0 ) {
            printf("Failed ACL_FileMergeFile() test.\n");
        }

        if ( ACL_FileMergeAcl(NULL, new_filename, acl_name_list, new_aclname, 0) < 0 ) {
            printf("Failed ACL_FileMergeAcl() test.\n");
        }

	/*	LAS Registration Unit Tests	*/

	ACL_Init();

	rv = ACL_MethodRegister(NULL, "one", &method);
	printf("Method one is #%d, rv=%d\n", (int)method, rv);

	rv = ACL_MethodRegister(NULL, "two", &method);
	printf("Method two is #%d, rv=%d\n", (int)method, rv);

	rv = ACL_MethodRegister(NULL, "one", &method);
	printf("Method one repeated is #%d, rv=%d\n", (int)method, rv);

	rv = ACL_MethodRegister(NULL, "three", &method);
	printf("Method three is #%d, rv=%d\n", (int)method, rv);

	rv = ACL_MethodNamesGet(NULL, &names, &cnt);

	for(i = 0; i < cnt; i++) {
	    printf("\tMethod[%d] = \"%s\"\n", i, names[i]);
	}

	ACL_MethodNamesFree(NULL, names, cnt);
	
	if (!ACL_MethodIsEqual(NULL, method, method)) {
	    printf("Error comparing methods");
	}

	if (!ACL_MethodNameIsEqual(NULL, method, "three")) {
	    printf("Error comparing method by name");
	}

	/* Since LDAP is already registered by ACL_Init, the first number
	 * we'll get is actually 2.
	 */
	rv = ACL_DbTypeRegister(NULL, "two", parse_dburl, &dbtype);
	printf("DbType two is #%d, rv=%d\n", (int)dbtype, rv);

	rv = ACL_DbTypeRegister(NULL, "three", parse_dburl, &dbtype);
	printf("DbType three is #%d, rv=%d\n", (int)dbtype, rv);

	rv = ACL_DbTypeRegister(NULL, "two", parse_dburl, &dbtype);
	printf("DbType two repeated is #%d, rv=%d\n", (int)dbtype, rv);

	rv = ACL_DbTypeRegister(NULL, "four", parse_dburl, &dbtype);
	printf("DbType four is #%d, rv=%d\n", (int)dbtype, rv);

	if (!ACL_DbTypeIsEqual(NULL, dbtype, dbtype)) {
	    printf("Error comparing dbtypes\n");
	}

	if (!ACL_DbTypeNameIsEqual(NULL, dbtype, "four")) {
	    printf("Error comparing dbtype by name\n");
	}

	rv = ACL_DatabaseRegister(NULL, dbtype, "db1", "url for db1", NULL);
	if (rv < 0) {
	    printf("ACL_DatabaseRegister failed for db1\n");
	}
	
	rv = ACL_DatabaseRegister(NULL, dbtype, "db2", "url for db2", NULL);
	if (rv < 0) {
	    printf("ACL_DatabaseRegister failed for db2\n");
	}
	
	rv = ACL_DatabaseRegister(NULL, dbtype, "db3", "url for db3", NULL);
	if (rv < 0) {
	    printf("ACL_DatabaseRegister failed for db3\n");
	}
	
	rv = ACL_DatabaseNamesGet(NULL, &names, &cnt);

	for(i = 0; i < cnt; i++) {
	    printf("\tDatabase[%d] = \"%s\"\n", i, names[i]);
	}

	if (ACL_AttrGetterRegister(NULL, "attr", (ACLAttrGetterFn_t)2, (ACLMethod_t)10, (ACLDbType_t)20, ACL_AT_FRONT, NULL)) {
	    printf("Error registering attr getter\n");
	}

	if (ACL_AttrGetterRegister(NULL, "attr", (ACLAttrGetterFn_t)3, (ACLMethod_t)10, (ACLDbType_t)20, ACL_AT_END, NULL)) {
	    printf("Error registering attr getter\n");
	}

	if (ACL_AttrGetterRegister(NULL, "attr", (ACLAttrGetterFn_t)1, (ACLMethod_t)10, (ACLDbType_t)20, ACL_AT_FRONT, NULL)) {
	    printf("Error registering attr getter\n");
	}

	if (ACL_AttrGetterRegister(NULL, "attr", (ACLAttrGetterFn_t)4, (ACLMethod_t)10, (ACLDbType_t)20, ACL_AT_END, NULL)) {
	    printf("Error registering attr getter\n");
	}

	if (ACL_AttrGetterFind(NULL, "attr", &aglist)) {
	    printf("Error finding attr getter\n");
	}

	for (i = 0, agptr = ACL_AttrGetterFirst(&aglist);
         i < 4;
         i++, agptr = ACL_AttrGetterNext(&aglist, agptr)) {

        if (agptr) {
            printf("position %d\n", (int)(agptr->fn));
        }
        else {
            printf("***Error: missing getter ***\n");
        }
	}

#ifndef	XP_WIN32
	if (ACL_LasRegister(NULL, "test_attr", TestEvalFunc, TestFlushFunc)) {
		printf("Error registering Test LAS functions\n");
	}
	ACL_LasFindEval(NULL, "test_attr", &Eval_funcp);
	if (Eval_funcp != TestEvalFunc) {
		printf("Error finding Eval function - expecting %x, got %x\n",
		TestEvalFunc, Eval_funcp);
	}
	ACL_LasFindFlush(NULL, "test_attr", &Flush_funcp);
	if (Flush_funcp != TestFlushFunc) {
		printf("Error finding Flush function - expecting %x, got %x\n",
		TestFlushFunc, Flush_funcp);
	}
	ACL_LasFindEval(NULL, "wrong_attr", &Eval_funcp);
	if (Eval_funcp != NULL) {
		printf("Error finding Eval function - expecting NULL, got %x\n",
		Eval_funcp);
	}
	ACL_LasFindFlush(NULL, "wrong_attr", &Flush_funcp);
	if (Flush_funcp != NULL) {
		printf("Error finding Flush function - expecting NULL, got %x\n",
		Flush_funcp);
	}
#endif /* !XP_WIN32 */

	/*	ACL Eval Unit Tests
	 */
	rights[0] = "http_get";
	rights[1] = "http_post";
	rights[2] = NULL;

	eval.subject = NULL;
	eval.resource = NULL;

	for (i=0; i<10; i++) {
		sprintf(filename, "aclfile%d", i);
		eval.acllist	= ACL_ParseFile((NSErr_t *)NULL, filename);
                if ( eval.acllist == NULL ) {
			printf("Couldn't parse.\n");
                        continue;
		}

                sprintf(newfilename, "%s.v30", filename);
                if ( ACL_WriteFile(NULL, newfilename, eval.acllist) < 0) {
			printf("Couldn't write %s.\n", newfilename);
		}
		result	= ACL_EvalTestRights(NULL, &eval, &rights[0], 
		http_generic, &bong, &bong_type, &acl_tag, &expr_num);
		ACL_ListDestroy(NULL, eval.acllist);
		printf("%s = %d\n\n", filename, result);
	}

/********************************************************************

 TEST #1

 TEST ACL_ParseString()
 TEST ACL_WriteFile()
 TEST ACL_ParseFile()
 TEST ACL_ListFind()

*********************************************************************/
        acl_list = ACL_ParseString((NSErr_t *)NULL, 
		"version 3.0; acl > franco;");
        if ( acl_list != NULL ) {
        	ACL_ListDestroy(NULL, acl_list);
		printf("Test #1a fails parsed invalid ACL\n");
                goto skip_test;
        }

        acl_list = ACL_ParseString((NSErr_t *)NULL, 
		"version 3.0; acl franco; \nallow (read) user=franco;");
        if ( acl_list == NULL ) {
		printf("Test #1b fails couldn't parse valid ACL\n");
                goto skip_test;
        } else {
		if ( ACL_WriteFile(NULL, "buffer", acl_list) < 0) {
			printf("Test #1b, couldn't write %s.\n", "buffer");
		}
		ACL_ListDestroy(NULL, acl_list);
        }

        acl_list = ACL_ParseString((NSErr_t *)NULL, 
		"version 3.0; acl franco; \njunk (read) user=franco;");
        
        if ( acl_list != NULL ) {
		printf("Test #1c failed missed syntax error\n");
		ACL_ListDestroy(NULL, acl_list);
                goto skip_test;
        }

        acl_list = ACL_ParseString((NSErr_t *)NULL, 
		"version 3.0; acl franco; \nallow (read) user=franco;");
        
        if ( acl_list == NULL ) {
		printf("Test #1d couldn't parse valid ACL\n");
        } else {
		ACL_ListDestroy(NULL, acl_list);
                goto skip_test;
        }

	acl_list= ACL_ParseFile((NSErr_t *)NULL, "buffer");
        if ( acl_list == NULL ) {
		printf("Test #1e, couldn't perform ACL_ParseFile(buffer)\n");
                goto skip_test;
        } else {
		if ( ACL_ListFind(NULL, acl_list, "franco", ACL_CASE_INSENSITIVE) == NULL ) {
			printf("Test #1e, couldn't find %s in %s.\n", "franco", "buffer");
		}
		ACL_ListDestroy(NULL, acl_list);
        }

/********************************************************************

 TEST #2

 TEST ACL_FileDeleteAcl()
 TEST ACL_ParseFile()
 TEST ACL_ListFind()

*********************************************************************/
	if ( ACL_FileDeleteAcl(NULL, "buffer", "franco", ACL_CASE_INSENSITIVE) < 0) {
		printf("Test #2, couldn't write %s.\n", "buffer");
	}
	acl_list= ACL_ParseFile((NSErr_t *)NULL, "buffer");
        if ( acl_list == NULL ) {
		printf("Test #2, couldn't perform ACL_ParseFile(buffer)\n");
                goto skip_test;
        } else {
		if ( ACL_ListFind(NULL, acl_list, "franco", ACL_CASE_INSENSITIVE) ) {
			printf("Couldn't delete %s from %s.\n", "franco", "buffer");
		}
		ACL_ListDestroy(NULL, acl_list);
        }

/********************************************************************

 TEST #3

 TEST ACL_FileSetAcl()
 TEST ACL_ParseFile()
 TEST ACL_ListFind()

*********************************************************************/
	if ( ACL_FileSetAcl(NULL, "buffer", 
		"version 3.0; acl FileSetAcl; \nallow (read) user=franco;",
                ACL_CASE_INSENSITIVE)< 0) {
		printf("Test #3, couldn't ACL_FileSetACL(%s).\n", "FileSetAcl");
	}
	if ( ACL_FileSetAcl(NULL, "buffer", 
		"version 3.0; acl franco; \nallow (read) user=franco;",
                ACL_CASE_INSENSITIVE)< 0) {
		printf("Test #3, couldn't ACL_FileSetACL(%s).\n", "franco");
	}
	acl_list= ACL_ParseFile((NSErr_t *)NULL, "buffer");
        if ( acl_list == NULL ) {
		printf("Test #3, couldn't perform ACL_ParseFile(buffer)\n");
                goto skip_test;
        } else {
		if ( ACL_ListFind(NULL, acl_list, "franco", ACL_CASE_INSENSITIVE) == NULL) {
			printf("Test #3, couldn't set %s in %s.\n", "franco", "buffer");
		}
		if ( ACL_ListFind(NULL, acl_list, "filesetacl", ACL_CASE_INSENSITIVE) == NULL) {
			printf("Test #3, couldn't set %s in %s.\n", "filesetacl", "buffer");
		}
		ACL_ListDestroy(NULL, acl_list);
	}

/********************************************************************

 TEST #4

 TEST ACL_FileRenameAcl()
 TEST ACL_ParseFile()
 TEST ACL_ListFind()

*********************************************************************/
	if ( ACL_FileRenameAcl(NULL, "buffer", "FileSetAcl", "loser", ACL_CASE_INSENSITIVE)< 0) {
		printf("Test #4, fail ACL_FileRenameACL(filesetacl, loser).\n");
	}
	if ( ACL_FileRenameAcl(NULL, "buffer", "franco", "bigdogs", 
                              ACL_CASE_INSENSITIVE)< 0) {
		printf("Test #4, fail ACL_FileRenameACL(franco, bigdogs).\n");
	}
	acl_list= ACL_ParseFile((NSErr_t *)NULL, "buffer");
        if ( acl_list == NULL ) {
		printf("Test #3, couldn't perform ACL_ParseFile(buffer)\n");
                goto skip_test;
        } else {
		if ( ACL_ListFind(NULL, acl_list, "loser", ACL_CASE_INSENSITIVE) == NULL) {
			printf("Test #4, fail rename %s in %s.\n", "loser", "buffer");
		}
		if ( ACL_ListFind(NULL, acl_list, "bigdogs", ACL_CASE_INSENSITIVE) == NULL) {
			printf("Test #4, fail rename %s in %s.\n", "bigdogs", "buffer");
		}
		if ( ACL_ListGetNameList(NULL, acl_list, &name_list) < 0 ) {
			printf("Test #4, yikes, the GetNameList failed.\n");
                } else {
                	for (ii = 0; name_list[ii]; ii++)
                		printf("ACL %s\n", name_list[ii]);
			ACL_NameListDestroy(NULL, name_list);
		}
		ACL_ListDestroy(NULL, acl_list);
	}

	


skip_test:
/********************************************************************

 END

*********************************************************************/

	rights[0] = "html_read";
	rights[1] = "html_write";

	map_generic[0]	= "html_read";
	map_generic[1]	= "html_write";
	map_generic[2]	= "N/A";
	map_generic[3]	= "html_create";
	map_generic[4]	= "html_delete";
	map_generic[5]	= "N/A";
	map_generic[6]	= NULL;

	for (i=10; i<20; i++) {
		sprintf(filename, "aclfile%d", i);
		eval.acllist	= ACL_ParseFile((NSErr_t *)NULL, filename);
		if ( eval.acllist == NULL ) {
			printf("Parse failed.\n");
			continue;
		}
		result	= ACL_EvalTestRights(NULL, &eval, &rights[0], map_generic, &bong, &bong_type, &acl_tag, &expr_num);
		ACL_ListDestroy(NULL, eval.acllist);
		printf("%s = %d\n\n", filename, result);
	}

	/*
	 *	Program LAS Unit Tests
	 */
	char *groups[32] = {
		"http-foo",
		"http-bar",
		"http-grog",
		NULL
	};
	char *programs[32] = {
		"foo, fubar, frobozz",
		"bar, shoo, fly",
		"grog, beer",
		NULL
	};
	struct program_groups program_groups;
	program_groups.groups = groups;
	program_groups.programs = programs;

	result = LASProgramEval(NULL, "program", CMP_OP_EQ, "http-foo, http-bar,http-grog", &cachable, &las_cookie, (PList_t)"foo", (PList_t)&program_groups, NULL, NULL);
	printf("program = foo %d\n\n", result);


	result = LASProgramEval(NULL, "program", CMP_OP_EQ, "http-foo, http-bar,http-grog", &cachable, &las_cookie, (PList_t)"nomatch", (PList_t)&program_groups, NULL, NULL);
	printf("program = nomatch %d\n\n", result);


	result = LASProgramEval(NULL, "program", CMP_OP_EQ, "http-foo, http-bar,http-grog", &cachable, &las_cookie, (PList_t)"beer", (PList_t)&program_groups, NULL, NULL);
	printf("program = beer %d\n\n", result);


	result = LASProgramEval(NULL, "program", CMP_OP_EQ, "http-foo, http-bar, http-grog", &cachable, &las_cookie, (PList_t)"http-grog", (PList_t)&program_groups, NULL, NULL);
	printf("program = http-grog %d\n\n", result);

	result = LASProgramEval(NULL, "program", CMP_OP_EQ, "http-foo", &cachable, &las_cookie, (PList_t)"ubar", (PList_t)&program_groups, NULL, NULL);
	printf("program = ubar %d\n\n", result);


	/*	
	 *	DNS LAS Unit Tests
	 */

	result	= LASDnsEval(NULL, "dnsalias", CMP_OP_EQ, "*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dnsalias = *? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dnsalias", CMP_OP_EQ, "aruba.mcom.com brain251.mcom.com", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dnsalias = aruba.mcom.com brain251.mcom.com? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = *? %d\n\n", result);

	result	= LASDnsEval(NULL, "dns", CMP_OP_NE, "*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns != *? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "aruba.mcom.com", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = aruba.mcom.com? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "ai.mit.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = ai.mit.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "*.ai.mit.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = *.ai.mit.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "*.mit.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = *.mit.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_EQ, "*.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns = *.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_NE, "*.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns != *.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "mistake", CMP_OP_NE, "*.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("mistake != *.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);

	result	= LASDnsEval(NULL, "dns", CMP_OP_GT, "*.edu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("dns > *.edu? %d\n\n", result);

	LASDnsFlush(&las_cookie);


	/* 
	 *	IP LAS Unit Tests
	 */
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = *? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_NE, "*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip != *? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "*.*.*.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = *.*.*.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.*.*.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.*.*.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.*.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.*.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.*", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.*? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.*+255.255.255.255", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.*+255.255.255.255? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.69+255.255.255.254, 123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.69+255.255.255.254, 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_NE, "17.34.51.69+255.255.255.254, 123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip != 17.34.51.69+255.255.255.254, 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.68, 17.34.51.69", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.68, 17.34.51.69? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.68, 17.34.51.69, 123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.68, 17.34.51.69, 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_NE, "17.34.51.68, 17.34.51.69, 123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip != 17.34.51.68, 17.34.51.69, 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.68", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.68? %d\n\n", result);

	LASIpFlush(&las_cookie);

	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.69", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.69? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.51.69+255.255.255.254", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.51.69+255.255.255.254? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.34.50.69+255.255.254.0", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.34.50.69+255.255.254.0? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "17.35.50.69+255.254.0.0", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 17.35.50.69+255.254.0.0? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "16.35.50.69+254.0.0.0", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 16.35.50.69+254.0.0.0? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_EQ, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip = 123.45.67.89? %d\n\n", result);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_NE, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip != 123.45.67.89? %d\n\n", result);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_GT, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip > 123.45.67.89? %d\n\n", result);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_LT, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip < 123.45.67.89? %d\n\n", result);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_GE, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip >= 123.45.67.89? %d\n\n", result);
	
	result	= LASIpEval(NULL, "ip", CMP_OP_LE, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("ip <= 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);
	
	result	= LASIpEval(NULL, "mistake", CMP_OP_LE, "123.45.67.89", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf ("mistake <= 123.45.67.89? %d\n\n", result);

	LASIpFlush(&las_cookie);
	

	/*
	 *	Time of Day unit tests.
	 */
	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_EQ, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time = 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_NE, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time != 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_EQ, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time = 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_NE, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time != 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_EQ, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time = 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_NE, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time != 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GT, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time > 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LT, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time < 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GT, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time > 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LT, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time < 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GT, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time > 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LT, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time < 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GE, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time >= 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LE, "2120", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time <= 2120? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GE, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time >= 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LE, "0700", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time <= 0700? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_GE, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time >= 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LE, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time <= 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "mistake", CMP_OP_LE, "2400", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("mistake <= 2400? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_EQ, "0800-2200", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time = 0800-2200? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_NE, "0800-2200", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time != 0800-2200? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_EQ, "2200-0800", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time = 2200-0800? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_NE, "2200-0800", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time != 2200-0800? %d\n\n", result);

	result	= LASTimeOfDayEval(NULL, "timeofday", CMP_OP_LE, "2200-0800", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("time <= 2200-0800? %d\n\n", result);


	/*
	 *	Day Of Week Unit Tests
	 */
	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "Mon", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= mon? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "tUe", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= tUe? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "weD", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= weD? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "THu", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= THu? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "FrI", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= FrI? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "sAT", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= tUe? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= Sun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_EQ, "mon,tuewed,thu,frisatsun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("= mon,tuewed,thu,frisatsun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_NE, "mon,tuewed,thu,frisatsun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("!= mon,tuewed,thu,frisatsun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_GT, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("> Sun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_LT, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("< Sun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_GE, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf(">= Sun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "dayofweek", CMP_OP_LE, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("<= Sun? %d\n\n", result);

	result	= LASDayOfWeekEval(NULL, "mistake", CMP_OP_LE, "Sun", &cachable, &las_cookie, NULL, NULL, NULL, NULL);
	printf("mistake <= Sun? %d\n\n", result);


	ACL_Destroy();

	exit(0);

}