From ba2d122308155878e88479077a71dba3374e962b Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Mon, 20 May 2024 11:34:52 -0500 Subject: [PATCH] fix lint --- .../downstreamsubject/downstream_subject.go | 4 ++-- .../downstreamsubject/downstream_subject_test.go | 8 ++++---- internal/githubclient/githubclient.go | 3 +++ internal/githubclient/githubclient_test.go | 9 ++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/federationdomain/downstreamsubject/downstream_subject.go b/internal/federationdomain/downstreamsubject/downstream_subject.go index 78d202918..d4c206ce7 100644 --- a/internal/federationdomain/downstreamsubject/downstream_subject.go +++ b/internal/federationdomain/downstreamsubject/downstream_subject.go @@ -25,8 +25,8 @@ func OIDC(upstreamIssuerAsString string, upstreamSubject string, idpDisplayName ) } -func GitHub(APIBaseURL, idpDisplayName, login, id string) string { - return fmt.Sprintf("%s?%s=%s&login=%s&id=%s", APIBaseURL, +func GitHub(apiBaseURL, idpDisplayName, login, id string) string { + return fmt.Sprintf("%s?%s=%s&login=%s&id=%s", apiBaseURL, oidc.IDTokenSubClaimIDPNameQueryParam, url.QueryEscape(idpDisplayName), url.QueryEscape(login), url.QueryEscape(id), ) diff --git a/internal/federationdomain/downstreamsubject/downstream_subject_test.go b/internal/federationdomain/downstreamsubject/downstream_subject_test.go index 8add3c077..3e57707ef 100644 --- a/internal/federationdomain/downstreamsubject/downstream_subject_test.go +++ b/internal/federationdomain/downstreamsubject/downstream_subject_test.go @@ -93,7 +93,7 @@ func TestOIDC(t *testing.T) { func TestGitHub(t *testing.T) { tests := []struct { name string - APIBaseURL string + apiBaseURL string idpDisplayName string login string id string @@ -101,7 +101,7 @@ func TestGitHub(t *testing.T) { }{ { name: "simple display name", - APIBaseURL: "https://github.com", + apiBaseURL: "https://github.com", idpDisplayName: "simpleName", login: "some login", id: "some id", @@ -109,7 +109,7 @@ func TestGitHub(t *testing.T) { }, { name: "interesting display name", - APIBaseURL: "https://server.example.com:1234/path", + apiBaseURL: "https://server.example.com:1234/path", idpDisplayName: "this is a 👍 display name that 🦭 can handle", login: "some other login", id: "some other id", @@ -121,7 +121,7 @@ func TestGitHub(t *testing.T) { t.Run(test.name, func(t *testing.T) { t.Parallel() - actual := GitHub(test.APIBaseURL, test.idpDisplayName, test.login, test.id) + actual := GitHub(test.apiBaseURL, test.idpDisplayName, test.login, test.id) require.Equal(t, test.wantSubject, actual) }) diff --git a/internal/githubclient/githubclient.go b/internal/githubclient/githubclient.go index 807fe5ae4..8fdaea6fc 100644 --- a/internal/githubclient/githubclient.go +++ b/internal/githubclient/githubclient.go @@ -1,3 +1,6 @@ +// Copyright 2024 the Pinniped contributors. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + package githubclient import ( diff --git a/internal/githubclient/githubclient_test.go b/internal/githubclient/githubclient_test.go index 36924fc8a..35ffc4e46 100644 --- a/internal/githubclient/githubclient_test.go +++ b/internal/githubclient/githubclient_test.go @@ -1,3 +1,6 @@ +// Copyright 2024 the Pinniped contributors. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + package githubclient import ( @@ -107,7 +110,11 @@ func TestNewGitHubClient(t *testing.T) { require.Equal(t, test.wantBaseURL, actual.client.BaseURL.String()) // Force the githubClient's httpClient roundTrippers to run and add the Authorization header - _, err = actual.client.Client().Get(testServer.URL) + + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, testServer.URL, nil) + require.NoError(t, err) + + _, err = actual.client.Client().Do(req) //nolint:bodyclose require.NoError(t, err) }) }