factor/extra/oauth2/oauth2-tests.factor

44 lines
1.1 KiB
Factor
Raw Normal View History

USING: accessors calendar kernel oauth2 tools.test urls ;
2016-10-17 07:05:18 -04:00
! assoc>tokens
{
"blah" "bleh" t
} [
H{
{ "expires_in" 3600 }
{ "access_token" "blah" }
{ "token_type" "Bearer" }
{ "refresh_token" "bleh" }
} assoc>tokens
[ access>> ] [ refresh>> ] [ expiry>> timestamp? ] tri
] unit-test
2016-10-17 07:05:18 -04:00
! oauth2>auth-uri
{
URL" https://github.com/login/oauth/authorize?client_id=1234&scope=user&redirect_uri=test-pest&state=abcd&response_type=code&access_type=offline"
} [
"https://github.com/login/oauth/authorize"
"https://github.com/login/oauth/access_token"
"test-pest"
"1234" "password" "user"
{ { "state" "abcd" } } oauth2 boa oauth2>auth-uri
] unit-test
! tokens-params
2016-10-17 07:05:18 -04:00
{
{
{ "code" "hej" }
2016-10-17 07:05:18 -04:00
{ "client_id" "1234" }
{ "client_secret" "password" }
{ "redirect_uri" "test-pest" }
{ "state" "abcd" }
{ "grant_type" "authorization_code" }
}
} [
"https://github.com/login/oauth/authorize"
"https://github.com/login/oauth/access_token"
"test-pest"
"1234" "password" "user" { { "state" "abcd" } } oauth2 boa
"hej" tokens-params
2016-10-17 07:05:18 -04:00
] unit-test