ESAPI-C 1.0
The OWASP Enterprise Security API for C
|
00001 #include <stdio.h> 00002 #include "minunit.h" 00003 #include "canonicalize.h" 00004 00005 /* Unpublished functions */ 00006 extern char *_codec_encode(codec *c, char *s); 00007 extern char *_codec_decode(codec *c, char *s); 00008 00009 int tests_run = 0; 00010 00011 void test__codec_encode(void) 00012 { 00013 (void)fprintf(stdout,"Testing %s\n", __func__); 00014 const char *s = "Execute this: one\u00fftwo !@#$%^&*()"; 00015 printf("Encoding...\n"); 00016 char *encoded = _codec_encode(pcodec_unix, s); 00017 printf("Encoded to: %s\n", encoded); 00018 /* Test it */ 00019 } 00020 00021 void test__codec_decode(void) 00022 { 00023 (void)fprintf(stdout,"Testing %s\n", __func__); 00024 const char *s = "Execute this: one\u00fftwo !@#$%^&*()"; 00025 char *decoded = _codec_decode(pcodec_unix, s); 00026 printf("Decoded to: %s\n", decoded); 00027 /* Test it */ 00028 00029 } 00030 00031 void test_esapi_canonicalize(void) 00032 { 00033 (void)fprintf(stdout,"Testing %s\n", __func__); 00034 const char *input = "Execute this: one\u00fftwo !@#$%^&*()"; 00035 char *canonicalized = esapi_canonicalize(input, pcodec_unix, 1, 1); 00036 printf("Encoded to: %s\n", canonicalized); 00037 /* Test it */ 00038 } 00039 00040 int main(void) 00041 { 00042 test__codec_encode(); 00043 test__codec_decode(); 00044 test_esapi_canonicalize(); 00045 00046 (void)fprintf(stdout, "%s: Pass <%i>, Fail<%i>\n", __FILE__, passed, failed); 00047 return(EXIT_SUCCESS); 00048 }