mirror of
https://github.com/safing/portbase
synced 2025-09-10 06:15:08 +00:00
Fix tests and linter warnings
This commit is contained in:
parent
7d2cd6c15d
commit
f59ad0357a
162 changed files with 668 additions and 696 deletions
|
@ -9,9 +9,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
testToken = new(AuthToken)
|
||||
)
|
||||
var testToken = new(AuthToken)
|
||||
|
||||
func testAuthenticator(r *http.Request, s *http.Server) (*AuthToken, error) {
|
||||
switch {
|
||||
|
@ -65,7 +63,9 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPermissions(t *testing.T) { //nolint:gocognit
|
||||
func TestPermissions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testHandler := &mainHandler{
|
||||
mux: mainMux,
|
||||
}
|
||||
|
@ -99,10 +99,11 @@ func TestPermissions(t *testing.T) { //nolint:gocognit
|
|||
http.MethodHead,
|
||||
http.MethodPost,
|
||||
http.MethodPut,
|
||||
http.MethodDelete,
|
||||
} {
|
||||
|
||||
// Set request permission for test requests.
|
||||
reading := method == http.MethodGet
|
||||
_, reading, _ := getEffectiveMethod(&http.Request{Method: method})
|
||||
if reading {
|
||||
testToken.Read = requestPerm
|
||||
testToken.Write = NotSupported
|
||||
|
@ -147,7 +148,6 @@ func TestPermissions(t *testing.T) { //nolint:gocognit
|
|||
}
|
||||
|
||||
if expectSuccess {
|
||||
|
||||
// Test for success.
|
||||
if !assert.HTTPBodyContains(
|
||||
t,
|
||||
|
@ -164,9 +164,7 @@ func TestPermissions(t *testing.T) { //nolint:gocognit
|
|||
handlerPerm, handlerPerm,
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Test for error.
|
||||
if !assert.HTTPError(t,
|
||||
testHandler.ServeHTTP,
|
||||
|
@ -181,7 +179,6 @@ func TestPermissions(t *testing.T) { //nolint:gocognit
|
|||
handlerPerm, handlerPerm,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +186,8 @@ func TestPermissions(t *testing.T) { //nolint:gocognit
|
|||
}
|
||||
|
||||
func TestPermissionDefinitions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if NotSupported != 0 {
|
||||
t.Fatalf("NotSupported must be zero, was %v", NotSupported)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue