paypal/auth_test.go

41 lines
1.3 KiB
Go
Raw Normal View History

2015-10-15 10:47:36 +02:00
package paypalsdk
import (
2015-10-30 08:02:32 +01:00
"testing"
2015-10-15 10:47:36 +02:00
)
func TestGetAuthorizationCodeURL(t *testing.T) {
2015-10-30 08:02:32 +01:00
c, _ := NewClient("clid", "secret", APIBaseSandBox)
_, err := c.GetAuthorizationCodeURL("", []string{})
if err == nil {
t.Errorf("redirectURI is required in GetAuthorizationCodeURL")
}
uri, err := c.GetAuthorizationCodeURL("test", []string{})
2015-11-17 04:03:46 +01:00
if uri != "https://sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=profile+email&redirect_uri=test" {
t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test " + uri)
2015-10-30 08:02:32 +01:00
}
uri, err = c.GetAuthorizationCodeURL("test", []string{"address"})
2015-11-17 04:03:46 +01:00
if uri != "https://sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=address&redirect_uri=test" {
t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test and scope=address " + uri)
2015-10-30 08:02:32 +01:00
}
2015-10-15 10:47:36 +02:00
}
2015-10-16 12:00:57 +02:00
2015-10-30 08:02:32 +01:00
func TestGetAccessToken(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
2015-10-16 12:00:57 +02:00
2015-10-30 08:02:32 +01:00
_, err := c.GetAccessToken("123", "")
if err == nil {
t.Errorf("redirectURI is required in GetRefreshToken")
}
2015-10-16 12:00:57 +02:00
2015-10-30 08:02:32 +01:00
_, err = c.GetAccessToken("", "123")
if err == nil {
t.Errorf("authorizationCode is required in GetRefreshToken")
}
2015-10-16 12:00:57 +02:00
2015-10-30 08:02:32 +01:00
_, err = c.GetAccessToken("123", "123")
2015-10-16 12:00:57 +02:00
}