Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lavabit/magma.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpadkins <jacobpadkins@gmail.com>2017-03-29 16:55:55 +0300
committerjpadkins <jacobpadkins@gmail.com>2017-03-29 16:55:55 +0300
commit733e00274e438ea37267294a80b7fe79541102ad (patch)
treecc85ab3c2ebd45a2fbf6461288546abe9da9025c
parentfe08a7961f7105b009aece3edcd5c6463cc4d794 (diff)
Fixed an issue in the POP tests.
-rw-r--r--check/magma/magma_check.c2
-rw-r--r--check/magma/magma_check.h2
-rw-r--r--check/magma/servers/camel/camel_check.c45
-rw-r--r--check/magma/servers/camel/camel_check.h16
-rw-r--r--check/magma/servers/camel/camel_check_network.c13
-rw-r--r--check/magma/servers/http/http_check_network.c2
-rw-r--r--check/magma/servers/json/json_check.c36
-rw-r--r--check/magma/servers/json/json_check.h13
-rw-r--r--check/magma/servers/pop/pop_check.c2
-rw-r--r--check/magma/servers/pop/pop_check_network.c21
-rw-r--r--dev/scripts/test/.t.camel.sh.swpbin24576 -> 0 bytes
11 files changed, 90 insertions, 62 deletions
diff --git a/check/magma/magma_check.c b/check/magma/magma_check.c
index c73e0965..e2d28493 100644
--- a/check/magma/magma_check.c
+++ b/check/magma/magma_check.c
@@ -283,7 +283,7 @@ int main(int argc, char *argv[]) {
srunner_add_suite(sr, suite_check_pop());
srunner_add_suite(sr, suite_check_imap());
srunner_add_suite(sr, suite_check_http());
- srunner_add_suite(sr, suite_check_json());
+ srunner_add_suite(sr, suite_check_camel());
srunner_add_suite(sr, suite_check_regression());
}
diff --git a/check/magma/magma_check.h b/check/magma/magma_check.h
index ac59a406..d9f2c238 100644
--- a/check/magma/magma_check.h
+++ b/check/magma/magma_check.h
@@ -35,7 +35,7 @@
#include "servers/pop/pop_check.h"
#include "servers/imap/imap_check.h"
#include "servers/http/http_check.h"
-#include "servers/json/json_check.h"
+#include <servers/camel/camel_check.h>
#include "regression/regression_check.h"
#include "config/config_check.h"
diff --git a/check/magma/servers/camel/camel_check.c b/check/magma/servers/camel/camel_check.c
new file mode 100644
index 00000000..daec0638
--- /dev/null
+++ b/check/magma/servers/camel/camel_check.c
@@ -0,0 +1,45 @@
+/**
+ * @file /check/magma/camel/camel_check.c
+ *
+ * @brief Camelface test functions.
+ */
+
+#include "magma_check.h"
+
+START_TEST (check_camel_basic_s) {
+
+ log_disable();
+ bool_t outcome = true;
+ client_t *client = NULL;
+ server_t *server = NULL;
+ stringer_t *errmsg = MANAGEDBUF(1024);
+
+ if (status() && !(server = servers_get_by_protocol(HTTP, true))) {
+ st_sprint(errmsg, "No HTTP servers were configured to support TLS connections.");
+ outcome = false;
+ }
+ else if (!(client = client_connect("localhost", server->network.port)) || (client_secure(client) == -1)) {
+
+ st_sprint(errmsg, "Failed to connect client securely to HTTP server.");
+ outcome = false;
+ }
+ else if (!check_camel_basic_sthread(client, errmsg)){
+ outcome = false;
+ }
+ else {
+ errmsg = NULL;
+ }
+
+ log_test("CAMEL / BASIC / SINGLE THREADED:", errmsg);
+ ck_assert_msg(outcome, st_char_get(errmsg));
+}
+END_TEST
+
+Suite * suite_check_camel(void) {
+
+ Suite *s = suite_create("\tCAMEL");
+
+ suite_check_testcase(s, "CAMEL", "Camel Basic/S", check_camel_basic_s);
+
+ return s;
+}
diff --git a/check/magma/servers/camel/camel_check.h b/check/magma/servers/camel/camel_check.h
new file mode 100644
index 00000000..64e14b5a
--- /dev/null
+++ b/check/magma/servers/camel/camel_check.h
@@ -0,0 +1,16 @@
+/*
+ * @file /check/magma/servers/camel/camel_check.h
+ *
+ * @brief Camelface test functions.
+ */
+
+#ifndef CAMEL_CHECK_H
+#define CAMEL_CHECK_H
+
+/// camel_check_network.c
+bool_t check_camel_basic_sthread(client_t *client, stringer_t *errmsg);
+
+/// pop_check.c
+Suite * suite_check_camel(void);
+
+#endif
diff --git a/check/magma/servers/camel/camel_check_network.c b/check/magma/servers/camel/camel_check_network.c
new file mode 100644
index 00000000..6e190f76
--- /dev/null
+++ b/check/magma/servers/camel/camel_check_network.c
@@ -0,0 +1,13 @@
+/**
+ * @file /magma/check/magma/servers/camel/camel_check_network.c
+ *
+ * @brief Functions used to test the Camelface.
+ *
+ */
+
+#include "magma_check.h"
+
+bool_t check_camel_basic_sthread(client_t *client, stringer_t *errmsg) {
+
+ return true;
+}
diff --git a/check/magma/servers/http/http_check_network.c b/check/magma/servers/http/http_check_network.c
index 75e57153..7499f42e 100644
--- a/check/magma/servers/http/http_check_network.c
+++ b/check/magma/servers/http/http_check_network.c
@@ -119,7 +119,7 @@ bool_t check_http_network_basic_sthread(stringer_t *errmsg, uint32_t port, bool_
return false;
}
// Test submitting a GET request.
- else if (client_print(client, "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n") != 37 || client_status(client) != 1 ||
+ else if (client_print(client, "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n") != 35 || client_status(client) != 1 ||
!(content_length = check_http_content_length_get(client, errmsg))) {
if (st_empty(errmsg)) st_sprint(errmsg, "Failed to return a valid GET response.");
diff --git a/check/magma/servers/json/json_check.c b/check/magma/servers/json/json_check.c
deleted file mode 100644
index a7c14d7f..00000000
--- a/check/magma/servers/json/json_check.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file /check/magma/json/json_check.c
- *
- * @brief JSON Web API test functions.
- */
-
-#include "magma_check.h"
-
-START_TEST (check_json_network_basic_s) {
-
- log_disable();
- bool_t outcome = true;
- client_t *client = NULL;
- stringer_t *errmsg = MANAGEDBUF(1024);
- if (status() && !(client = client_connect("localhost/json", 10000))) {
-
- st_sprint(errmsg, "Failed to connect to JSON Web API endpoint.");
- outcome = false;
- }
- else {
- errmsg = NULL;
- }
-
- log_test("IMAP / NETWORK / FETCH / SINGLE THREADED:", errmsg);
- ck_assert_msg(outcome, st_char_get(errmsg));
-}
-END_TEST
-
-Suite * suite_check_json(void) {
-
- Suite *s = suite_create("\tJSON");
-
- suite_check_testcase(s, "JSON", "JSON Network Basic/S", check_json_network_basic_s);
-
- return s;
-}
diff --git a/check/magma/servers/json/json_check.h b/check/magma/servers/json/json_check.h
deleted file mode 100644
index 1271bbfd..00000000
--- a/check/magma/servers/json/json_check.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * @file /check/magma/servers/json/json_check.h
- *
- * @brief JSON Web API test functions.
- */
-
-#ifndef JSON_CHECK_H
-#define JSON_CHECK_H
-
-/// pop_check.c
-Suite * suite_check_json(void);
-
-#endif
diff --git a/check/magma/servers/pop/pop_check.c b/check/magma/servers/pop/pop_check.c
index ce2b258b..6e3fb089 100644
--- a/check/magma/servers/pop/pop_check.c
+++ b/check/magma/servers/pop/pop_check.c
@@ -19,6 +19,8 @@ START_TEST (check_pop_network_basic_tcp_s) {
}
else if (status() && !check_pop_network_basic_sthread(errmsg, tcp->network.port, false)) {
outcome = false;
+ }
+ else {
errmsg = NULL;
}
diff --git a/check/magma/servers/pop/pop_check_network.c b/check/magma/servers/pop/pop_check_network.c
index 4c07e3d7..e1761709 100644
--- a/check/magma/servers/pop/pop_check_network.c
+++ b/check/magma/servers/pop/pop_check_network.c
@@ -9,10 +9,10 @@
#include "magma_check.h"
/**
- * Calls client_read_line on a client until it reaches a period only line, returning the
- * number of messages in the inbox.
+ * @brief Calls client_read_line on a client until it reaches a period only line, returning
+ * the number of messages in the inbox.
*
- * @param client The client_t* to read from (which should be connected to a POP server).
+ * @param client The client_t* to read from (which should be connected to a POP server)
* @return true if a line containing a single period is found, false if not.
*/
bool_t check_pop_client_read_end(client_t *client) {
@@ -39,7 +39,7 @@ uint64_t check_pop_client_read_list(client_t *client, stringer_t *errmsg) {
while (client_read_line(client) > 0) {
if (pl_starts_with_char(client->line, '.')) {
- return counter;
+ return counter-1;
}
else if (tok_get_st(&(client->line), ' ', 0, &fragment) >= 0 && !uint64_conv_pl(fragment, &sequence)) {
if (sequence != counter) return 0;
@@ -55,6 +55,7 @@ bool_t check_pop_network_basic_sthread(stringer_t *errmsg, uint32_t port, bool_t
uint64_t message_num;
client_t *client = NULL;
+ stringer_t *top_command = NULL;
// Connect the client.
if (!(client = client_connect("localhost", port)) || (secure && (client_secure(client) == -1)) ||
@@ -134,19 +135,19 @@ bool_t check_pop_network_basic_sthread(stringer_t *errmsg, uint32_t port, bool_t
return false;
}
- // Test the LAST command.
- else if (client_print(client, "LAST 1\r\n") != 8 || client_read_line(client) <= 0 || client_status(client) != 1 ||
- st_cmp_cs_starts(&(client->line), NULLER("+OK")) || st_cmp_cs_ends(&(client->line),
- st_aprint_opts(MANAGED_T | CONTIGUOUS | STACK, "%lu\r\n", message_num))) {
+ // Test the TOP command.
+ else if (!(top_command = st_aprint_opts(MANAGED_T | CONTIGUOUS | STACK, "TOP %lu 0\r\n", message_num)) ||
+ client_print(client, st_char_get(top_command)) != st_length_get(top_command) || client_status(client) != 1 ||
+ client_read_line(client) <= 0 || st_cmp_cs_starts(&(client->line), NULLER("+OK"))|| !check_pop_client_read_end(client)) {
- st_sprint(errmsg, "Failed to return a successful state after LAST.");
+ st_sprint(errmsg, "Failed to return a successful state after TOP.");
client_close(client);
return false;
}
// Test the RSET command.
else if (client_print(client, "RSET\r\n") != 6 || client_read_line(client) <= 0 || client_status(client) != 1 ||
- st_cmp_cs_starts(&(client->line), NULLER("+OK")) || st_cmp_cs_ends(&(client->line), NULLER("were reset.\r\n"))) {
+ st_cmp_cs_eq(&(client->line), NULLER("+OK All messages were reset.\r\n"))) {
st_sprint(errmsg, "Failed to return a successful state after RSET.");
client_close(client);
diff --git a/dev/scripts/test/.t.camel.sh.swp b/dev/scripts/test/.t.camel.sh.swp
deleted file mode 100644
index cb7a3ba3..00000000
--- a/dev/scripts/test/.t.camel.sh.swp
+++ /dev/null
Binary files differ