blob: f4819ff9c2b5ce3cdc3021537ec1ba672ab75223 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* 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_type_init ();
test_extract_token ();
return 0;
}
|