diff --git a/google/internal/oauth2/clientAuthentication.go b/google/internal/oauth/clientAuthentication.go similarity index 99% rename from google/internal/oauth2/clientAuthentication.go rename to google/internal/oauth/clientAuthentication.go index 3cb6bad..fc09998 100644 --- a/google/internal/oauth2/clientAuthentication.go +++ b/google/internal/oauth/clientAuthentication.go @@ -36,4 +36,4 @@ func (c *ClientAuthentication) InjectAuthentication(values *url.Values, headers } return -} \ No newline at end of file +} diff --git a/google/internal/oauth2/clientAuthentication_test.go b/google/internal/oauth/clientAuthentication_test.go similarity index 64% rename from google/internal/oauth2/clientAuthentication_test.go rename to google/internal/oauth/clientAuthentication_test.go index 1e0d854..50bcedf 100644 --- a/google/internal/oauth2/clientAuthentication_test.go +++ b/google/internal/oauth/clientAuthentication_test.go @@ -8,39 +8,38 @@ import ( "testing" ) - var clientID = "rbrgnognrhongo3bi4gb9ghg9g" var clientSecret = "notsosecret" -var valuesH = url.Values { - "audience": []string{"32555940559.apps.googleusercontent.com"}, - "grant_type": []string{"urn:ietf:params:oauth:grant-type:token-exchange"}, +var valuesH = url.Values{ + "audience": []string{"32555940559.apps.googleusercontent.com"}, + "grant_type": []string{"urn:ietf:params:oauth:grant-type:token-exchange"}, "requested_token_type": []string{"urn:ietf:params:oauth:token-type:access_token"}, - "subject_token_type": []string{"urn:ietf:params:oauth:token-type:jwt"}, - "subject_token": []string{"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJjNmZhNmY1OTUwYTdjZTQ2NWZjZjI0N2FhMGIwOTQ4MjhhYzk1MmMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6IjMyNTU1OTQwNTU5LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEzMzE4NTQxMDA5MDU3Mzc4MzI4IiwiaGQiOiJnb29nbGUuY29tIiwiZW1haWwiOiJpdGh1cmllbEBnb29nbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiI5OVJVYVFrRHJsVDFZOUV0SzdiYXJnIiwiaWF0IjoxNjAxNTgxMzQ5LCJleHAiOjE2MDE1ODQ5NDl9.SZ-4DyDcogDh_CDUKHqPCiT8AKLg4zLMpPhGQzmcmHQ6cJiV0WRVMf5Lq911qsvuekgxfQpIdKNXlD6yk3FqvC2rjBbuEztMF-OD_2B8CEIYFlMLGuTQimJlUQksLKM-3B2ITRDCxnyEdaZik0OVssiy1CBTsllS5MgTFqic7w8w0Cd6diqNkfPFZRWyRYsrRDRlHHbH5_TUnv2wnLVHBHlNvU4wU2yyjDIoqOvTRp8jtXdq7K31CDhXd47-hXsVFQn2ZgzuUEAkH2Q6NIXACcVyZOrjBcZiOQI9IRWz-g03LzbzPSecO7I8dDrhqUSqMrdNUz_f8Kr8JFhuVMfVug"}, - "scope": []string{"https://www.googleapis.com/auth/devstorage.full_control"}, + "subject_token_type": []string{"urn:ietf:params:oauth:token-type:jwt"}, + "subject_token": []string{"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJjNmZhNmY1OTUwYTdjZTQ2NWZjZjI0N2FhMGIwOTQ4MjhhYzk1MmMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6IjMyNTU1OTQwNTU5LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEzMzE4NTQxMDA5MDU3Mzc4MzI4IiwiaGQiOiJnb29nbGUuY29tIiwiZW1haWwiOiJpdGh1cmllbEBnb29nbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiI5OVJVYVFrRHJsVDFZOUV0SzdiYXJnIiwiaWF0IjoxNjAxNTgxMzQ5LCJleHAiOjE2MDE1ODQ5NDl9.SZ-4DyDcogDh_CDUKHqPCiT8AKLg4zLMpPhGQzmcmHQ6cJiV0WRVMf5Lq911qsvuekgxfQpIdKNXlD6yk3FqvC2rjBbuEztMF-OD_2B8CEIYFlMLGuTQimJlUQksLKM-3B2ITRDCxnyEdaZik0OVssiy1CBTsllS5MgTFqic7w8w0Cd6diqNkfPFZRWyRYsrRDRlHHbH5_TUnv2wnLVHBHlNvU4wU2yyjDIoqOvTRp8jtXdq7K31CDhXd47-hXsVFQn2ZgzuUEAkH2Q6NIXACcVyZOrjBcZiOQI9IRWz-g03LzbzPSecO7I8dDrhqUSqMrdNUz_f8Kr8JFhuVMfVug"}, + "scope": []string{"https://www.googleapis.com/auth/devstorage.full_control"}, } -var headerH = http.Header { +var headerH = http.Header{ "Content-Type": []string{"application/x-www-form-urlencoded"}, } -var valuesP = url.Values { - "audience": []string{"32555940559.apps.googleusercontent.com"}, - "grant_type": []string{"urn:ietf:params:oauth:grant-type:token-exchange"}, +var valuesP = url.Values{ + "audience": []string{"32555940559.apps.googleusercontent.com"}, + "grant_type": []string{"urn:ietf:params:oauth:grant-type:token-exchange"}, "requested_token_type": []string{"urn:ietf:params:oauth:token-type:access_token"}, - "subject_token_type": []string{"urn:ietf:params:oauth:token-type:jwt"}, - "subject_token": []string{"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJjNmZhNmY1OTUwYTdjZTQ2NWZjZjI0N2FhMGIwOTQ4MjhhYzk1MmMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6IjMyNTU1OTQwNTU5LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEzMzE4NTQxMDA5MDU3Mzc4MzI4IiwiaGQiOiJnb29nbGUuY29tIiwiZW1haWwiOiJpdGh1cmllbEBnb29nbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiI5OVJVYVFrRHJsVDFZOUV0SzdiYXJnIiwiaWF0IjoxNjAxNTgxMzQ5LCJleHAiOjE2MDE1ODQ5NDl9.SZ-4DyDcogDh_CDUKHqPCiT8AKLg4zLMpPhGQzmcmHQ6cJiV0WRVMf5Lq911qsvuekgxfQpIdKNXlD6yk3FqvC2rjBbuEztMF-OD_2B8CEIYFlMLGuTQimJlUQksLKM-3B2ITRDCxnyEdaZik0OVssiy1CBTsllS5MgTFqic7w8w0Cd6diqNkfPFZRWyRYsrRDRlHHbH5_TUnv2wnLVHBHlNvU4wU2yyjDIoqOvTRp8jtXdq7K31CDhXd47-hXsVFQn2ZgzuUEAkH2Q6NIXACcVyZOrjBcZiOQI9IRWz-g03LzbzPSecO7I8dDrhqUSqMrdNUz_f8Kr8JFhuVMfVug"}, - "scope": []string{"https://www.googleapis.com/auth/devstorage.full_control"}, + "subject_token_type": []string{"urn:ietf:params:oauth:token-type:jwt"}, + "subject_token": []string{"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJjNmZhNmY1OTUwYTdjZTQ2NWZjZjI0N2FhMGIwOTQ4MjhhYzk1MmMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6IjMyNTU1OTQwNTU5LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEzMzE4NTQxMDA5MDU3Mzc4MzI4IiwiaGQiOiJnb29nbGUuY29tIiwiZW1haWwiOiJpdGh1cmllbEBnb29nbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiI5OVJVYVFrRHJsVDFZOUV0SzdiYXJnIiwiaWF0IjoxNjAxNTgxMzQ5LCJleHAiOjE2MDE1ODQ5NDl9.SZ-4DyDcogDh_CDUKHqPCiT8AKLg4zLMpPhGQzmcmHQ6cJiV0WRVMf5Lq911qsvuekgxfQpIdKNXlD6yk3FqvC2rjBbuEztMF-OD_2B8CEIYFlMLGuTQimJlUQksLKM-3B2ITRDCxnyEdaZik0OVssiy1CBTsllS5MgTFqic7w8w0Cd6diqNkfPFZRWyRYsrRDRlHHbH5_TUnv2wnLVHBHlNvU4wU2yyjDIoqOvTRp8jtXdq7K31CDhXd47-hXsVFQn2ZgzuUEAkH2Q6NIXACcVyZOrjBcZiOQI9IRWz-g03LzbzPSecO7I8dDrhqUSqMrdNUz_f8Kr8JFhuVMfVug"}, + "scope": []string{"https://www.googleapis.com/auth/devstorage.full_control"}, } -var headerP = http.Header { +var headerP = http.Header{ "Content-Type": []string{"application/x-www-form-urlencoded"}, } func TestClientAuthentication_InjectHeaderAuthentication(t *testing.T) { headerAuthentication := ClientAuthentication{ - AuthStyle: oauth2.AuthStyleInHeader, - ClientID: clientID, + AuthStyle: oauth2.AuthStyleInHeader, + ClientID: clientID, ClientSecret: clientSecret, } headerAuthentication.InjectAuthentication(&valuesH, &headerH) @@ -63,15 +62,15 @@ func TestClientAuthentication_InjectHeaderAuthentication(t *testing.T) { if got, want := valuesH["scope"], []string{"https://www.googleapis.com/auth/devstorage.full_control"}; !reflect.DeepEqual(got, want) { t.Errorf("scope = %q, want %q", got, want) } - if got, want := headerH["Authorization"],[]string{"Basic cmJyZ25vZ25yaG9uZ28zYmk0Z2I5Z2hnOWc6bm90c29zZWNyZXQ="}; !reflect.DeepEqual(got, want) { + if got, want := headerH["Authorization"], []string{"Basic cmJyZ25vZ25yaG9uZ28zYmk0Z2I5Z2hnOWc6bm90c29zZWNyZXQ="}; !reflect.DeepEqual(got, want) { t.Errorf("Authorization in header = %q, want %q", got, want) } } func TestClientAuthentication_ParamsAuthentication(t *testing.T) { paramsAuthentication := ClientAuthentication{ - AuthStyle: oauth2.AuthStyleInParams, - ClientID: clientID, + AuthStyle: oauth2.AuthStyleInParams, + ClientID: clientID, ClientSecret: clientSecret, } paramsAuthentication.InjectAuthentication(&valuesP, &headerP) @@ -100,4 +99,4 @@ func TestClientAuthentication_ParamsAuthentication(t *testing.T) { if got, want := valuesP["scope"], []string{"https://www.googleapis.com/auth/devstorage.full_control"}; !reflect.DeepEqual(got, want) { t.Errorf("scope = %q, want %q", got, want) } -} \ No newline at end of file +} diff --git a/google/internal/oauth2/err.go b/google/internal/oauth/err.go similarity index 99% rename from google/internal/oauth2/err.go rename to google/internal/oauth/err.go index 594b19f..8e183d3 100644 --- a/google/internal/oauth2/err.go +++ b/google/internal/oauth/err.go @@ -11,4 +11,4 @@ type Error struct { func (err *Error) Error() string { return fmt.Sprintf("got error code %s from %s: %s", err.Code, err.URI, err.Description) -} \ No newline at end of file +} diff --git a/google/internal/oauth2/err_test.go b/google/internal/oauth/err_test.go similarity index 99% rename from google/internal/oauth2/err_test.go rename to google/internal/oauth/err_test.go index 3b6690d..74a9462 100644 --- a/google/internal/oauth2/err_test.go +++ b/google/internal/oauth/err_test.go @@ -12,4 +12,4 @@ func TestError_Generator(t *testing.T) { if got, want := e, output; e.Error() != output { t.Errorf("Got error message %q; want %q", got, want) } -} \ No newline at end of file +}