refactor: fix linter directives for go 1.19 and golangci-lint 1.48.0 (#3798)

This commit is contained in:
Amir Zarrinkafsh 2022-08-07 11:24:00 +10:00 committed by GitHub
parent c585e19499
commit 2d26b4e115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 26 deletions

View File

@ -29,7 +29,7 @@ func (suite *NotifierSuite) SetupTest() {
} }
/* /*
Common Tests. Common Tests.
*/ */
func (suite *NotifierSuite) TestShouldEnsureAtLeastSMTPOrFilesystemIsProvided() { func (suite *NotifierSuite) TestShouldEnsureAtLeastSMTPOrFilesystemIsProvided() {
ValidateNotifier(&suite.config, suite.validator) ValidateNotifier(&suite.config, suite.validator)
@ -69,7 +69,7 @@ func (suite *NotifierSuite) TestShouldEnsureEitherSMTPOrFilesystemIsProvided() {
} }
/* /*
SMTP Tests. SMTP Tests.
*/ */
func (suite *NotifierSuite) TestSMTPShouldSetTLSDefaults() { func (suite *NotifierSuite) TestSMTPShouldSetTLSDefaults() {
ValidateNotifier(&suite.config, suite.validator) ValidateNotifier(&suite.config, suite.validator)
@ -146,7 +146,7 @@ func (suite *NotifierSuite) TestSMTPShouldEnsureSenderIsProvided() {
} }
/* /*
File Tests. File Tests.
*/ */
func (suite *NotifierSuite) TestFileShouldEnsureFilenameIsProvided() { func (suite *NotifierSuite) TestFileShouldEnsureFilenameIsProvided() {
suite.config.SMTP = nil suite.config.SMTP = nil

View File

@ -11,6 +11,7 @@ import (
) )
// FirstFactorPOST is the handler performing the first factory. // FirstFactorPOST is the handler performing the first factory.
//
//nolint:gocyclo // TODO: Consider refactoring time permitting. //nolint:gocyclo // TODO: Consider refactoring time permitting.
func FirstFactorPOST(delayFunc middlewares.TimingAttackDelayFunc) middlewares.RequestHandler { func FirstFactorPOST(delayFunc middlewares.TimingAttackDelayFunc) middlewares.RequestHandler {
return func(ctx *middlewares.AutheliaCtx) { return func(ctx *middlewares.AutheliaCtx) {

View File

@ -346,11 +346,14 @@ func (s *FirstFactorRedirectionSuite) TearDownTest() {
} }
// When: // When:
// 1/ the target url is unknown //
// 2/ two_factor is disabled (no policy is set to two_factor) // 1/ the target url is unknown
// 3/ default_redirect_url is provided // 2/ two_factor is disabled (no policy is set to two_factor)
// 3/ default_redirect_url is provided
//
// Then: // Then:
// the user should be redirected to the default url. //
// the user should be redirected to the default url.
func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTargetURLProvidedAndTwoFactorDisabled() { func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTargetURLProvidedAndTwoFactorDisabled() {
s.mock.Ctx.Request.SetBodyString(`{ s.mock.Ctx.Request.SetBodyString(`{
"username": "test", "username": "test",
@ -365,11 +368,14 @@ func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTarget
} }
// When: // When:
// 1/ the target url is unsafe //
// 2/ two_factor is disabled (no policy is set to two_factor) // 1/ the target url is unsafe
// 3/ default_redirect_url is provided // 2/ two_factor is disabled (no policy is set to two_factor)
// 3/ default_redirect_url is provided
//
// Then: // Then:
// the user should be redirected to the default url. //
// the user should be redirected to the default url.
func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUnsafeAndTwoFactorDisabled() { func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUnsafeAndTwoFactorDisabled() {
s.mock.Ctx.Request.SetBodyString(`{ s.mock.Ctx.Request.SetBodyString(`{
"username": "test", "username": "test",
@ -386,9 +392,12 @@ func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUns
} }
// When: // When:
// 1/ two_factor is enabled (default policy) //
// 1/ two_factor is enabled (default policy)
//
// Then: // Then:
// the user should receive 200 without redirection URL. //
// the user should receive 200 without redirection URL.
func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedAndTwoFactorEnabled() { func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedAndTwoFactorEnabled() {
s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{ s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{
AccessControl: schema.AccessControlConfiguration{ AccessControl: schema.AccessControlConfiguration{
@ -409,9 +418,12 @@ func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedA
} }
// When: // When:
// 1/ two_factor is enabled (some rule) //
// 1/ two_factor is enabled (some rule)
//
// Then: // Then:
// the user should receive 200 without redirection URL. //
// the user should receive 200 without redirection URL.
func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenUnsafeTargetURLProvidedAndTwoFactorEnabled() { func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenUnsafeTargetURLProvidedAndTwoFactorEnabled() {
s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{ s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{
AccessControl: schema.AccessControlConfiguration{ AccessControl: schema.AccessControlConfiguration{

View File

@ -48,8 +48,9 @@ func OpenIDConnectConsentGET(ctx *middlewares.AutheliaCtx) {
} }
} }
//nolint:gocyclo
// OpenIDConnectConsentPOST handles consent responses for OpenID Connect. // OpenIDConnectConsentPOST handles consent responses for OpenID Connect.
//
//nolint:gocyclo // TODO: Consider refactoring time permitting.
func OpenIDConnectConsentPOST(ctx *middlewares.AutheliaCtx) { func OpenIDConnectConsentPOST(ctx *middlewares.AutheliaCtx) {
var ( var (
consentID uuid.UUID consentID uuid.UUID

View File

@ -9,12 +9,12 @@ import (
) )
/* /*
TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret. TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret.
This test is vital to ensuring the TOTP configuration is marshalled correctly. If encoding/json suddenly changes This test is vital to ensuring the TOTP configuration is marshalled correctly. If encoding/json suddenly changes
upstream and the json tag value of '-' doesn't exclude the field from marshalling then this test will pickup this upstream and the json tag value of '-' doesn't exclude the field from marshalling then this test will pickup this
issue prior to code being shipped. issue prior to code being shipped.
For this reason it's essential that the marshalled object contains all values populated, especially the secret. For this reason it's essential that the marshalled object contains all values populated, especially the secret.
*/ */
func TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret(t *testing.T) { func TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret(t *testing.T) {
object := TOTPConfiguration{ object := TOTPConfiguration{

View File

@ -156,6 +156,7 @@ type ConsentPostResponseBody struct {
/* /*
CommonDiscoveryOptions represents the discovery options used in both OAuth 2.0 and OpenID Connect. CommonDiscoveryOptions represents the discovery options used in both OAuth 2.0 and OpenID Connect.
See Also: See Also:
OpenID Connect Discovery: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata OpenID Connect Discovery: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
OAuth 2.0 Discovery: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-discovery-10#section-2 OAuth 2.0 Discovery: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-discovery-10#section-2
*/ */
@ -514,7 +515,8 @@ type OpenIDConnectDiscoveryOptions struct {
// OpenIDConnectFrontChannelLogoutDiscoveryOptions represents the discovery options specific to // OpenIDConnectFrontChannelLogoutDiscoveryOptions represents the discovery options specific to
// OpenID Connect Front-Channel Logout functionality. // OpenID Connect Front-Channel Logout functionality.
// See Also: // See Also:
// OpenID Connect Front-Channel Logout: https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout //
// OpenID Connect Front-Channel Logout: https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct { type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct {
/* /*
OPTIONAL. Boolean value specifying whether the OP supports HTTP-based logout, with true indicating support. If OPTIONAL. Boolean value specifying whether the OP supports HTTP-based logout, with true indicating support. If
@ -533,7 +535,8 @@ type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct {
// OpenIDConnectBackChannelLogoutDiscoveryOptions represents the discovery options specific to // OpenIDConnectBackChannelLogoutDiscoveryOptions represents the discovery options specific to
// OpenID Connect Back-Channel Logout functionality. // OpenID Connect Back-Channel Logout functionality.
// See Also: // See Also:
// OpenID Connect Back-Channel Logout: https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport //
// OpenID Connect Back-Channel Logout: https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport
type OpenIDConnectBackChannelLogoutDiscoveryOptions struct { type OpenIDConnectBackChannelLogoutDiscoveryOptions struct {
/* /*
OPTIONAL. Boolean value specifying whether the OP supports back-channel logout, with true indicating support. OPTIONAL. Boolean value specifying whether the OP supports back-channel logout, with true indicating support.

View File

@ -133,7 +133,7 @@ func (p *SQLProvider) SchemaMigrate(ctx context.Context, up bool, version int) (
return p.schemaMigrate(ctx, currentVersion, version) return p.schemaMigrate(ctx, currentVersion, version)
} }
//nolint: gocyclo //nolint:gocyclo // TODO: Consider refactoring time permitting.
func (p *SQLProvider) schemaMigrate(ctx context.Context, prior, target int) (err error) { func (p *SQLProvider) schemaMigrate(ctx context.Context, prior, target int) (err error) {
migrations, err := loadMigrations(p.name, prior, target) migrations, err := loadMigrations(p.name, prior, target)
if err != nil { if err != nil {

View File

@ -32,9 +32,8 @@ var BuildNumber = "0"
// Version returns the Authelia version. // Version returns the Authelia version.
// //
// The format of the string is dependent on the values in BuildState. If tagged and clean are present it returns the // The format of the string is dependent on the values in BuildState. If tagged and clean are present it returns the
// BuildTag i.e. v1.0.0. If dirty and tagged are present it returns <BuildTag>-dirty. Otherwise the following is the // BuildTag i.e. v1.0.0. If dirty and tagged are present it returns <BuildTag>-dirty. Otherwise, the following is the
// format: untagged-<BuildTag>-dirty-<BuildExtra> (<BuildBranch>, <BuildCommit>). // format: untagged-<BuildTag>-dirty-<BuildExtra> (<BuildBranch>, <BuildCommit>).
//
func Version() (versionString string) { func Version() (versionString string) {
return version(BuildTag, BuildState, BuildCommit, BuildBranch, BuildExtra) return version(BuildTag, BuildState, BuildCommit, BuildBranch, BuildExtra)
} }