Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
static void errors(void **state)
{
  selene_error_t *err = selene_error_create_impl(1, "test", 42, "filename");
  assert_int_equal(err->err, 1);
  assert_int_equal(err->line, 42);
  assert_string_equal(err->msg, "test");
  assert_string_equal(err->file, "filename");
  selene_error_clear(err);

  err = selene_error_createf_impl(2, 43, "xfilename", "foo:%s", "test");
  assert_int_equal(err->err, 2);
  assert_int_equal(err->line, 43);
  assert_string_equal(err->msg, "foo:test");
  assert_string_equal(err->file, "xfilename");
  selene_error_clear(err);

}
Ejemplo n.º 3
0
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);
}