summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/oauth2.c56
2 files changed, 58 insertions, 4 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0a112f3..fe265e6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,4 @@
-TESTS = proxy threaded oauth oauth-async flickr
-# TODO: oauth-async is failing due to infinite looping for some reason. Need to
-# fix this.
-XFAIL_TESTS = oauth-async
+TESTS = proxy threaded oauth oauth-async oauth2 flickr
AM_CPPFLAGS = $(SOUP_CFLAGS) -I$(top_srcdir)
AM_LDFLAGS = $(SOUP_LIBS) ../rest/librest-@API_VERSION@.la ../rest-extras/librest-extras-@API_VERSION@.la
@@ -12,4 +9,5 @@ proxy_SOURCES = proxy.c
threaded_SOURCES = threaded.c
oauth_SOURCES = oauth.c
oauth_async_SOURCES = oauth-async.c
+oauth2_SOURCES = oauth2.c
flickr_SOURCES = flickr.c
diff --git a/tests/oauth2.c b/tests/oauth2.c
new file mode 100644
index 0000000..e992b6a
--- /dev/null
+++ b/tests/oauth2.c
@@ -0,0 +1,56 @@
+/*
+ * librest - RESTful web services access
+ * Copyright (c) 2010 Intel Corporation.
+ *
+ * Authors: Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <rest/oauth2-proxy.h>
+#include <string.h>
+
+void
+test_extract_token ()
+{
+ char *token;
+
+ /* test a url without a fragment */
+ token = oauth2_proxy_extract_access_token ("http://example.com/");
+ g_assert (token == NULL);
+
+ /* test a url with a fragment but without an access_token parameter */
+ token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#bar");
+ g_assert (token == NULL);
+
+ /* test simple access_token */
+ token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#access_token=1234567890_12.34561abcdefg&bar");
+ g_assert (strcmp(token, "1234567890_12.34561abcdefg") == 0);
+
+ /* test access_token with url encoding */
+ token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#access_token=1234567890%5F12%2E34561abcdefg&bar");
+ g_assert (strcmp(token, "1234567890_12.34561abcdefg") == 0);
+}
+
+int
+main (int argc, char **argv)
+{
+ g_thread_init (NULL);
+ g_type_init ();
+
+ test_extract_token ();
+
+ return 0;
+}