From 4a1d3a65210f012ffafe16642fa1692154215383 Mon Sep 17 00:00:00 2001 From: Mark Wolfe Date: Tue, 7 Jan 2020 09:02:18 +1100 Subject: [PATCH] Updates to fix naming and layout --- endpoints/endpoints.go | 28 +++++++++++++++------------- endpoints/endpoints_test.go | 4 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/endpoints/endpoints.go b/endpoints/endpoints.go index bbb8f34..2572dca 100644 --- a/endpoints/endpoints.go +++ b/endpoints/endpoints.go @@ -18,7 +18,8 @@ var Amazon = oauth2.Endpoint{ } // Bitbucket provides endpoint for using OAuth2 to access Bitbucket. -var Bitbucket = oauth2.Endpoint{AuthURL: "https://bitbucket.org/site/oauth2/authorize", +var Bitbucket = oauth2.Endpoint{ + AuthURL: "https://bitbucket.org/site/oauth2/authorize", TokenURL: "https://bitbucket.org/site/oauth2/access_token", } @@ -46,14 +47,14 @@ var Fitbit = oauth2.Endpoint{ TokenURL: "https://api.fitbit.com/oauth2/token", } -// Github provides endpoint for using OAuth2 to access Github. -var Github = oauth2.Endpoint{ +// GitHub provides endpoint for using OAuth2 to access Github. +var GitHub = oauth2.Endpoint{ AuthURL: "https://github.com/login/oauth/authorize", TokenURL: "https://github.com/login/oauth/access_token", } -// Gitlab provides endpoint for using OAuth2 to access Gitlab. -var Gitlab = oauth2.Endpoint{ +// GitLab provides endpoint for using OAuth2 to access Gitlab. +var GitLab = oauth2.Endpoint{ AuthURL: "https://gitlab.com/oauth/authorize", TokenURL: "https://gitlab.com/oauth/token", } @@ -70,8 +71,9 @@ var Heroku = oauth2.Endpoint{ TokenURL: "https://id.heroku.com/oauth/token", } -// Hipchat provides endpoint for using OAuth2 to access Hipchat. -var Hipchat = oauth2.Endpoint{AuthURL: "https://www.hipchat.com/users/authorize", +// HipChat provides endpoint for using OAuth2 to access HipChat. +var HipChat = oauth2.Endpoint{ + AuthURL: "https://www.hipchat.com/users/authorize", TokenURL: "https://api.hipchat.com/v2/oauth/token", } @@ -105,8 +107,8 @@ var Mailru = oauth2.Endpoint{ TokenURL: "https://o2.mail.ru/token", } -// Mediamath provides endpoint for using OAuth2 to access Mediamath. -var Mediamath = oauth2.Endpoint{ +// MediaMath provides endpoint for using OAuth2 to access MediaMath. +var MediaMath = oauth2.Endpoint{ AuthURL: "https://api.mediamath.com/oauth2/v1.0/authorize", TokenURL: "https://api.mediamath.com/oauth2/v1.0/token", } @@ -210,16 +212,16 @@ func AzureAD(tenant string) oauth2.Endpoint { } } -// HipchatServer returns a new oauth2.Endpoint for a HipChat Server instance +// HipChatServer returns a new oauth2.Endpoint for a HipChat Server instance // running on the given domain or host. -func HipchatServer(host string) oauth2.Endpoint { +func HipChatServer(host string) oauth2.Endpoint { return oauth2.Endpoint{ AuthURL: "https://" + host + "/users/authorize", TokenURL: "https://" + host + "/v2/oauth/token", } } -// Cognito returns a new oauth2.Endpoint for the supplied AWS Cognito domain which is +// AWSCognito returns a new oauth2.Endpoint for the supplied AWS Cognito domain which is // linked to your Cognito User Pool. // // Example domain: https://testing.auth.us-east-1.amazoncognito.com @@ -227,7 +229,7 @@ func HipchatServer(host string) oauth2.Endpoint { // For more information see: // https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-assign-domain.html // https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html -func Cognito(domain string) oauth2.Endpoint { +func AWSCognito(domain string) oauth2.Endpoint { domain = strings.TrimRight(domain, "/") return oauth2.Endpoint{ AuthURL: domain + "/oauth2/authorize", diff --git a/endpoints/endpoints_test.go b/endpoints/endpoints_test.go index 5e8e767..4ffa314 100644 --- a/endpoints/endpoints_test.go +++ b/endpoints/endpoints_test.go @@ -10,7 +10,7 @@ import ( "golang.org/x/oauth2" ) -func TestCognitoEndpoint(t *testing.T) { +func TestAWSCognitoEndpoint(t *testing.T) { var endpointTests = []struct { in string @@ -34,7 +34,7 @@ func TestCognitoEndpoint(t *testing.T) { for _, tt := range endpointTests { t.Run(tt.in, func(t *testing.T) { - endpoint := Cognito(tt.in) + endpoint := AWSCognito(tt.in) if endpoint != tt.out { t.Errorf("got %q, want %q", endpoint, tt.out) }