]> gitweb.factorcode.org Git - factor.git/blob - extra/oauth2/oauth2-tests.factor
ff0c5d59755d9184c1ebeafb0c8d316dbbad6ce1
[factor.git] / extra / oauth2 / oauth2-tests.factor
1 USING: accessors calendar kernel oauth2 tools.test urls ;
2 IN: oauth2.tests
3
4 ! assoc>tokens
5 {
6     "blah" "bleh" t
7 } [
8     H{
9         { "expires_in" 3600 }
10         { "access_token" "blah" }
11         { "token_type" "Bearer" }
12         { "refresh_token" "bleh" }
13     } assoc>tokens
14     [ access>> ] [ refresh>> ] [ expiry>> timestamp? ] tri
15 ] unit-test
16
17 ! oauth2>auth-uri
18 {
19     URL" https://github.com/login/oauth/authorize?client_id=1234&scope=user&redirect_uri=test-pest&state=abcd&response_type=code&access_type=offline"
20 } [
21     "https://github.com/login/oauth/authorize"
22     "https://github.com/login/oauth/access_token"
23     "test-pest"
24     "1234" "password" "user"
25     { { "state" "abcd" } } oauth2 boa oauth2>auth-uri
26 ] unit-test
27
28 ! tokens-params
29 {
30     {
31         { "code" "hej" }
32         { "client_id" "1234" }
33         { "client_secret" "password" }
34         { "redirect_uri" "test-pest" }
35         { "state" "abcd" }
36         { "grant_type" "authorization_code" }
37     }
38 } [
39     "https://github.com/login/oauth/authorize"
40     "https://github.com/login/oauth/access_token"
41     "test-pest"
42     "1234" "password" "user" { { "state" "abcd" } } oauth2 boa
43     "hej" tokens-params
44 ] unit-test