mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-21 22:41:26 +00:00
Update tests to latest changes
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de> [Erik Ekman: reverted login test changes]
This commit is contained in:
parent
8c5127b375
commit
8d4b43e178
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "base32.h"
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
#define TUPLES 5
|
#define TUPLES 5
|
||||||
|
@ -43,13 +42,11 @@ START_TEST(test_base32_encode)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
struct encoder *b32;
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b32 = get_base32_encoder();
|
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
val = b32->encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
|
val = base32_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
|
||||||
|
|
||||||
fail_unless(val == strlen(testpairs[_i].b));
|
fail_unless(val == strlen(testpairs[_i].b));
|
||||||
fail_unless(strcmp(buf, testpairs[_i].b) == 0,
|
fail_unless(strcmp(buf, testpairs[_i].b) == 0,
|
||||||
|
@ -61,13 +58,10 @@ START_TEST(test_base32_decode)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
struct encoder *b32;
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b32 = get_base32_encoder();
|
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
val = b32->decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
|
val = base32_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
|
||||||
|
|
||||||
fail_unless(val == strlen(testpairs[_i].a));
|
fail_unless(val == strlen(testpairs[_i].a));
|
||||||
fail_unless(strcmp(buf, testpairs[_i].a) == 0,
|
fail_unless(strcmp(buf, testpairs[_i].a) == 0,
|
||||||
|
@ -93,14 +87,11 @@ START_TEST(test_base32_blksize)
|
||||||
size_t enclen;
|
size_t enclen;
|
||||||
char *rawbuf;
|
char *rawbuf;
|
||||||
char *encbuf;
|
char *encbuf;
|
||||||
struct encoder *b32;
|
|
||||||
int i;
|
int i;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b32 = get_base32_encoder();
|
rawlen = base32_ops.blocksize_raw;
|
||||||
|
enclen = base32_ops.blocksize_encoded;
|
||||||
rawlen = b32->blocksize_raw();
|
|
||||||
enclen = b32->blocksize_encoded();
|
|
||||||
|
|
||||||
rawbuf = malloc(rawlen + 16);
|
rawbuf = malloc(rawlen + 16);
|
||||||
encbuf = malloc(enclen + 16);
|
encbuf = malloc(enclen + 16);
|
||||||
|
@ -110,7 +101,7 @@ START_TEST(test_base32_blksize)
|
||||||
}
|
}
|
||||||
rawbuf[i] = 0;
|
rawbuf[i] = 0;
|
||||||
|
|
||||||
val = b32->encode(encbuf, &enclen, rawbuf, rawlen);
|
val = base32_ops.encode(encbuf, &enclen, rawbuf, rawlen);
|
||||||
|
|
||||||
fail_unless(rawlen == 5, "raw length was %d not 5", rawlen);
|
fail_unless(rawlen == 5, "raw length was %d not 5", rawlen);
|
||||||
fail_unless(enclen == 5, "encoded %d bytes, not 5", enclen);
|
fail_unless(enclen == 5, "encoded %d bytes, not 5", enclen);
|
||||||
|
@ -119,7 +110,7 @@ START_TEST(test_base32_blksize)
|
||||||
memset(rawbuf, 0, rawlen + 16);
|
memset(rawbuf, 0, rawlen + 16);
|
||||||
|
|
||||||
enclen = val;
|
enclen = val;
|
||||||
val = b32->decode(rawbuf, &rawlen, encbuf, enclen);
|
val = base32_ops.decode(rawbuf, &rawlen, encbuf, enclen);
|
||||||
|
|
||||||
fail_unless(rawlen == 5, "raw length was %d not 5", rawlen);
|
fail_unless(rawlen == 5, "raw length was %d not 5", rawlen);
|
||||||
fail_unless(val == 5, "val was not 5 but %d", val);
|
fail_unless(val == 5, "val was not 5 but %d", val);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "base64.h"
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
#define TUPLES 5
|
#define TUPLES 5
|
||||||
|
@ -69,13 +68,10 @@ START_TEST(test_base64_encode)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
struct encoder *b64;
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b64 = get_base64_encoder();
|
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
val = b64->encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
|
val = base64_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
|
||||||
|
|
||||||
fail_unless(val == strlen(testpairs[_i].b));
|
fail_unless(val == strlen(testpairs[_i].b));
|
||||||
fail_unless(strcmp(buf, testpairs[_i].b) == 0,
|
fail_unless(strcmp(buf, testpairs[_i].b) == 0,
|
||||||
|
@ -87,13 +83,10 @@ START_TEST(test_base64_decode)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
struct encoder *b64;
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b64 = get_base64_encoder();
|
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
val = b64->decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
|
val = base64_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
|
||||||
|
|
||||||
fail_unless(val == strlen(testpairs[_i].a));
|
fail_unless(val == strlen(testpairs[_i].a));
|
||||||
fail_unless(strcmp(buf, testpairs[_i].a) == 0,
|
fail_unless(strcmp(buf, testpairs[_i].a) == 0,
|
||||||
|
@ -107,14 +100,11 @@ START_TEST(test_base64_blksize)
|
||||||
size_t enclen;
|
size_t enclen;
|
||||||
char *rawbuf;
|
char *rawbuf;
|
||||||
char *encbuf;
|
char *encbuf;
|
||||||
struct encoder *b64;
|
|
||||||
int i;
|
int i;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
b64 = get_base64_encoder();
|
rawlen = base64_ops.blocksize_raw;
|
||||||
|
enclen = base64_ops.blocksize_encoded;
|
||||||
rawlen = b64->blocksize_raw();
|
|
||||||
enclen = b64->blocksize_encoded();
|
|
||||||
|
|
||||||
rawbuf = malloc(rawlen + 16);
|
rawbuf = malloc(rawlen + 16);
|
||||||
encbuf = malloc(enclen + 16);
|
encbuf = malloc(enclen + 16);
|
||||||
|
@ -124,7 +114,7 @@ START_TEST(test_base64_blksize)
|
||||||
}
|
}
|
||||||
rawbuf[i] = 0;
|
rawbuf[i] = 0;
|
||||||
|
|
||||||
val = b64->encode(encbuf, &enclen, rawbuf, rawlen);
|
val = base64_ops.encode(encbuf, &enclen, rawbuf, rawlen);
|
||||||
|
|
||||||
fail_unless(rawlen == 3, "raw length was %d not 3", rawlen);
|
fail_unless(rawlen == 3, "raw length was %d not 3", rawlen);
|
||||||
fail_unless(enclen == 3, "encoded %d bytes, not 3", enclen);
|
fail_unless(enclen == 3, "encoded %d bytes, not 3", enclen);
|
||||||
|
@ -133,7 +123,7 @@ START_TEST(test_base64_blksize)
|
||||||
memset(rawbuf, 0, rawlen + 16);
|
memset(rawbuf, 0, rawlen + 16);
|
||||||
|
|
||||||
enclen = val;
|
enclen = val;
|
||||||
val = b64->decode(rawbuf, &rawlen, encbuf, enclen);
|
val = base64_ops.decode(rawbuf, &rawlen, encbuf, enclen);
|
||||||
|
|
||||||
fail_unless(rawlen == 3, "raw length was %d not 3", rawlen);
|
fail_unless(rawlen == 3, "raw length was %d not 3", rawlen);
|
||||||
fail_unless(val == 3);
|
fail_unless(val == 3);
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "base32.h"
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
static void dump_packet(char *, size_t);
|
static void dump_packet(char *, size_t);
|
||||||
|
@ -70,7 +69,7 @@ START_TEST(test_encode_query)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
char resolv[512];
|
char resolv[512];
|
||||||
struct query q;
|
struct query q;
|
||||||
struct encoder *enc;
|
const struct encoder *enc;
|
||||||
char *d;
|
char *d;
|
||||||
size_t len;
|
size_t len;
|
||||||
size_t enclen;
|
size_t enclen;
|
||||||
|
@ -83,7 +82,7 @@ START_TEST(test_encode_query)
|
||||||
q.type = T_NULL;
|
q.type = T_NULL;
|
||||||
q.id = 1337;
|
q.id = 1337;
|
||||||
d = resolv;
|
d = resolv;
|
||||||
enc = get_base32_encoder();
|
enc = &base32_ops;
|
||||||
|
|
||||||
*d++ = 'A';
|
*d++ = 'A';
|
||||||
enc->encode(d, &enclen, innerData, strlen(innerData));
|
enc->encode(d, &enclen, innerData, strlen(innerData));
|
||||||
|
@ -111,14 +110,14 @@ START_TEST(test_decode_query)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
char *domain;
|
char *domain;
|
||||||
struct query q;
|
struct query q;
|
||||||
struct encoder *enc;
|
const struct encoder *enc;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
memset(&q, 0, sizeof(struct query));
|
memset(&q, 0, sizeof(struct query));
|
||||||
memset(&buf, 0, sizeof(buf));
|
memset(&buf, 0, sizeof(buf));
|
||||||
q.id = 0;
|
q.id = 0;
|
||||||
len = sizeof(query_packet) - 1;
|
len = sizeof(query_packet) - 1;
|
||||||
enc = get_base32_encoder();
|
enc = &base32_ops;
|
||||||
|
|
||||||
dns_decode(buf, sizeof(buf), &q, QR_QUERY, query_packet, len);
|
dns_decode(buf, sizeof(buf), &q, QR_QUERY, query_packet, len);
|
||||||
domain = strstr(q.name, topdomain);
|
domain = strstr(q.name, topdomain);
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "base32.h"
|
|
||||||
#include "base64.h"
|
|
||||||
|
|
||||||
#define TUPLES 4
|
#define TUPLES 4
|
||||||
|
|
||||||
|
@ -87,7 +85,7 @@ START_TEST(test_build_hostname)
|
||||||
buflen = sizeof(buf);
|
buflen = sizeof(buf);
|
||||||
|
|
||||||
for (i = 1; i < sizeof(data); i++) {
|
for (i = 1; i < sizeof(data); i++) {
|
||||||
int len = build_hostname(buf, buflen, data, i, topdomain, get_base32_encoder(), sizeof(buf));
|
int len = build_hostname(buf, buflen, data, i, topdomain, &base32_ops, sizeof(buf));
|
||||||
|
|
||||||
fail_if(len > i);
|
fail_if(len > i);
|
||||||
fail_if(strstr(buf, ".."), "Found double dots when encoding data len %d! buf: %s", i, buf);
|
fail_if(strstr(buf, ".."), "Found double dots when encoding data len %d! buf: %s", i, buf);
|
||||||
|
|
Loading…
Reference in a new issue