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