fix(ci): satisfy golangci-lint in api keys code
CI / changes (push) Successful in 7s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 41s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m18s
CI / changes (push) Successful in 7s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 41s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m18s
Правки errcheck в тестах httpapi и gofmt полей APIKeyPatch в store. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -25,7 +25,7 @@ func TestBearerDevWithoutInsecureDev(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
b, _ := io.ReadAll(resp.Body)
|
b, _ := io.ReadAll(resp.Body)
|
||||||
t.Fatalf("status=%d body=%s", resp.StatusCode, b)
|
t.Fatalf("status=%d body=%s", resp.StatusCode, b)
|
||||||
@@ -53,7 +53,7 @@ func TestAPIKeysCRUDAndAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer respCreate.Body.Close()
|
defer func() { _ = respCreate.Body.Close() }()
|
||||||
if respCreate.StatusCode != http.StatusCreated {
|
if respCreate.StatusCode != http.StatusCreated {
|
||||||
b, _ := io.ReadAll(respCreate.Body)
|
b, _ := io.ReadAll(respCreate.Body)
|
||||||
t.Fatalf("create status=%d body=%s", respCreate.StatusCode, b)
|
t.Fatalf("create status=%d body=%s", respCreate.StatusCode, b)
|
||||||
@@ -77,7 +77,7 @@ func TestAPIKeysCRUDAndAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer respMod.Body.Close()
|
defer func() { _ = respMod.Body.Close() }()
|
||||||
if respMod.StatusCode != http.StatusOK {
|
if respMod.StatusCode != http.StatusOK {
|
||||||
b, _ := io.ReadAll(respMod.Body)
|
b, _ := io.ReadAll(respMod.Body)
|
||||||
t.Fatalf("modules status=%d body=%s", respMod.StatusCode, b)
|
t.Fatalf("modules status=%d body=%s", respMod.StatusCode, b)
|
||||||
@@ -89,7 +89,7 @@ func TestAPIKeysCRUDAndAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer respDel.Body.Close()
|
defer func() { _ = respDel.Body.Close() }()
|
||||||
if respDel.StatusCode != http.StatusNoContent {
|
if respDel.StatusCode != http.StatusNoContent {
|
||||||
t.Fatalf("delete status=%d", respDel.StatusCode)
|
t.Fatalf("delete status=%d", respDel.StatusCode)
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func TestAPIKeysCRUDAndAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer respAfter.Body.Close()
|
defer func() { _ = respAfter.Body.Close() }()
|
||||||
if respAfter.StatusCode != http.StatusUnauthorized {
|
if respAfter.StatusCode != http.StatusUnauthorized {
|
||||||
t.Fatalf("expected 401 after revoke, got %d", respAfter.StatusCode)
|
t.Fatalf("expected 401 after revoke, got %d", respAfter.StatusCode)
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ func TestAPIKeysCRUDAndAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer respNode.Body.Close()
|
defer func() { _ = respNode.Body.Close() }()
|
||||||
if respNode.StatusCode != http.StatusForbidden {
|
if respNode.StatusCode != http.StatusForbidden {
|
||||||
t.Fatalf("node list api-keys status=%d want 403", respNode.StatusCode)
|
t.Fatalf("node list api-keys status=%d want 403", respNode.StatusCode)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,10 +260,10 @@ type APIKeyCreate struct {
|
|||||||
|
|
||||||
// APIKeyPatch is a partial update (role change affects auth after resolver reload).
|
// APIKeyPatch is a partial update (role change affects auth after resolver reload).
|
||||||
type APIKeyPatch struct {
|
type APIKeyPatch struct {
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
Role *string `json:"role,omitempty"`
|
Role *string `json:"role,omitempty"`
|
||||||
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||||||
ClearExpiresAt bool `json:"-"`
|
ClearExpiresAt bool `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIKeyWithSecret is returned only on create/rotate.
|
// APIKeyWithSecret is returned only on create/rotate.
|
||||||
|
|||||||
Reference in New Issue
Block a user