Skip to content

Commit a618558

Browse files
committed
style(api): satisfy discovery lint checks
1 parent 8fb9939 commit a618558

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

internal/cmd/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ func TestDiscoveryMethodPolicyRequiresExplicitPermission(t *testing.T) {
6464
}
6565

6666
func TestValidateDiscoveryRedirect(t *testing.T) {
67-
trusted, err := http.NewRequest(http.MethodGet, "https://gmail.googleapis.com/gmail/v1/users/me/labels", nil)
67+
trusted, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "https://gmail.googleapis.com/gmail/v1/users/me/labels", nil)
6868
if err != nil {
6969
t.Fatal(err)
7070
}
71-
if err := validateDiscoveryRedirect(trusted, nil); err != nil {
72-
t.Fatalf("trusted redirect: %v", err)
71+
if redirectErr := validateDiscoveryRedirect(trusted, nil); redirectErr != nil {
72+
t.Fatalf("trusted redirect: %v", redirectErr)
7373
}
7474

75-
untrusted, err := http.NewRequest(http.MethodGet, "https://example.test/steal", nil)
75+
untrusted, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "https://example.test/steal", nil)
7676
if err != nil {
7777
t.Fatal(err)
7878
}

internal/discoveryapi/discovery.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ func BuildURL(description *discovery.RestDescription, method Method, params map[
218218
func ValidateGoogleAPIURL(requestURL string) error {
219219
u, err := url.Parse(requestURL)
220220
if err != nil {
221-
return fmt.Errorf("%w: %v", ErrUntrustedAPIURL, err)
221+
return fmt.Errorf("%w: %w", ErrUntrustedAPIURL, err)
222222
}
223+
223224
host := strings.ToLower(strings.TrimSuffix(u.Hostname(), "."))
224225
if u.Scheme != "https" || u.User != nil || host == "" || (host != "googleapis.com" && !strings.HasSuffix(host, ".googleapis.com")) {
225226
return fmt.Errorf("%w: %q", ErrUntrustedAPIURL, requestURL)

0 commit comments

Comments
 (0)