static void tls_io_slowly(void **state) { selene_error_t *err; sln_parser_baton_t *baton; selene_conf_t *conf = NULL; selene_t *s = NULL; sln_bucket_t *e1; size_t maxlen = sizeof(openssl_client_hello_basic); size_t i; init_ctxt(state, &s, &conf); baton = (sln_parser_baton_t *)s->backend_baton; for (i = 0; i <= maxlen; i++) { SLN_ERR(sln_bucket_create_copy_bytes( sln_test_alloc, &e1, (const char *)openssl_client_hello_basic, i)); SLN_BRIGADE_INSERT_TAIL(s->bb.in_enc, e1); err = sln_io_tls_read(s, baton); if (err) { SLN_ASSERT(err->err == SELENE_EINVAL); } else if (baton->peer_version_major != 0) { assert_int_equal(baton->peer_version_major, 3); assert_int_equal(baton->peer_version_minor, 1); } sln_brigade_clear(baton->in_handshake); sln_brigade_clear(s->bb.in_enc); } destroy_ctxt(state, s, conf); }
static void tls_http_accident(void **state) { selene_error_t *err; sln_parser_baton_t *baton; selene_conf_t *conf = NULL; selene_t *s = NULL; http_cb_t cbb; sln_bucket_t *e1; init_ctxt(state, &s, &conf); baton = (sln_parser_baton_t *)s->backend_baton; cbb.gotit = 0; selene_handler_set(s, SELENE_EVENT_TLS_GOT_HTTP, http_cb, &cbb); SLN_ERR(sln_bucket_create_copy_bytes(sln_test_alloc, &e1, http_message, strlen(http_message))); SLN_BRIGADE_INSERT_TAIL(s->bb.in_enc, e1); err = sln_io_tls_read(s, baton); SLN_ASSERT(err != NULL); SLN_ASSERT(err->err == SELENE_EINVAL); selene_error_clear(err); assert_int_equal(1, cbb.gotit); destroy_ctxt(state, s, conf); }
static void handshake_io_slowly(void **state) { selene_error_t *err; sln_parser_baton_t *baton; selene_conf_t *conf = NULL; selene_t *s = NULL; sln_bucket_t *e1; size_t maxlen = sizeof(openssl_client_hello_basic); size_t i; selene_conf_create(&conf); SLN_ERR(selene_conf_use_reasonable_defaults(conf)); SLN_ERR(selene_server_create(conf, &s)); SLN_ASSERT_CONTEXT(s); baton = (sln_parser_baton_t *)s->backend_baton; for (i = maxlen; i <= maxlen; i++) { SLN_ERR(sln_bucket_create_copy_bytes(sln_test_alloc, &e1, openssl_client_hello_basic, i)); SLN_BRIGADE_INSERT_TAIL(baton->in_handshake, e1); err = sln_io_handshake_read(s, baton); if (err) { SLN_ASSERT(err->err == SELENE_EINVAL); } else { /* TODO: more asserts */ } sln_brigade_clear(baton->in_handshake); } selene_destroy(s); selene_conf_destroy(conf); }
static void tls_v2_hello(void **state) { selene_error_t *err; sln_parser_baton_t *baton; selene_conf_t *conf = NULL; selene_t *s = NULL; sln_bucket_t *e1; init_ctxt(state, &s, &conf); baton = (sln_parser_baton_t *)s->backend_baton; SLN_ERR(sln_bucket_create_copy_bytes(sln_test_alloc, &e1, (const char *)openssl_client_hello_sslv2, sizeof(openssl_client_hello_sslv2))); SLN_BRIGADE_INSERT_TAIL(s->bb.in_enc, e1); err = sln_io_tls_read(s, baton); /* TODO: successfully parse the sslv2 client hello... enough to know it was * sslv2. */ /* SLN_ASSERT(err == NULL); */ selene_error_clear(err); destroy_ctxt(state, s, conf); }