diff options
author | Kristian Høgsberg <krh@redhat.com> | 2004-05-17 22:19:04 +0000 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2004-05-17 22:19:04 +0000 |
commit | d86fc4071ccb8590d922e3456c5c80c0f7bb9d6f (patch) | |
tree | 7ed880494686d9290ad1f9ded6230459e2e7269a /test | |
parent | 91605d6899e8f21a6adf7f2fc87cfe07d399875f (diff) |
2004-05-17 Kristian Høgsberg <krh@redhat.com>
Remove base64 encoding, replace with hex encoding. Original patch
from trow@ximian.com, added error handling.
* dbus/dbus-string.c (_dbus_string_base64_encode)
(_dbus_string_base64_decode): Remove.
(_dbus_string_hex_decode): Add end_return argument so we can
distinguish between OOM and invalid hex encoding.
(_dbus_string_test): Remove base64 tests and add test case for
invalid hex.
* dbus/dbus-keyring.c, dbus/dbus-auth-script.c, dbus/dbus-auth.c:
Replace base64 with hex.
* test/data/auth/invalid-hex-encoding.auth-script: New test case
for invalid hex encoded data in auth protocol.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/data/auth/cancel.auth-script | 4 | ||||
-rw-r--r-- | test/data/auth/external-failed.auth-script | 2 | ||||
-rw-r--r-- | test/data/auth/external-root.auth-script | 2 | ||||
-rw-r--r-- | test/data/auth/external-silly.auth-script | 2 | ||||
-rw-r--r-- | test/data/auth/external-successful.auth-script | 2 | ||||
-rw-r--r-- | test/data/auth/extra-bytes.auth-script | 2 | ||||
-rw-r--r-- | test/data/auth/fail-after-n-attempts.auth-script | 12 | ||||
-rw-r--r-- | test/data/auth/invalid-hex-encoding.auth-script | 6 | ||||
-rw-r--r-- | test/unbase64.c | 50 |
10 files changed, 20 insertions, 68 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 53170a2b..387456a3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -9,7 +9,7 @@ INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) if DBUS_BUILD_TESTS -TEST_BINARIES=test-service unbase64 break-loader spawn-test test-segfault test-exit test-sleep-forever +TEST_BINARIES=test-service break-loader spawn-test test-segfault test-exit test-sleep-forever else TEST_BINARIES= endif @@ -27,9 +27,6 @@ test_service_SOURCES= \ test-utils.c \ test-utils.h -unbase64_SOURCES= \ - unbase64.c - break_loader_SOURCES= \ break-loader.c @@ -51,7 +48,6 @@ decode_gcov_SOURCES= \ TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la test_service_LDADD=$(TEST_LIBS) -unbase64_LDADD=$(TEST_LIBS) break_loader_LDADD= $(TEST_LIBS) spawn_test_LDADD=$(TEST_LIBS) decode_gcov_LDADD=$(TEST_LIBS) diff --git a/test/data/auth/cancel.auth-script b/test/data/auth/cancel.auth-script index a99c6128..f2c519aa 100644 --- a/test/data/auth/cancel.auth-script +++ b/test/data/auth/cancel.auth-script @@ -1,7 +1,7 @@ ## this tests canceling EXTERNAL SERVER -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND OK EXPECT_STATE WAITING_FOR_INPUT SEND 'CANCEL' @@ -9,7 +9,7 @@ EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT ## now start over and see if it works -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND OK EXPECT_STATE WAITING_FOR_INPUT SEND 'BEGIN' diff --git a/test/data/auth/external-failed.auth-script b/test/data/auth/external-failed.auth-script index 8f0d1aa9..b11ee9c5 100644 --- a/test/data/auth/external-failed.auth-script +++ b/test/data/auth/external-failed.auth-script @@ -2,7 +2,7 @@ SERVER NO_CREDENTIALS -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT diff --git a/test/data/auth/external-root.auth-script b/test/data/auth/external-root.auth-script index c126067c..b0189719 100644 --- a/test/data/auth/external-root.auth-script +++ b/test/data/auth/external-root.auth-script @@ -2,7 +2,7 @@ SERVER ROOT_CREDENTIALS -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND OK EXPECT_STATE WAITING_FOR_INPUT SEND 'BEGIN' diff --git a/test/data/auth/external-silly.auth-script b/test/data/auth/external-silly.auth-script index cbfef8fd..8ac0688a 100644 --- a/test/data/auth/external-silly.auth-script +++ b/test/data/auth/external-silly.auth-script @@ -2,7 +2,7 @@ SERVER SILLY_CREDENTIALS -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT diff --git a/test/data/auth/external-successful.auth-script b/test/data/auth/external-successful.auth-script index 02ecdc08..128d3294 100644 --- a/test/data/auth/external-successful.auth-script +++ b/test/data/auth/external-successful.auth-script @@ -1,7 +1,7 @@ ## this tests a successful auth of type EXTERNAL SERVER -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND OK EXPECT_STATE WAITING_FOR_INPUT SEND 'BEGIN' diff --git a/test/data/auth/extra-bytes.auth-script b/test/data/auth/extra-bytes.auth-script index 0bd705dc..cd1e01d2 100644 --- a/test/data/auth/extra-bytes.auth-script +++ b/test/data/auth/extra-bytes.auth-script @@ -1,7 +1,7 @@ ## this tests that we have the expected extra bytes at the end SERVER -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND OK EXPECT_STATE WAITING_FOR_INPUT SEND 'BEGIN\r\nHello' diff --git a/test/data/auth/fail-after-n-attempts.auth-script b/test/data/auth/fail-after-n-attempts.auth-script index ae3b907a..a56f182b 100644 --- a/test/data/auth/fail-after-n-attempts.auth-script +++ b/test/data/auth/fail-after-n-attempts.auth-script @@ -4,30 +4,30 @@ SERVER NO_CREDENTIALS # 1 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT # 2 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT # 3 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT # 4 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT # 5 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_COMMAND REJECTED EXPECT_STATE WAITING_FOR_INPUT # 6 -SEND 'AUTH EXTERNAL USERID_BASE64' +SEND 'AUTH EXTERNAL USERID_HEX' EXPECT_STATE NEED_DISCONNECT diff --git a/test/data/auth/invalid-hex-encoding.auth-script b/test/data/auth/invalid-hex-encoding.auth-script new file mode 100644 index 00000000..1f15c436 --- /dev/null +++ b/test/data/auth/invalid-hex-encoding.auth-script @@ -0,0 +1,6 @@ +## this tests an invalid hex encoding followed by successful authentication + +SERVER +SEND 'AUTH EXTERNAL willy' +EXPECT_COMMAND ERROR +EXPECT_STATE WAITING_FOR_INPUT diff --git a/test/unbase64.c b/test/unbase64.c deleted file mode 100644 index 2dc232f3..00000000 --- a/test/unbase64.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <dbus/dbus.h> -#define DBUS_COMPILATION /* cheat and use string etc. */ -#include <dbus/dbus-string.h> -#include <dbus/dbus-sysdeps.h> -#include <dbus/dbus-internals.h> -#undef DBUS_COMPILATION -#include <stdio.h> - -int -main (int argc, - char **argv) -{ - DBusString contents; - DBusString decoded; - DBusString filename; - const char *s; - DBusError error; - - if (argc < 2) - { - fprintf (stderr, "Give the file to decode as an argument\n"); - return 1; - } - - _dbus_string_init_const (&filename, argv[1]); - - if (!_dbus_string_init (&contents)) - return 1; - - if (!_dbus_string_init (&decoded)) - return 1; - - dbus_error_init (&error); - if (!_dbus_file_get_contents (&contents, &filename, &error)) - { - fprintf (stderr, "Failed to load file: %s\n", error.message); - dbus_error_free (&error); - return 1; - } - - if (!_dbus_string_base64_decode (&contents, 0, - &decoded, 0)) - return 1; - - s = _dbus_string_get_const_data (&decoded); - - fputs (s, stdout); - - return 0; -} |