smtp: remove bad tests

pull/7954/head
Victor Julien 4 years ago
parent 79499e4769
commit d39a79b6f2

@ -4104,219 +4104,6 @@ end:
FLOW_DESTROY(&f);
return result;
}
static int SMTPProcessDataChunkTest01(void){
Flow f;
FLOW_INITIALIZE(&f);
f.file_flags = FLOWFILE_NO_STORE_TS;
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
int ret;
ret = SMTPProcessDataChunk(NULL, 0, state);
return ret == 0;
}
static int SMTPProcessDataChunkTest02(void){
char mimemsg[] = {0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E,
0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65,
0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A,
0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x6F, 0x63, 0x74,
0x65, 0x74, 0x2D, 0x73, 0x74, 0x72, 0x65, 0x61,
0x6D, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65,
0x6E, 0x74, 0x2D, 0x54, 0x72, 0x61, 0x6E, 0x73,
0x66, 0x65, 0x72, 0x2D, 0x45, 0x6E, 0x63, 0x6F,
0x64, 0x69, 0x6E, 0x67, 0x3A, 0x20, 0x62, 0x61,
0x73, 0x65, 0x36, 0x34, 0x0D, 0x0A, 0x43, 0x6F,
0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x44, 0x69,
0x73, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F,
0x6E, 0x3A, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63,
0x68, 0x6D, 0x65, 0x6E, 0x74, 0x3B, 0x20, 0x66,
0x69, 0x6C, 0x65, 0x6E, 0x61, 0x6D, 0x65, 0x3D,
0x22, 0x74, 0x65, 0x73, 0x74, 0x2E, 0x65, 0x78,
0x65, 0x22, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x54,
0x56, 0x6F, 0x41, 0x41, 0x46, 0x42, 0x46, 0x41,
0x41, 0x42, 0x4D, 0x41, 0x51, 0x45, 0x41, 0x61,
0x69, 0x70, 0x59, 0x77, 0x77, 0x41, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42,
0x41, 0x41, 0x44, 0x41, 0x51, 0x73, 0x42, 0x43,
0x41, 0x41, 0x42, 0x41, 0x41, 0x43, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x48, 0x6B, 0x41, 0x41,
0x41, 0x41, 0x4D, 0x41, 0x41, 0x41, 0x41, 0x65,
0x51, 0x41, 0x41, 0x41, 0x41, 0x77, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x45, 0x41, 0x41, 0x42,
0x41, 0x41, 0x41, 0x41, 0x41, 0x51, 0x41, 0x41,
0x41, 0x42, 0x30, 0x41, 0x41, 0x41, 0x41, 0x49,
0x41, 0x41, 0x41, 0x41, 0x41, 0x51, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42,
0x41, 0x45, 0x41, 0x41, 0x49, 0x67, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x67, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x41, 0x42, 0x63, 0x58, 0x44, 0x59, 0x32, 0x4C,
0x6A, 0x6B, 0x7A, 0x4C, 0x6A, 0x59, 0x34, 0x4C,
0x6A, 0x5A, 0x63, 0x65, 0x67, 0x41, 0x41, 0x4F,
0x41, 0x3D, 0x3D, 0x0D, 0x0A,};
Flow f;
TcpSession ssn;
memset(&ssn, 0, sizeof(ssn));
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
state->body_begin = 1;
int ret;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg, sizeof(mimemsg), state);
return ret == 0;
}
static int SMTPProcessDataChunkTest03(void){
char mimemsg[] = {0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, };
char mimemsg2[] = {0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, };
char mimemsg3[] = {0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, };
char mimemsg4[] = {0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, };
char mimemsg5[] = {0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, };
char mimemsg6[] = {0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x6F, 0x63, 0x74, };
char mimemsg7[] = {0x65, 0x74, 0x2D, 0x73, 0x74, 0x72, 0x65, 0x61, };
char mimemsg8[] = {0x6D, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, };
char mimemsg9[] = {0x6E, 0x74, 0x2D, 0x54, 0x72, 0x61, 0x6E, 0x73, };
char mimemsg10[] = {0x66, 0x65, 0x72, 0x2D, 0x45, 0x6E, 0x63, 0x6F, };
char mimemsg11[] = {0x64, 0x69, 0x6E, 0x67, 0x3A, 0x20, 0x62, 0x61, };
char mimemsg12[] = {0x73, 0x65, 0x36, 0x34, 0x0D, 0x0A, 0x43, 0x6F, };
TcpSession ssn;
memset(&ssn, 0, sizeof(ssn));
Flow f;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
int ret;
state->body_begin = 1;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg, sizeof(mimemsg), state);
if(ret) goto end;
state->body_begin = 0;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg2, sizeof(mimemsg2), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg3, sizeof(mimemsg3), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg4, sizeof(mimemsg4), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg5, sizeof(mimemsg5), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg6, sizeof(mimemsg6), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg7, sizeof(mimemsg7), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg8, sizeof(mimemsg8), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg9, sizeof(mimemsg9), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg10, sizeof(mimemsg10), state);
if(ret) goto end;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg11, sizeof(mimemsg11), state);
if(ret) goto end;
state->body_end = 1;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg12, sizeof(mimemsg12), state);
if(ret) goto end;
end:
return ret == 0;
}
static int SMTPProcessDataChunkTest04(void){
char mimemsg[] = {0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, };
char mimemsg2[] = {0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, };
char mimemsg3[] = {0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, };
char mimemsg4[] = {0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, };
char mimemsg5[] = {0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, };
char mimemsg6[] = {0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x6F, 0x63, 0x74, };
char mimemsg7[] = {0x65, 0x74, 0x2D, 0x73, 0x74, 0x72, 0x65, 0x61, };
char mimemsg8[] = {0x6D, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, };
char mimemsg9[] = {0x6E, 0x74, 0x2D, 0x54, 0x72, 0x61, 0x6E, 0x73, };
char mimemsg10[] = {0x66, 0x65, 0x72, 0x2D, 0x45, 0x6E, 0x63, 0x6F, };
char mimemsg11[] = {0x64, 0x69, 0x6E, 0x67, 0x3A, 0x20, 0x62, 0x61, };
TcpSession ssn;
memset(&ssn, 0, sizeof(ssn));
Flow f;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
int ret = MIME_DEC_OK;
state->body_begin = 1;
if(SMTPProcessDataChunk((uint8_t *)mimemsg, sizeof(mimemsg), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg2, sizeof(mimemsg2), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg3, sizeof(mimemsg3), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg4, sizeof(mimemsg4), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg5, sizeof(mimemsg5), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg6, sizeof(mimemsg6), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg7, sizeof(mimemsg7), state) != 0) goto end;
state->body_begin = 0;
state->body_end = 1;
if(SMTPProcessDataChunk((uint8_t *)mimemsg8, sizeof(mimemsg8), state) != 0) goto end;
state->body_end = 0;
if(SMTPProcessDataChunk((uint8_t *)mimemsg9, sizeof(mimemsg9), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg10, sizeof(mimemsg10), state) != 0) goto end;
if(SMTPProcessDataChunk((uint8_t *)mimemsg11, sizeof(mimemsg11), state) != 0) goto end;
end:
return ret == 0;
}
static int SMTPProcessDataChunkTest05(void){
#if 0
char mimemsg[] = {0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E,
0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65,
0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A,
0x6A, 0x6B, 0x7A, 0x4C, 0x6A, 0x59, 0x34, 0x4C,
0x6A, 0x5A, 0x63, 0x65, 0x67, 0x41, 0x41, 0x4F,
0x41, 0x3D, 0x3D, 0x0D, 0x0A,};
TcpSession ssn;
memset(&ssn, 0, sizeof(ssn));
Flow f;
int ret;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
FAIL_IF(f.alstate == NULL);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
FAIL_IF(state == NULL);
state->body_begin = 1;
ret = SMTPProcessDataChunk((uint8_t *)mimemsg, sizeof(mimemsg), state);
FAIL_IF(ret != 0);
state->body_begin = 0;
SMTPState *smtp_state = (SMTPState *)((Flow *)state->data)->alstate;
FileContainer *files = smtp_state->files_ts;
FAIL_IF(files == NULL);
File *file = files->head;
FAIL_IF(file == NULL);
ret = SMTPProcessDataChunk((uint8_t *)mimemsg, sizeof(mimemsg), state);
FAIL_IF(ret != 0);
FAIL_IF((uint32_t)FileDataSize(file) != 106);
SMTPStateFree(smtp_state);
FLOW_DESTROY(&f);
#endif
PASS;
}
#endif /* UNITTESTS */
void SMTPParserRegisterTests(void)
@ -4331,11 +4118,6 @@ void SMTPParserRegisterTests(void)
UtRegisterTest("SMTPParserTest12", SMTPParserTest12);
UtRegisterTest("SMTPParserTest13", SMTPParserTest13);
UtRegisterTest("SMTPParserTest14", SMTPParserTest14);
UtRegisterTest("SMTPProcessDataChunkTest01", SMTPProcessDataChunkTest01);
UtRegisterTest("SMTPProcessDataChunkTest02", SMTPProcessDataChunkTest02);
UtRegisterTest("SMTPProcessDataChunkTest03", SMTPProcessDataChunkTest03);
UtRegisterTest("SMTPProcessDataChunkTest04", SMTPProcessDataChunkTest04);
UtRegisterTest("SMTPProcessDataChunkTest05", SMTPProcessDataChunkTest05);
#endif /* UNITTESTS */
return;

Loading…
Cancel
Save