From 1e3307dcbef1bfc11999a9856d63c45458c38f07 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 3 Mar 2021 00:24:31 +0100 Subject: [PATCH] Fixes CHRLY-S. Don't return an error for an invalid username --- mojangtextures/mojang_textures.go | 3 +-- mojangtextures/mojang_textures_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mojangtextures/mojang_textures.go b/mojangtextures/mojang_textures.go index a5252d2..c092169 100644 --- a/mojangtextures/mojang_textures.go +++ b/mojangtextures/mojang_textures.go @@ -1,7 +1,6 @@ package mojangtextures import ( - "errors" "regexp" "strings" "sync" @@ -92,7 +91,7 @@ func (ctx *Provider) GetForUsername(username string) (*mojang.SignedTexturesResp }) if !allowedUsernamesRegex.MatchString(username) { - return nil, errors.New("invalid username") + return nil, nil } username = strings.ToLower(username) diff --git a/mojangtextures/mojang_textures_test.go b/mojangtextures/mojang_textures_test.go index 4417d94..b4a328b 100644 --- a/mojangtextures/mojang_textures_test.go +++ b/mojangtextures/mojang_textures_test.go @@ -391,7 +391,7 @@ func (suite *providerTestSuite) TestGetForTheSameUsernames() { func (suite *providerTestSuite) TestGetForNotAllowedMojangUsername() { result, err := suite.Provider.GetForUsername("Not allowed") - suite.Assert().Error(err, "invalid username") + suite.Assert().Nil(err) suite.Assert().Nil(result) }