diff options
| author | Amir Zarrinkafsh <nightah@me.com> | 2020-04-09 11:05:17 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-09 11:05:17 +1000 |
| commit | de2c5836fd8a2b99260b555173fcd3023292da0f (patch) | |
| tree | 6af2c37c31a8d439dbb0432ec54b8cb7f7978bd9 /internal/handlers/handler_verify_test.go | |
| parent | 2fed503e5e538cbbdcdc09ff52a1ddad94218400 (diff) | |
[Buildkite] Introduce CI linting with golangci-lint and reviewdog (#832)
* [Buildkite] Introduce CI linting with golangci-lint and reviewdog
* Initial pass of golangci-lint
* Add gosimple (megacheck) recommendations
* Add golint recommendations
* [BUGFIX] Migrate authentication traces from v3 mongodb
* Add deadcode recommendations
* [BUGFIX] Fix ShortTimeouts suite when run in dev workflow
* Add unused recommendations
* Add unparam recommendations
* Disable linting on unfixable errors instead of skipping files
* Adjust nolint notation for unparam
* Fix ineffectual assignment to err raised by linter.
* Export environment variable in agent hook
* Add ineffassign recommendations
* Add staticcheck recommendations
* Add gocyclo recommendations
* Adjust ineffassign recommendations
Co-authored-by: Clement Michaud <clement.michaud34@gmail.com>
Diffstat (limited to 'internal/handlers/handler_verify_test.go')
| -rw-r--r-- | internal/handlers/handler_verify_test.go | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/internal/handlers/handler_verify_test.go b/internal/handlers/handler_verify_test.go index 6bd8e23b5..1fed911a7 100644 --- a/internal/handlers/handler_verify_test.go +++ b/internal/handlers/handler_verify_test.go @@ -147,21 +147,21 @@ func TestShouldCheckAuthorizationMatching(t *testing.T) { ExpectedMatching authorizationMatching } rules := []Rule{ - Rule{"bypass", authentication.NotAuthenticated, Authorized}, - Rule{"bypass", authentication.OneFactor, Authorized}, - Rule{"bypass", authentication.TwoFactor, Authorized}, + {"bypass", authentication.NotAuthenticated, Authorized}, + {"bypass", authentication.OneFactor, Authorized}, + {"bypass", authentication.TwoFactor, Authorized}, - Rule{"one_factor", authentication.NotAuthenticated, NotAuthorized}, - Rule{"one_factor", authentication.OneFactor, Authorized}, - Rule{"one_factor", authentication.TwoFactor, Authorized}, + {"one_factor", authentication.NotAuthenticated, NotAuthorized}, + {"one_factor", authentication.OneFactor, Authorized}, + {"one_factor", authentication.TwoFactor, Authorized}, - Rule{"two_factor", authentication.NotAuthenticated, NotAuthorized}, - Rule{"two_factor", authentication.OneFactor, NotAuthorized}, - Rule{"two_factor", authentication.TwoFactor, Authorized}, + {"two_factor", authentication.NotAuthenticated, NotAuthorized}, + {"two_factor", authentication.OneFactor, NotAuthorized}, + {"two_factor", authentication.TwoFactor, Authorized}, - Rule{"deny", authentication.NotAuthenticated, NotAuthorized}, - Rule{"deny", authentication.OneFactor, Forbidden}, - Rule{"deny", authentication.TwoFactor, Forbidden}, + {"deny", authentication.NotAuthenticated, NotAuthorized}, + {"deny", authentication.OneFactor, Forbidden}, + {"deny", authentication.TwoFactor, Forbidden}, } url, _ := url.ParseRequestURI("https://test.example.com") @@ -169,7 +169,7 @@ func TestShouldCheckAuthorizationMatching(t *testing.T) { for _, rule := range rules { authorizer := authorization.NewAuthorizer(schema.AccessControlConfiguration{ DefaultPolicy: "deny", - Rules: []schema.ACLRule{schema.ACLRule{ + Rules: []schema.ACLRule{{ Domain: "test.example.com", Policy: rule.Policy, }}, @@ -419,23 +419,23 @@ func (p Pair) String() string { func TestShouldVerifyAuthorizationsUsingSessionCookie(t *testing.T) { testCases := []Pair{ - Pair{"https://test.example.com", "", authentication.NotAuthenticated, 401}, - Pair{"https://bypass.example.com", "", authentication.NotAuthenticated, 200}, - Pair{"https://one-factor.example.com", "", authentication.NotAuthenticated, 401}, - Pair{"https://two-factor.example.com", "", authentication.NotAuthenticated, 401}, - Pair{"https://deny.example.com", "", authentication.NotAuthenticated, 401}, - - Pair{"https://test.example.com", "john", authentication.OneFactor, 403}, - Pair{"https://bypass.example.com", "john", authentication.OneFactor, 200}, - Pair{"https://one-factor.example.com", "john", authentication.OneFactor, 200}, - Pair{"https://two-factor.example.com", "john", authentication.OneFactor, 401}, - Pair{"https://deny.example.com", "john", authentication.OneFactor, 403}, - - Pair{"https://test.example.com", "john", authentication.TwoFactor, 403}, - Pair{"https://bypass.example.com", "john", authentication.TwoFactor, 200}, - Pair{"https://one-factor.example.com", "john", authentication.TwoFactor, 200}, - Pair{"https://two-factor.example.com", "john", authentication.TwoFactor, 200}, - Pair{"https://deny.example.com", "john", authentication.TwoFactor, 403}, + {"https://test.example.com", "", authentication.NotAuthenticated, 401}, + {"https://bypass.example.com", "", authentication.NotAuthenticated, 200}, + {"https://one-factor.example.com", "", authentication.NotAuthenticated, 401}, + {"https://two-factor.example.com", "", authentication.NotAuthenticated, 401}, + {"https://deny.example.com", "", authentication.NotAuthenticated, 401}, + + {"https://test.example.com", "john", authentication.OneFactor, 403}, + {"https://bypass.example.com", "john", authentication.OneFactor, 200}, + {"https://one-factor.example.com", "john", authentication.OneFactor, 200}, + {"https://two-factor.example.com", "john", authentication.OneFactor, 401}, + {"https://deny.example.com", "john", authentication.OneFactor, 403}, + + {"https://test.example.com", "john", authentication.TwoFactor, 403}, + {"https://bypass.example.com", "john", authentication.TwoFactor, 200}, + {"https://one-factor.example.com", "john", authentication.TwoFactor, 200}, + {"https://two-factor.example.com", "john", authentication.TwoFactor, 200}, + {"https://deny.example.com", "john", authentication.TwoFactor, 403}, } for _, testCase := range testCases { @@ -628,7 +628,6 @@ func TestSchemeIsHTTPS(t *testing.T) { GetURL("wss://mytest.example.com/abc/?query=abc"))) assert.True(t, isSchemeHTTPS( GetURL("https://mytest.example.com/abc/?query=abc"))) - } func TestSchemeIsWSS(t *testing.T) { @@ -646,5 +645,4 @@ func TestSchemeIsWSS(t *testing.T) { GetURL("https://mytest.example.com/abc/?query=abc"))) assert.True(t, isSchemeWSS( GetURL("wss://mytest.example.com/abc/?query=abc"))) - } |
