diff options
author | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2011-06-23 12:40:30 +0000 |
---|---|---|
committer | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2011-06-23 12:40:30 +0000 |
commit | c34742e433401f293957f52a854c071797f51bf8 (patch) | |
tree | 2eca823266cd5029379dcbfa0fd8c0efba3a0181 /test | |
parent | 2dc778e736e76e20b17066e9ae8502a0e375bb94 (diff) | |
download | neon-c34742e433401f293957f52a854c071797f51bf8.tar.gz |
* src/ne_ssl.h (ne_ssl_clicert_import): New function.
* src/ne_openssl.c (parse_client_cert): Factor out from
ne_ssl_clicert_read.
(ne_ssl_clicert_read): Reimplement using above.
(ne_ssl_clicert_import): New function.
* src/ne_gnutls.c (ne_ssl_clicert_import): Factor out from
ne_ssl_clicert_read.
(ne_ssl_clicert_import): Reimplement using above.
* test/utils.c (file_to_buffer): Move to here...
* test/compress.c (file2buf): ... from here.
(do_fetch): Use it.
* test/ssl.c (clicert_import): New test.
git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@1847 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'test')
-rw-r--r-- | test/compress.c | 21 | ||||
-rw-r--r-- | test/ssl.c | 17 | ||||
-rw-r--r-- | test/utils.c | 19 | ||||
-rw-r--r-- | test/utils.h | 3 |
4 files changed, 41 insertions, 19 deletions
diff --git a/test/compress.c b/test/compress.c index 7d91639..bc9ffea 100644 --- a/test/compress.c +++ b/test/compress.c @@ -24,8 +24,6 @@ #include <unistd.h> #endif -#include <fcntl.h> - #include "ne_compress.h" #include "ne_auth.h" @@ -91,33 +89,18 @@ static int reader(void *ud, const char *block, size_t len) return 0; } -static int file2buf(int fd, ne_buffer *buf) -{ - char buffer[BUFSIZ]; - ssize_t n; - - while ((n = read(fd, buffer, BUFSIZ)) > 0) { - ne_buffer_append(buf, buffer, n); - } - - return 0; -} - static int do_fetch(const char *realfn, const char *gzipfn, int chunked, int expect_fail) { ne_session *sess; ne_request *req; - int fd, ret; + int ret; ne_buffer *buf = ne_buffer_create(); struct serve_file_args sfargs; ne_decompress *dc; struct string body; - fd = open(realfn, O_RDONLY); - ONN("failed to open file", fd < 0); - file2buf(fd, buf); - (void) close(fd); + CALL(file_to_buffer(realfn, buf)); body.data = buf->data; body.len = buf->used - 1; @@ -382,6 +382,22 @@ static int load_client_cert(void) return OK; } +static int clicert_import(void) +{ + ne_ssl_client_cert *cc; + ne_buffer *buf = ne_buffer_create(); + + CALL(file_to_buffer("client.p12", buf)); + + cc = ne_ssl_clicert_import((unsigned char *)buf->data, ne_buffer_size(buf)); + ONN("could not import client cert from buffer", cc == NULL); + + ONN("failed to decrypt", ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE)); + ne_ssl_clicert_free(cc); + + return OK; +} + /* Test that 'cert', which is signed by CA_CERT, is accepted * unconditionaly. */ static int accept_signed_cert_for_hostname(char *cert, const char *hostname) @@ -1856,6 +1872,7 @@ ne_test tests[] = { T(read_write), T(load_client_cert), + T(clicert_import), T(simple), T(simple_sslv2), diff --git a/test/utils.c b/test/utils.c index 4b781d0..0749774 100644 --- a/test/utils.c +++ b/test/utils.c @@ -26,6 +26,7 @@ #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif +#include <fcntl.h> #include "ne_session.h" @@ -204,3 +205,21 @@ int make_session(ne_session **sess, server_fn fn, void *ud) { return session_server(sess, fn, ud); } + +int file_to_buffer(const char *filename, ne_buffer *buf) +{ + char buffer[BUFSIZ]; + int fd; + ssize_t n; + + fd = open(filename, O_RDONLY); + ONV(fd < 0, ("could not open file %s", filename)); + + while ((n = read(fd, buffer, BUFSIZ)) > 0) { + ne_buffer_append(buf, buffer, n); + } + + close(fd); + + return 0; +} diff --git a/test/utils.h b/test/utils.h index 934d597..39c4722 100644 --- a/test/utils.h +++ b/test/utils.h @@ -123,5 +123,8 @@ int session_server(ne_session **sess, server_fn fn, void *userdata); int proxied_session_server(ne_session **sess, const char *scheme, const char *host, unsigned int fakeport, server_fn fn, void *userdata); + +/* Read contents of file 'filename' into buffer 'buf'. */ +int file_to_buffer(const char *filename, ne_buffer *buf); #endif /* UTILS_H */ |