Commit 83bb0702 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

unit1600: unit test for Curl_ntlm_core_mk_nt_hash

parent 6b68aa98
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -510,6 +510,7 @@ static void ascii_uppercase_to_unicode_le(unsigned char *dest,


/*
/*
 * Set up nt hashed passwords
 * Set up nt hashed passwords
 * @unittest: 1600
 */
 */
CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
                                   const char *password,
                                   const char *password,
+2 −0
Original line number Original line Diff line number Diff line
@@ -155,6 +155,8 @@ test1520 \
\
\
test1525 test1526 test1527 test1528 test1529 \
test1525 test1526 test1527 test1528 test1529 \
\
\
test1600 \
\
test1800 test1801 \
test1800 test1801 \
\
\
test1900 test1901 test1902 test1903 \
test1900 test1901 test1902 test1903 \
+15 −1
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -111,6 +111,20 @@ static void memory_tracking_init(void)
#  define memory_tracking_init() Curl_nop_stmt
#  define memory_tracking_init() Curl_nop_stmt
#endif
#endif


/* returns a hexdump in a static memory area */
char *hexdump(unsigned char *buffer, size_t len)
{
  static char dump[200*3+1];
  char *p = dump;
  size_t i;
  if(len > 200)
    return NULL;
  for(i=0; i<len; i++, p += 3)
    snprintf(p, 4, "%02x ", buffer[i]);
  return dump;
}


int main(int argc, char **argv)
int main(int argc, char **argv)
{
{
  char *URL;
  char *URL;
+3 −1
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -63,6 +63,8 @@ extern void wait_ms(int ms); /* wait this many milliseconds */
extern int test(char *URL); /* the actual test function provided by each
extern int test(char *URL); /* the actual test function provided by each
                               individual libXXX.c file */
                               individual libXXX.c file */


extern char *hexdump(unsigned char *buffer, size_t len);

#ifdef UNITTESTS
#ifdef UNITTESTS
extern int unitfail;
extern int unitfail;
#endif
#endif
+8 −6
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -38,8 +38,10 @@


#define verify_memory(dynamic, check, len)                                  \
#define verify_memory(dynamic, check, len)                                  \
  if(dynamic && memcmp(dynamic, check, len)) {                              \
  if(dynamic && memcmp(dynamic, check, len)) {                              \
    fprintf(stderr, "%s:%d The dynamic string didn't match '%s'\n",     \
    fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \
            __FILE__, __LINE__, check);                                 \
            __FILE__, __LINE__, len, hexdump((unsigned char *)check, len));      \
    fprintf(stderr, "%s:%d the same as '%s'\n",                             \
            __FILE__, __LINE__, hexdump((unsigned char *)dynamic, len));         \
    unitfail++;                                                             \
    unitfail++;                                                             \
  }
  }


Loading