Resolves #4. Fix Gopkg.toml structure, update all outdated dependencies, use middlewares introduced in gorilla/mux 1.6.1, replace gopkg.in/h2non/gock.v1 with it's GitHub link github.com/h2non/gock

This commit is contained in:
ErickSkrauch 2019-05-01 01:47:55 +03:00
parent 8aeb1929b5
commit a81c6fc9f8
6 changed files with 63 additions and 57 deletions

80
Gopkg.lock generated
View File

@ -40,35 +40,43 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:82da6a2b72827cb7031d3b9e44e24aebcf17e878e4c8af6ba16503021e2de6f9" digest = "1:904b0b847f705de43c15e6c8f3dd639044db5601dedfb2f3fdb3021a28491d15"
name = "github.com/getsentry/raven-go" name = "github.com/getsentry/raven-go"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "d175f85701dfbf44cb0510114c9943e665e60907" revision = "919484f041ea21e7e27be291cee1d6af7bc98864"
[[projects]] [[projects]]
digest = "1:a1bad350477afbc84e8cbe5c78be4579478c55335377239631ff0adb985fbabc" digest = "1:530233672f656641b365f8efb38ed9fba80e420baff2ce87633813ab3755ed6d"
name = "github.com/golang/mock" name = "github.com/golang/mock"
packages = ["gomock"] packages = ["gomock"]
pruneopts = "" pruneopts = ""
revision = "13f360950a79f5864a972c786a10a50e44b69541" revision = "51421b967af1f557f93a59e0057aaf15ca02e29c"
version = "v1.0.0" version = "v1.2.0"
[[projects]] [[projects]]
digest = "1:20ed7daa9b3b38b6d1d39b48ab3fd31122be5419461470d0c28de3e121c93ecf" digest = "1:65c7ed49d9f36dd4752e43013323fa9229db60b29aa4f5a75aaecda3130c74e2"
name = "github.com/gorilla/context"
packages = ["."]
pruneopts = ""
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
version = "v1.1"
[[projects]]
digest = "1:783fde5796ef54ba05de240f2529b6c9fbabc541e70ea43585c53b3f1bbabb5b"
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "bcd8bc72b08df0f70df986b97f95590779502d31" revision = "c5c6c98bc25355028a63748a498942a6398ccd22"
version = "v1.4.0" version = "v1.7.1"
[[projects]]
digest = "1:5eeb4bfc6db411dbb34a6d9e5d49a9956b160d59fd004ee8f03fe53c9605c082"
name = "github.com/h2non/gock"
packages = ["."]
pruneopts = ""
revision = "ba88c4862a27596539531ce469478a91bc5a0511"
version = "v1.0.14"
[[projects]]
digest = "1:0f31ddb2589297fc1d716f45b34e34bff34e968de1aa239543274c87522e86f4"
name = "github.com/h2non/parth"
packages = ["."]
pruneopts = ""
revision = "b4df798d65426f8c8ab5ca5f9987aec5575d26c9"
version = "v2.0.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -78,6 +86,7 @@
".", ".",
"hcl/ast", "hcl/ast",
"hcl/parser", "hcl/parser",
"hcl/printer",
"hcl/scanner", "hcl/scanner",
"hcl/strconv", "hcl/strconv",
"hcl/token", "hcl/token",
@ -106,7 +115,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:539b18d9ba35afbd27dcae32cff46177ec4af9209dce144048331b584c739e56" digest = "1:19a9f4143462f07553e9bf6ae0f1b8633a2c44763b1df90d4e9e49f51cd8423a"
name = "github.com/mediocregopher/radix.v2" name = "github.com/mediocregopher/radix.v2"
packages = [ packages = [
"cluster", "cluster",
@ -115,7 +124,7 @@
"util", "util",
] ]
pruneopts = "" pruneopts = ""
revision = "d234cfb904a91daafa4e1f92599a893b349cc0c2" revision = "b67df6e626f993b64b3ca9f4b8630900e61002e3"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -195,12 +204,12 @@
version = "v1.1.0" version = "v1.1.0"
[[projects]] [[projects]]
branch = "master" digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6"
digest = "1:7747c74ea2256d41544c67b1e4e473b6be1122dd42f35541589f0ba8f3cfd981"
name = "github.com/spf13/cobra" name = "github.com/spf13/cobra"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "0c34d16c3123764e413b9ed982ada58b1c3d53ea" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385"
version = "v0.0.3"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -211,20 +220,20 @@
revision = "12bd96e66386c1960ab0f74ced1362f66f552f7b" revision = "12bd96e66386c1960ab0f74ced1362f66f552f7b"
[[projects]] [[projects]]
digest = "1:261bc565833ef4f02121450d74eb88d5ae4bd74bfe5d0e862cddb8550ec35000" digest = "1:cbaf13cdbfef0e4734ed8a7504f57fe893d471d62a35b982bf6fb3f036449a66"
name = "github.com/spf13/pflag" name = "github.com/spf13/pflag"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" revision = "298182f68c66c05229eb03ac171abe6e309ee79a"
version = "v1.0.0" version = "v1.0.3"
[[projects]] [[projects]]
digest = "1:59354ad53dfe6ed1b941844cb029cd37c0377598eec3a0d49c03aee2375ef9c4" digest = "1:90fe60ab6f827e308b0c8cc1e11dce8ff1e96a927c8b171271a3cb04dd517606"
name = "github.com/spf13/viper" name = "github.com/spf13/viper"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" revision = "9e56dacc08fbbf8c9ee2dbc717553c758ce42bc9"
version = "v1.0.0" version = "v1.3.2"
[[projects]] [[projects]]
digest = "1:711eebe744c0151a9d09af2315f0bb729b2ec7637ef4c410fa90a18ef74b65b6" digest = "1:711eebe744c0151a9d09af2315f0bb729b2ec7637ef4c410fa90a18ef74b65b6"
@ -256,13 +265,12 @@
revision = "9b9efcf221b50905aab9bbabd3daed56dc10f339" revision = "9b9efcf221b50905aab9bbabd3daed56dc10f339"
[[projects]] [[projects]]
branch = "issue-18" digest = "1:061754b9de261d8e1cf804970dff7b3e105d1cb4883ef446dbe911489ba8e9eb"
digest = "1:123d45cdeb4dbefa402fb700760b0a5f8d1cb5ed55c78a757dc4bb5c12a7b3db"
name = "github.com/thedevsaddam/govalidator" name = "github.com/thedevsaddam/govalidator"
packages = ["."] packages = ["."]
pruneopts = "" pruneopts = ""
revision = "59055296916bb3c6ad9cf3b21d5f2cf7059f8e76" revision = "0413a0eb80cac8ab2d666639130658ce49a0c967"
source = "https://github.com/erickskrauch/govalidator.git" version = "v1.9.6"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -287,14 +295,6 @@
pruneopts = "" pruneopts = ""
revision = "bd91bbf73e9a4a801adbfb97133c992678533126" revision = "bd91bbf73e9a4a801adbfb97133c992678533126"
[[projects]]
digest = "1:6a8a36d8b25b669d77ff638f7acdf4d3439ce6c349461f246b2c450b0b4b3bc8"
name = "gopkg.in/h2non/gock.v1"
packages = ["."]
pruneopts = ""
revision = "a6029d17e101ac1594adafea9e63fd8c988a8701"
version = "v1.0.12"
[[projects]] [[projects]]
branch = "v2" branch = "v2"
digest = "1:81314a486195626940617e43740b4fa073f265b0715c9f54ce2027fee1cb5f61" digest = "1:81314a486195626940617e43740b4fa073f265b0715c9f54ce2027fee1cb5f61"
@ -312,6 +312,7 @@
"github.com/getsentry/raven-go", "github.com/getsentry/raven-go",
"github.com/golang/mock/gomock", "github.com/golang/mock/gomock",
"github.com/gorilla/mux", "github.com/gorilla/mux",
"github.com/h2non/gock",
"github.com/mediocregopher/radix.v2/pool", "github.com/mediocregopher/radix.v2/pool",
"github.com/mediocregopher/radix.v2/redis", "github.com/mediocregopher/radix.v2/redis",
"github.com/mediocregopher/radix.v2/util", "github.com/mediocregopher/radix.v2/util",
@ -328,7 +329,6 @@
"github.com/stretchr/testify/suite", "github.com/stretchr/testify/suite",
"github.com/tevino/abool", "github.com/tevino/abool",
"github.com/thedevsaddam/govalidator", "github.com/thedevsaddam/govalidator",
"gopkg.in/h2non/gock.v1",
] ]
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View File

@ -2,23 +2,27 @@ ignored = ["github.com/elyby/chrly"]
[[constraint]] [[constraint]]
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
version = "1.4.0" version = "^1.6.1"
[[constraint]] [[constraint]]
name = "github.com/mediocregopher/radix.v2" name = "github.com/mediocregopher/radix.v2"
[[constraint]]
name = "github.com/mono83/slf"
[[constraint]]
name = "github.com/spf13/cobra"
branch = "master" branch = "master"
[[constraint]]
name = "github.com/mono83/slf"
branch = "master"
[[constraint]]
name = "github.com/spf13/cobra"
version = "^0.0.3"
[[constraint]] [[constraint]]
name = "github.com/spf13/viper" name = "github.com/spf13/viper"
version = "^1.0.0"
[[constraint]] [[constraint]]
name = "github.com/getsentry/raven-go" name = "github.com/getsentry/raven-go"
branch = "master"
[[constraint]] [[constraint]]
name = "github.com/SermoDigital/jose" name = "github.com/SermoDigital/jose"
@ -26,12 +30,11 @@ ignored = ["github.com/elyby/chrly"]
[[constraint]] [[constraint]]
name = "github.com/thedevsaddam/govalidator" name = "github.com/thedevsaddam/govalidator"
source = "https://github.com/erickskrauch/govalidator.git" version = "^1.9.6"
branch = "issue-18"
[[constraint]] [[constraint]]
branch = "master"
name = "github.com/tevino/abool" name = "github.com/tevino/abool"
branch = "master"
# Testing dependencies # Testing dependencies
@ -44,5 +47,5 @@ ignored = ["github.com/elyby/chrly"]
version = "^1.0.0" version = "^1.0.0"
[[constraint]] [[constraint]]
name = "gopkg.in/h2non/gock.v1" name = "github.com/h2non/gock"
version = "^1.0.6" version = "^1.0.6"

View File

@ -4,8 +4,8 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/h2non/gock"
testify "github.com/stretchr/testify/assert" testify "github.com/stretchr/testify/assert"
"gopkg.in/h2non/gock.v1"
) )
func TestSignedTexturesResponse(t *testing.T) { func TestSignedTexturesResponse(t *testing.T) {

View File

@ -20,6 +20,7 @@ import (
//noinspection GoSnakeCaseUsage //noinspection GoSnakeCaseUsage
const UUID_ANY = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" const UUID_ANY = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
var regexUuidAny = regexp.MustCompile(UUID_ANY) var regexUuidAny = regexp.MustCompile(UUID_ANY)
func init() { func init() {
@ -115,7 +116,7 @@ func (cfg *Config) DeleteSkinByUsername(resp http.ResponseWriter, req *http.Requ
cfg.deleteSkin(skin, resp) cfg.deleteSkin(skin, resp)
} }
func (cfg *Config) Authenticate(handler http.Handler) http.Handler { func (cfg *Config) AuthenticationMiddleware(handler http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
cfg.Logger.IncCounter("authentication.challenge", 1) cfg.Logger.IncCounter("authentication.challenge", 1)
err := cfg.Auth.Check(req) err := cfg.Auth.Check(req)

View File

@ -482,7 +482,7 @@ func TestConfig_Authenticate(t *testing.T) {
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1)) mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1)) mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1))
res := config.Authenticate(http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {})) res := config.AuthenticationMiddleware(http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {}))
res.ServeHTTP(w, req) res.ServeHTTP(w, req)
resp := w.Result() resp := w.Result()

View File

@ -60,9 +60,11 @@ func (cfg *Config) CreateHandler() http.Handler {
router.HandleFunc("/skins", cfg.SkinGET).Methods("GET") router.HandleFunc("/skins", cfg.SkinGET).Methods("GET")
router.HandleFunc("/cloaks", cfg.CapeGET).Methods("GET") router.HandleFunc("/cloaks", cfg.CapeGET).Methods("GET")
// API // API
router.Handle("/api/skins", cfg.Authenticate(http.HandlerFunc(cfg.PostSkin))).Methods("POST") apiRouter := router.PathPrefix("/api").Subrouter()
router.Handle("/api/skins/id:{id:[0-9]+}", cfg.Authenticate(http.HandlerFunc(cfg.DeleteSkinByUserId))).Methods("DELETE") apiRouter.Use(cfg.AuthenticationMiddleware)
router.Handle("/api/skins/{username}", cfg.Authenticate(http.HandlerFunc(cfg.DeleteSkinByUsername))).Methods("DELETE") apiRouter.Handle("/skins", http.HandlerFunc(cfg.PostSkin)).Methods("POST")
apiRouter.Handle("/skins/id:{id:[0-9]+}", http.HandlerFunc(cfg.DeleteSkinByUserId)).Methods("DELETE")
apiRouter.Handle("/skins/{username}", http.HandlerFunc(cfg.DeleteSkinByUsername)).Methods("DELETE")
// 404 // 404
router.NotFoundHandler = http.HandlerFunc(cfg.NotFound) router.NotFoundHandler = http.HandlerFunc(cfg.NotFound)