diff --git a/.gitignore b/.gitignore index b563fd7..5751de6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .idea -test.env .vscode \ No newline at end of file diff --git a/cmd/verification/main.go b/cmd/verification/main.go index 7e020ae..f8e35d7 100644 --- a/cmd/verification/main.go +++ b/cmd/verification/main.go @@ -1,16 +1,37 @@ package main import ( + "go.uber.org/zap" "log" + "os" "penahub.gitlab.yandexcloud.net/backend/verification/internal/app" "penahub.gitlab.yandexcloud.net/backend/verification/internal/config" + "time" ) +var ( + commit string = os.Getenv("COMMIT") + buildTime string = os.Getenv("BUILD_TIME") + version string = os.Getenv("VERSION") +) + +// $env:COMMIT=$(git rev-parse --short HEAD); $env:BUILD_TIME=$(Get-Date -UFormat "%Y-%m-%dT%H:%M:%SZ"); $env:VERSION=$(git describe --tags); go run cmd/verification/main.go + func main() { + ptime, err := time.Parse(time.RFC3339, buildTime) + if err != nil { + log.Println("Error parsing build time:", zap.Error(err)) + ptime = time.Now() + } + cfg, err := config.NewConfig("staging.env") if err != nil { log.Fatal("can't load config: ", err.Error()) } - app.Run(cfg) + app.Run(cfg, app.Build{ + Commit: commit, + Version: version, + BuildTime: ptime.Unix(), + }) } diff --git a/go.mod b/go.mod index 5178ae5..490de41 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,39 @@ module penahub.gitlab.yandexcloud.net/backend/verification -go 1.21 +go 1.22.0 -toolchain go1.21.4 +toolchain go1.22.2 require ( github.com/caarlos0/env/v8 v8.0.0 github.com/go-playground/validator/v10 v10.14.1 github.com/gofiber/contrib/fiberzap v1.0.2 - github.com/gofiber/fiber/v2 v2.51.0 + github.com/gofiber/fiber/v2 v2.52.1 github.com/joho/godotenv v1.5.1 github.com/minio/minio-go/v7 v7.0.56 - go.mongodb.org/mongo-driver v1.13.1 - go.uber.org/zap v1.24.0 - penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d + github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf + go.mongodb.org/mongo-driver v1.14.0 + go.uber.org/zap v1.27.0 + penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a + penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 + penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240526134522-aab18dfcec46 ) require ( - github.com/kr/pretty v0.1.0 // indirect - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect + github.com/ClickHouse/clickhouse-go v1.5.4 // indirect + github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/skeris/appInit v1.0.2 // indirect + go.etcd.io/bbolt v1.3.6 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect + google.golang.org/grpc v1.62.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/tucnak/telebot.v2 v2.5.0 // indirect ) require ( - github.com/andybalholm/brotli v1.0.5 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -30,11 +41,10 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 - github.com/golang/snappy v0.0.1 // indirect - github.com/google/go-cmp v0.5.8 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect + github.com/google/uuid v1.6.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.16.7 // indirect + github.com/klauspost/compress v1.17.7 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -44,26 +54,25 @@ require ( github.com/minio/sha256-simd v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect + github.com/montanaflynn/stats v0.7.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.4.3 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/rs/xid v1.5.0 // indirect github.com/sirupsen/logrus v1.9.2 // indirect github.com/stretchr/testify v1.8.4 github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.50.0 + github.com/valyala/fasthttp v1.52.0 github.com/valyala/tcplisten v1.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect - github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.9.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/text v0.9.0 // indirect + github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/crypto v0.20.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2eb8929..b66873d 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,14 @@ -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= +github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/bkaradzic/go-lz4 v1.0.0 h1:RXc4wYsyz985CkXXeX04y4VnZFGG8Rd43pRaHsOXAKk= +github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/caarlos0/env/v8 v8.0.0 h1:POhxHhSpuxrLMIdvTGARuZqR4Jjm8AYmoi/JKlcScs0= github.com/caarlos0/env/v8 v8.0.0/go.mod h1:7K4wMY9bH0esiXSSHlfHLX5xKGQMnkH5Fk4TDSSSzfo= +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,6 +16,10 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= @@ -21,37 +30,46 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= github.com/gofiber/contrib/fiberzap v1.0.2 h1:EQwhggtszVfIdBeXxN9Xrmld71es34Ufs+ef8VMqZxc= github.com/gofiber/contrib/fiberzap v1.0.2/go.mod h1:jGO8BHU4gRI9U0JtM6zj2CIhYfgVmW5JxziN8NTgVwE= -github.com/gofiber/fiber/v2 v2.51.0 h1:JNACcZy5e2tGApWB2QrRpenTWn0fq0hkFm6k0C86gKQ= -github.com/gofiber/fiber/v2 v2.51.0/go.mod h1:xaQRZQJGqnKOQnbQw+ltvku3/h8QxvNi8o6JiJ7Ll0U= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gofiber/fiber/v2 v2.52.1 h1:1RoU2NS+b98o1L77sdl5mboGPiW+0Ypsi5oLmcYlgHI= +github.com/gofiber/fiber/v2 v2.52.1/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -59,6 +77,7 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v7 v7.0.56 h1:pkZplIEHu8vinjkmhsexcXpWth2tjVLphrTZx6fBVZY= @@ -70,33 +89,55 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.16.0 h1:NBrNLB37exjJLxXtFOktx6CISBdS1aF8+7MwKlTV8U4= +github.com/onsi/ginkgo v1.16.0/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= +github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= +github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pioz/faker v1.7.3 h1:Tez8Emuq0UN+/d6mo3a9m/9ZZ/zdfJk0c5RtRatrceM= +github.com/pioz/faker v1.7.3/go.mod h1:xSpay5w/oz1a6+ww0M3vfpe40pSIykeUPeWEc3TvVlc= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= -github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/skeris/appInit v1.0.2 h1:Hr4KbXYd6kolTVq4cXGqDpgnpmaauiOiKizA1+Ep4KQ= +github.com/skeris/appInit v1.0.2/go.mod h1:4ElEeXWVGzU3dlYq/eMWJ/U5hd+LKisc1z3+ySh1XmY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33 h1:N9f/Q+2Ssa+yDcbfaoLTYvXmdeyUUxsJKdPUVsjSmiA= +github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33/go.mod h1:rpcH99JknBh8seZmlOlUg51gasZH6QH34oXNsIwYT6E= +github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf h1:TJJm6KcBssmbWzplF5lzixXl1RBAi/ViPs1GaSOkhwo= +github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf/go.mod h1:1FsorU3vnXO9xS9SrhUp8fRb/6H/Zfll0rPt1i4GWaA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.50.0 h1:H7fweIlBm0rXLs2q0XbalvJ6r0CUPFWK3/bB4N13e9M= -github.com/valyala/fasthttp v1.50.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= +github.com/valyala/fasthttp v1.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0= +github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= @@ -105,39 +146,47 @@ github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= +github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= -go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= -go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= +go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= +go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -145,31 +194,60 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= +google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/tucnak/telebot.v2 v2.5.0 h1:i+NynLo443Vp+Zn3Gv9JBjh3Z/PaiKAQwcnhNI7y6Po= +gopkg.in/tucnak/telebot.v2 v2.5.0/go.mod h1:BgaIIx50PSRS9pG59JH+geT82cfvoJU/IaI5TJdN3v8= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d h1:gbaDt35HMDqOK84WYmDIlXMI7rstUcRqNttaT6Kx1do= -penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6 h1:oV+/HNX+JPoQ3/GUx08hio7d45WpY0AMGrFs7j70QlA= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527155320-a234eec54383 h1:B6nHWxqx3YD84nHm6/TgTvaG1sRfGGOVv6tdaqJkTQ4= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527155320-a234eec54383/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c h1:jxnyIeC2CNDNmfdFx2qnLS4Qd0v5ocYrY9X+OL9qsvc= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a h1:dGW8ErUVdwGJBq6uc5AHYn6Yt10CDNkMIpV+yrDDTLs= +penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE= +penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 h1:WlRVJnzU0sti+qBq/JTCgFPU0RoxIqGHu7hzDirxE2k= +penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4= +penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240526134522-aab18dfcec46 h1:AX5HxEjjOf6YajMmi2vAB8hErBGEGouPB8ei9VVmdmo= +penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240526134522-aab18dfcec46/go.mod h1:fKiHnVzo7ScG4LNQABOxe7EdAfyu6RpkpAIXBx2I19k= diff --git a/internal/app/app_verification.go b/internal/app/app_verification.go index a907839..f626364 100644 --- a/internal/app/app_verification.go +++ b/internal/app/app_verification.go @@ -5,17 +5,28 @@ import ( tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + "github.com/themakers/hlog" "go.uber.org/zap" "go.uber.org/zap/zapcore" mongo "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" "penahub.gitlab.yandexcloud.net/backend/verification/internal/client" "penahub.gitlab.yandexcloud.net/backend/verification/internal/config" "penahub.gitlab.yandexcloud.net/backend/verification/internal/initialize" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" "penahub.gitlab.yandexcloud.net/backend/verification/internal/server" + "penahub.gitlab.yandexcloud.net/external/trashlog.git/app" + "penahub.gitlab.yandexcloud.net/external/trashlog.git/wrappers/zaptrashlog" + "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/customer_clients" "time" ) -func Run(cfg *config.Config) { +type Build struct { + Commit string + Version string + BuildTime int64 +} + +func Run(cfg *config.Config, build Build) { cfgLogger := zap.NewDevelopmentConfig() cfgLogger.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder cfgLogger.EncoderConfig.ConsoleSeparator = " " @@ -29,6 +40,19 @@ func Run(cfg *config.Config) { ctx := context.Background() + clickHouseLogger, err := zaptrashlog.NewCore(ctx, zap.InfoLevel, cfg.TrashLogHost, build.Version, build.Commit, build.BuildTime) + if err != nil { + panic(err) + } + + loggerForHlog := logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core { + return zapcore.NewTee(core, clickHouseLogger) + })) + + loggerHlog := hlog.New(loggerForHlog).Module(cfg.ModuleLogger) + loggerHlog.With(models.AllFields{}) + loggerHlog.Emit(app.InfoSvcStarted{}) + mongoDB, err := mongo.Connect(ctx, &mongo.ConnectDeps{ Configuration: &mongo.Configuration{ Host: cfg.MongoHost, @@ -69,16 +93,34 @@ func Run(cfg *config.Config) { ChatID: cfg.TelegramChannelID, StagingURL: cfg.StagingURL, }) - cons := initialize.NewControllers(reps, telegram, client.NewCustomer(logger, cfg.CustomerSvcAddress)) + cons := initialize.NewControllers(reps, telegram, customer_clients.NewCustomersClient(customer_clients.CustomersClientDeps{ + Logger: logger, + CustomerServiceHost: cfg.CustomerRPCHost, + })) - httpSrv := server.NewHTTP(cfg, logger).Register(cons.List()...) + userSrv := server.NewHTTP(server.ServerConfig{ + Logger: logger, + Controllers: []server.Controller{cons.VerificationUser}, + HLogger: loggerHlog, + }) + + adminSrv := server.NewHTTP(server.ServerConfig{ + Logger: logger, + Controllers: []server.Controller{cons.VerificationAdmin}, + HLogger: loggerHlog, + }) go func() { - err := httpSrv.Start() - if err != nil { - logger.Fatal("CanNotServe", zap.Error(err)) + if err := userSrv.Start(cfg.HttpAddressUser); err != nil { + logger.Fatal("Server startup error", zap.Error(err)) } }() - gracefulShutdown(ctx, logger, httpSrv, mongoDB) + go func() { + if err := adminSrv.Start(cfg.HttpAddressAdmin); err != nil { + logger.Fatal("Server startup error", zap.Error(err)) + } + }() + + gracefulShutdown(ctx, logger, []*server.Server{userSrv, adminSrv}, mongoDB) } diff --git a/internal/app/shutdown.go b/internal/app/shutdown.go index 3089373..dd76d4f 100644 --- a/internal/app/shutdown.go +++ b/internal/app/shutdown.go @@ -10,7 +10,7 @@ import ( "syscall" ) -func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.HTTP, mongoDB *mongo.Database) { +func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrvs []*server.Server, mongoDB *mongo.Database) { interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) killSignal := <-interrupt @@ -21,8 +21,10 @@ func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.H logger.Info("AppTerminated") } - if err := httpSrv.Stop(); err != nil { - logger.Error("HttpServerShutdown", zap.Error(err)) + for _, srv := range httpSrvs { + if err := srv.Shutdown(ctx); err != nil { + logger.Error("HttpServerShutdown", zap.Error(err)) + } } if err := mongoDB.Client().Disconnect(ctx); err != nil { diff --git a/internal/client/customer.go b/internal/client/customer.go deleted file mode 100644 index 80a2743..0000000 --- a/internal/client/customer.go +++ /dev/null @@ -1,55 +0,0 @@ -package client - -import ( - "encoding/json" - "fmt" - "github.com/gofiber/fiber/v2" - "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" -) - -type Customer struct { - logger *zap.Logger - address string -} - -func NewCustomer(logger *zap.Logger, address string) *Customer { - return &Customer{logger: logger, address: address} -} - -func (c *Customer) UpdateAccountVerification(userId, status, token string) (*models.RespUpdateVerificationStatus, error) { - agent := fiber.Patch(fmt.Sprintf("%s/account/%s", c.address, userId)).Add("Authorization",token) - agent.JSON(&models.ReqCreateVerification{Status: status}) - - err := agent.Parse() - if err != nil { - c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err)) - return nil, err - } - - var resp models.RespUpdateVerificationStatus - statusCode, body, errs := agent.Struct(&resp) - - if errs != nil || len(errs) > 0 { - for _, err := range errs { - c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err)) - } - return nil, errs[0] - } - - if statusCode != 200 { - var respErr models.RespUpdateVerificationStatusError - err = json.Unmarshal(body, &respErr) - if err != nil { - c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err)) - return nil, err - } - - err = fmt.Errorf("got bad status: %v | %v", respErr.StatusCode, respErr.Message) - c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err)) - - return nil, err - } - - return &resp, nil -} diff --git a/internal/config/config.go b/internal/config/config.go index 4935483..c39555f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,7 +8,8 @@ import ( type Config struct { TelegramToken string `env:"TELEGRAM_TOKEN,required"` TelegramChannelID int64 `env:"TELEGRAM_CHANNEL_ID,required"` - HttpAddress string `env:"HTTP_ADDRESS,required"` + HttpAddressUser string `env:"HTTP_ADDRESS_USER,required"` + HttpAddressAdmin string `env:"HTTP_ADDRESS_ADMIN,required"` MongoHost string `env:"MONGO_HOST,required"` MongoPort string `env:"MONGO_PORT,required"` MongoUser string `env:"MONGO_USER,required"` @@ -20,8 +21,11 @@ type Config struct { S3SecretKey string `env:"S3_SECRET_KEY,required"` CustomerSvcAddress string `env:"CUSTOMER_SVC_ADDRESS,required"` StagingURL string `env:"STAGING_URL,required"` - S3Folder string `env:"S3_FOLDER,required"` - S3FileUrl string `env:"S3_FILE_URL,required"` + S3Folder string `env:"S3_FOLDER,required"` + S3FileUrl string `env:"S3_FILE_URL,required"` + CustomerRPCHost string `env:"CUSTOMER_RPC_HOST,required"` + TrashLogHost string `env:"TRASH_LOG_HOST,required"` + ModuleLogger string `env:"MODULE_LOGGER,required"` } func NewConfig(file ...string) (*Config, error) { diff --git a/internal/controllers/admin/route.go b/internal/controllers/admin/route.go new file mode 100644 index 0000000..600bb95 --- /dev/null +++ b/internal/controllers/admin/route.go @@ -0,0 +1,12 @@ +package admin + +import "github.com/gofiber/fiber/v2" + +func (r *VerifyAdminController) Register(router fiber.Router) { + router.Get("/verification/:userID", r.GetVerification) + router.Patch("/verification", r.SetVerificationStatus) +} + +func (r *VerifyAdminController) Name() string { + return "" +} diff --git a/internal/controllers/admin/verification_admin.go b/internal/controllers/admin/verification_admin.go new file mode 100644 index 0000000..60f3b29 --- /dev/null +++ b/internal/controllers/admin/verification_admin.go @@ -0,0 +1,93 @@ +package admin + +import ( + "github.com/gofiber/fiber/v2" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/repository" + "penahub.gitlab.yandexcloud.net/backend/verification/pkg/validate_controllers" + "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/customer_clients" +) + +type VerifyAdminControllerDeps struct { + Repository *repository.VerificationRepository + Customer *customer_clients.CustomersClient +} + +type VerifyAdminController struct { + repository *repository.VerificationRepository + customer *customer_clients.CustomersClient +} + +func NewVerificationAdminController(deps VerifyAdminControllerDeps) *VerifyAdminController { + return &VerifyAdminController{ + repository: deps.Repository, + customer: deps.Customer, + } +} + +func (r *VerifyAdminController) SetVerificationStatus(c *fiber.Ctx) error { + var req models.ReqSetVerification + hloger := log_mw.ExtractLogger(c) + err := c.BodyParser(&req) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + errValidate := validate_controllers.ValidateStruct(&req) + if errValidate != nil { + return c.Status(fiber.StatusBadRequest).JSON(errValidate) + } + + updated, err := r.repository.Update(c.Context(), &models.Verification{ + ID: req.ID, + Accepted: req.Accepted, + Status: req.Status, + Comment: req.Comment, + TaxNumber: req.TaxNumber, + }) + + if err != nil { + return fiber.NewError(fiber.StatusInternalServerError, err.Error()) + } + + if req.Accepted { + _, err := r.customer.SetVerifyAccount(c.Context(), updated.UserID, req.Status) + if err != nil { + return fiber.NewError(fiber.StatusInternalServerError, err.Error()) + } + + hloger.Emit(models.InfoVerificationAccepted{ + CtxID: updated.ID, + KeyStatus: updated.Status, + CtxTaxNumber: updated.TaxNumber, + }) + } + + if !req.Accepted { + hloger.Emit(models.InfoVerificationDeclined{ + CtxID: updated.ID, + KeyStatus: updated.Status, + CtxComment: updated.Comment, + }) + } + + return c.SendStatus(fiber.StatusOK) +} + +func (r *VerifyAdminController) GetVerification(c *fiber.Ctx) error { + userID := c.Params("userID") + if userID == "" { + return fiber.NewError(fiber.StatusUnauthorized) + } + + resp, err := r.repository.GetByUserID(c.Context(), userID) + if err != nil { + return c.Status(fiber.StatusInternalServerError).SendString(err.Error()) + } + + if resp == nil { + return c.SendStatus(fiber.StatusNotFound) + } + + return c.Status(fiber.StatusOK).JSON(resp) +} diff --git a/internal/controllers/user/route.go b/internal/controllers/user/route.go new file mode 100644 index 0000000..e8c634c --- /dev/null +++ b/internal/controllers/user/route.go @@ -0,0 +1,13 @@ +package user + +import "github.com/gofiber/fiber/v2" + +func (r *VerifyUserController) Register(router fiber.Router) { + router.Get("/verification", r.GetVerification) + router.Post("/verification", r.CreateVerification) + router.Put("/verification", r.SetVerificationFile) +} + +func (r *VerifyUserController) Name() string { + return "" +} diff --git a/internal/controllers/verification.go b/internal/controllers/user/verification_user.go similarity index 57% rename from internal/controllers/verification.go rename to internal/controllers/user/verification_user.go index 3d33e21..c621406 100644 --- a/internal/controllers/verification.go +++ b/internal/controllers/user/verification_user.go @@ -1,43 +1,38 @@ -package controllers +package user import ( "errors" - "mime/multipart" - "github.com/gofiber/fiber/v2" "github.com/valyala/fasthttp" + "mime/multipart" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" "penahub.gitlab.yandexcloud.net/backend/verification/internal/client" "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" "penahub.gitlab.yandexcloud.net/backend/verification/internal/repository" + "penahub.gitlab.yandexcloud.net/backend/verification/pkg/validate_controllers" ) -type VerificationController struct { +type VerifyUserControllerDeps struct { + Repository *repository.VerificationRepository + Telegram *client.Telegram +} + +type VerifyUserController struct { repository *repository.VerificationRepository telegram *client.Telegram - customer *client.Customer } -func NewVerificationController(rep *repository.VerificationRepository, telegram *client.Telegram, customer *client.Customer) *VerificationController { - return &VerificationController{repository: rep, telegram: telegram, customer: customer} -} - -func (r *VerificationController) GetRoutes() []Route { - return []Route{ - {"GET", "/verification/:userID", "GetVerification", r.GetVerification}, - {"POST", "/verification", "CreateVerification", r.CreateVerification}, - {"PATCH", "/verification", "SetVerificationStatus", r.SetVerificationStatus}, - {"PATCH", "/verification/file", "SetVerificationFile", r.SetVerificationFile}, +func NewVerificationUserController(deps VerifyUserControllerDeps) *VerifyUserController { + return &VerifyUserController{ + repository: deps.Repository, + telegram: deps.Telegram, } } -func (r *VerificationController) GetVerification(c *fiber.Ctx) error { - userID := c.Params("userID") - +func (r *VerifyUserController) GetVerification(c *fiber.Ctx) error { + userID := c.Locals(models.UserCtxKey).(string) if userID == "" { - userID = c.Locals("userID").(string) - if userID == "" { - return fiber.NewError(fiber.StatusUnauthorized) - } + return fiber.NewError(fiber.StatusUnauthorized) } resp, err := r.repository.GetByUserID(c.Context(), userID) @@ -52,17 +47,14 @@ func (r *VerificationController) GetVerification(c *fiber.Ctx) error { return c.Status(fiber.StatusOK).JSON(resp) } -func (r *VerificationController) CreateVerification(c *fiber.Ctx) error { +func (r *VerifyUserController) CreateVerification(c *fiber.Ctx) error { var req models.ReqCreateVerification - - userID := c.Params("userID") baseURL := c.BaseURL() + hloger := log_mw.ExtractLogger(c) + userID := c.Locals(models.UserCtxKey).(string) if userID == "" { - userID = c.Locals("userID").(string) - if userID == "" { - return fiber.NewError(fiber.StatusUnauthorized) - } + return fiber.NewError(fiber.StatusUnauthorized) } err := c.BodyParser(&req) @@ -70,7 +62,7 @@ func (r *VerificationController) CreateVerification(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusBadRequest, err.Error()) } - errValidate := validateStruct(&req) + errValidate := validate_controllers.ValidateStruct(&req) if errValidate != nil { return c.Status(fiber.StatusBadRequest).JSON(errValidate) } @@ -122,53 +114,21 @@ func (r *VerificationController) CreateVerification(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) } + hloger.Emit(models.InfoVerificationRequested{ + CtxID: result.ID, + KeyStatus: result.Status, + }) + return c.Status(fiber.StatusOK).JSON(result) } -func (r *VerificationController) SetVerificationStatus(c *fiber.Ctx) error { - var req models.ReqSetVerification - - err := c.BodyParser(&req) - if err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - errValidate := validateStruct(&req) - if errValidate != nil { - return c.Status(fiber.StatusBadRequest).JSON(errValidate) - } - - updated, err := r.repository.Update(c.Context(), &models.Verification{ - ID: req.ID, - Accepted: req.Accepted, - Status: req.Status, - Comment: req.Comment, - TaxNumber: req.TaxNumber, - }) - - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - if req.Accepted { - token := c.Locals("token").(string) - _, err := r.customer.UpdateAccountVerification(updated.UserID, req.Status,token) - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - } - - return c.SendStatus(fiber.StatusOK) -} - -func (r *VerificationController) SetVerificationFile(c *fiber.Ctx) error { - userID := c.Params("userID") +func (r *VerifyUserController) SetVerificationFile(c *fiber.Ctx) error { baseURL := c.BaseURL() + hloger := log_mw.ExtractLogger(c) + userID := c.Locals(models.UserCtxKey).(string) if userID == "" { - userID = c.Locals("userID").(string) - if userID == "" { - return fiber.NewError(fiber.StatusUnauthorized) - } + return fiber.NewError(fiber.StatusUnauthorized) } availableFiles := []string{"inn", "rule", "egrule", "certificate"} @@ -198,5 +158,10 @@ func (r *VerificationController) SetVerificationFile(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) } + hloger.Emit(models.InfoVerificationRequested{ + CtxID: result.ID, + KeyStatus: result.Status, + }) + return c.SendStatus(fiber.StatusOK) } diff --git a/internal/controllers/verification_test.go b/internal/controllers/user/verification_user_test.go similarity index 95% rename from internal/controllers/verification_test.go rename to internal/controllers/user/verification_user_test.go index c797b12..8125ec1 100644 --- a/internal/controllers/verification_test.go +++ b/internal/controllers/user/verification_user_test.go @@ -1,11 +1,11 @@ -package controllers +package user import ( "github.com/stretchr/testify/suite" ) type VerificationTestSuite struct { - controller *VerificationController + controller *VerifyUserController suite.Suite } diff --git a/internal/initialize/controllers.go b/internal/initialize/controllers.go index 77aa6a9..3c80a5e 100644 --- a/internal/initialize/controllers.go +++ b/internal/initialize/controllers.go @@ -2,33 +2,25 @@ package initialize import ( "penahub.gitlab.yandexcloud.net/backend/verification/internal/client" - "penahub.gitlab.yandexcloud.net/backend/verification/internal/controllers" - "reflect" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/controllers/admin" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/controllers/user" + "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/customer_clients" ) -type Controller interface { - GetRoutes() []controllers.Route -} - type Controllers struct { - Verification *controllers.VerificationController + VerificationAdmin *admin.VerifyAdminController + VerificationUser *user.VerifyUserController } -func (c *Controllers) List() []Controller { - fields := reflect.ValueOf(c).Elem() - - var controllersArr []Controller - for i := 0; i < fields.NumField(); i++ { - vf := fields.Field(i) - - if vf.Type().Implements(reflect.TypeOf((*Controller)(nil)).Elem()) { - controllersArr = append(controllersArr, vf.Interface().(Controller)) - } +func NewControllers(reps *Repositories, telegram *client.Telegram, customer *customer_clients.CustomersClient) *Controllers { + return &Controllers{ + VerificationAdmin: admin.NewVerificationAdminController(admin.VerifyAdminControllerDeps{ + Repository: reps.Verification, + Customer: customer, + }), + VerificationUser: user.NewVerificationUserController(user.VerifyUserControllerDeps{ + Repository: reps.Verification, + Telegram: telegram, + }), } - - return controllersArr -} - -func NewControllers(reps *Repositories, telegram *client.Telegram, customer *client.Customer) *Controllers { - return &Controllers{Verification: controllers.NewVerificationController(reps.Verification, telegram, customer)} } diff --git a/internal/models/events_hlog.go b/internal/models/events_hlog.go new file mode 100644 index 0000000..b1b1526 --- /dev/null +++ b/internal/models/events_hlog.go @@ -0,0 +1,27 @@ +package models + +type AllFields struct { + CtxID string + KeyStatus string + CtxComment string + CtxTaxNumber string + CtxUserIP string + CtxUserPort string + KeyDomain string + KeyPath string +} + +type InfoVerificationRequested struct { //эмиттить при подаче на верификацию и при замене файла + CtxID string // - айдишник верификации + KeyStatus string // статус, который пользователь хочет обрести после верификации +} +type InfoVerificationDeclined struct { + CtxID string // - айдишник верификации + KeyStatus string // статус, который пользователь хочет обрести после верификации + CtxComment string // комментарий при отклонении +} +type InfoVerificationAccepted struct { + CtxID string // - айдишник верификации + KeyStatus string // статус, который пользователь хочет обрести после верификации + CtxTaxNumber string +} diff --git a/internal/models/validate.go b/internal/models/validate.go index 88d6db9..50216fd 100644 --- a/internal/models/validate.go +++ b/internal/models/validate.go @@ -5,3 +5,6 @@ type RespErrorValidate struct { Tag string `json:"tag"` Value string `json:"value"` } + +const UserCtxKey = "userID" +const TokenCtxKey = "token" diff --git a/internal/server/http.go b/internal/server/http.go index 176fbe1..4192838 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -1,21 +1,29 @@ package server import ( + "context" + "fmt" "github.com/gofiber/contrib/fiberzap" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/recover" + "github.com/themakers/hlog" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/backend/verification/internal/config" - "penahub.gitlab.yandexcloud.net/backend/verification/internal/initialize" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" ) -type HTTP struct { - fiber *fiber.App - cfg *config.Config - logger *zap.Logger +type ServerConfig struct { + Logger *zap.Logger + Controllers []Controller + HLogger hlog.Logger } -func NewHTTP(cfg *config.Config, logger *zap.Logger) *HTTP { +type Server struct { + Logger *zap.Logger + Controllers []Controller + app *fiber.App +} + +func NewHTTP(cfg ServerConfig) *Server { srv := fiber.New(fiber.Config{ AppName: "Verification", ErrorHandler: fiber.DefaultErrorHandler, @@ -24,30 +32,52 @@ func NewHTTP(cfg *config.Config, logger *zap.Logger) *HTTP { srv.Use( recover.New(recover.Config{EnableStackTrace: true}), - fiberzap.New(fiberzap.Config{Logger: logger}), + fiberzap.New(fiberzap.Config{Logger: cfg.Logger}), LocalJwt(), Jwt(), + log_mw.ContextLogger(cfg.HLogger), ) - return &HTTP{fiber: srv, cfg: cfg, logger: logger} + s := &Server{ + Logger: cfg.Logger, + Controllers: cfg.Controllers, + app: srv, + } + + s.registerRoutes() + + return s } -// Register - автоматически регистрирует все контроллеры. -func (srv *HTTP) Register(controllers ...initialize.Controller) *HTTP { - for _, controller := range controllers { - for _, route := range controller.GetRoutes() { - srv.fiber.Add(route.Method, route.Path, route.Handler).Name(route.Name) +func (s *Server) Start(addr string) error { + if err := s.app.Listen(addr); err != nil { + s.Logger.Error("Failed to start server", zap.Error(err)) + return err + } + return nil +} + +func (s *Server) Shutdown(ctx context.Context) error { + return s.app.Shutdown() +} + +func (s *Server) registerRoutes() { + for _, c := range s.Controllers { + router := s.app.Group(c.Name()) + c.Register(router) + } +} + +type Controller interface { + Register(router fiber.Router) + Name() string +} + +func (s *Server) ListRoutes() { + fmt.Println("Registered routes:") + for _, stack := range s.app.Stack() { + for _, route := range stack { + fmt.Printf("%s %s\n", route.Method, route.Path) } } - return srv -} - -// Start - запускает http сервер. -func (srv *HTTP) Start() error { - return srv.fiber.Listen(srv.cfg.HttpAddress) -} - -// Stop - останавливает http сервер. -func (srv *HTTP) Stop() error { - return srv.fiber.Shutdown() } diff --git a/internal/server/middleware.go b/internal/server/middleware.go index 6eef99e..69a5191 100644 --- a/internal/server/middleware.go +++ b/internal/server/middleware.go @@ -1,6 +1,7 @@ package server import ( + "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" "strings" "github.com/gofiber/fiber/v2" @@ -20,7 +21,7 @@ func LocalJwt() fiber.Handler { func Jwt() fiber.Handler { return func(c *fiber.Ctx) error { // check LocalJwt - if c.Locals("userID") != nil { + if c.Locals(models.UserCtxKey) != nil { return c.Next() } @@ -38,8 +39,8 @@ func Jwt() fiber.Handler { return fiber.NewError(fiber.StatusUnauthorized, "empty user") } - c.Locals("userID", jwt.GetUserID()) - c.Locals("token", c.Get(jwt_adapter.DefaultHeaderKey)) + c.Locals(models.UserCtxKey, jwt.GetUserID()) + c.Locals(models.TokenCtxKey, c.Get(jwt_adapter.DefaultHeaderKey)) return c.Next() } } diff --git a/internal/controllers/controller.go b/pkg/validate_controllers/controller.go similarity index 92% rename from internal/controllers/controller.go rename to pkg/validate_controllers/controller.go index fb38106..04c3a8d 100644 --- a/internal/controllers/controller.go +++ b/pkg/validate_controllers/controller.go @@ -1,4 +1,4 @@ -package controllers +package validate_controllers import ( "reflect" @@ -18,7 +18,7 @@ type Route struct { } // validateStruct - возвращает строку с ошибкой, если структура не прошла валидацию. -func validateStruct(s any) []*models.RespErrorValidate { +func ValidateStruct(s any) []*models.RespErrorValidate { err := validate.Struct(s) var errorsValidate []*models.RespErrorValidate diff --git a/test.env b/test.env new file mode 100644 index 0000000..6a89eaf --- /dev/null +++ b/test.env @@ -0,0 +1,20 @@ +TELEGRAM_TOKEN=6712573453:AAFbioUuXf0Te73MUCqa0_h09qEQ1iQREas +TELEGRAM_CHANNEL_ID=542073142 +HTTP_ADDRESS_USER=0.0.0.0:8080 +HTTP_ADDRESS_ADMIN=0.0.0.0:8081 +MONGO_HOST=localhost +MONGO_PORT=27020 +MONGO_USER=test +MONGO_PASSWORD=test +MONGO_AUTH=admin +MONGO_DATABASE_NAME=admin +S3_ENDPOINT=localhost:9005 +S3_ACCESS_KEY_ID=admin +S3_SECRET_KEY=admin123 +CUSTOMER_SVC_ADDRESS=localhost:9003 +STAGING_URL=https://sadmin.pena +S3_FOLDER=videodata +S3_FILE_URL=http://localhost:9005/videodata +CUSTOMER_RPC_HOST=localhost:9003 +TRASH_LOG_HOST=localhost:7113 +MODULE_LOGGER=verify-local diff --git a/tests/e2e/create_verify_user_test.go b/tests/e2e/create_verify_user_test.go new file mode 100644 index 0000000..06b705b --- /dev/null +++ b/tests/e2e/create_verify_user_test.go @@ -0,0 +1,61 @@ +package e2e + +import ( + "bytes" + "fmt" + "github.com/gofiber/fiber/v2" + "github.com/stretchr/testify/assert" + "io" + "mime/multipart" + "os" + "penahub.gitlab.yandexcloud.net/backend/verification/tests/helpers" + "testing" +) + +func Test_SetVerify(t *testing.T) { + url := "http://localhost:8080/verification" + client := fiber.AcquireClient() + + token, err := helpers.CreateJwt("64e53ed187392e122e5d3d50") + assert.NoError(t, err) + + fmt.Println(token) + + assert.NoError(t, err) + + var requestBody bytes.Buffer + writer := multipart.NewWriter(&requestBody) + err = writer.WriteField("status", "nko") + assert.NoError(t, err) + files := []struct { + fieldName string + filePath string + }{ + {"inn", "files/inn"}, + {"rule", "files/rule"}, + {"egrule", "files/egrule"}, + {"certificate", "files/certificate"}, + } + for _, file := range files { + fileWriter, err := writer.CreateFormFile(file.fieldName, file.filePath) + assert.NoError(t, err) + + f, err := os.Open(file.filePath) + assert.NoError(t, err) + defer f.Close() + _, err = io.Copy(fileWriter, f) + assert.NoError(t, err) + } + + writer.Close() + + agent := client.Post(url).Body(requestBody.Bytes()).ContentType(writer.FormDataContentType()) + agent.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + statusCode, respBody, errs := agent.Bytes() + if len(errs) > 0 { + assert.NoError(t, errs[0]) + } + assert.Equal(t, 200, statusCode) + + fmt.Println(string(respBody)) +} diff --git a/tests/e2e/files/certificate b/tests/e2e/files/certificate new file mode 100644 index 0000000..a6de0f8 --- /dev/null +++ b/tests/e2e/files/certificate @@ -0,0 +1 @@ +аываывавыфавыавыфаываываываывпыпыфывиываолиыврмиыврмиывимролыиф \ No newline at end of file diff --git a/tests/e2e/files/egrule b/tests/e2e/files/egrule new file mode 100644 index 0000000..a6de0f8 --- /dev/null +++ b/tests/e2e/files/egrule @@ -0,0 +1 @@ +аываывавыфавыавыфаываываываывпыпыфывиываолиыврмиыврмиывимролыиф \ No newline at end of file diff --git a/tests/e2e/files/inn b/tests/e2e/files/inn new file mode 100644 index 0000000..a6de0f8 --- /dev/null +++ b/tests/e2e/files/inn @@ -0,0 +1 @@ +аываывавыфавыавыфаываываываывпыпыфывиываолиыврмиыврмиывимролыиф \ No newline at end of file diff --git a/tests/e2e/files/rule b/tests/e2e/files/rule new file mode 100644 index 0000000..a6de0f8 --- /dev/null +++ b/tests/e2e/files/rule @@ -0,0 +1 @@ +аываывавыфавыавыфаываываываывпыпыфывиываолиыврмиыврмиывимролыиф \ No newline at end of file diff --git a/tests/e2e/get_verify_admin_test.go b/tests/e2e/get_verify_admin_test.go new file mode 100644 index 0000000..4e3eca8 --- /dev/null +++ b/tests/e2e/get_verify_admin_test.go @@ -0,0 +1,57 @@ +package e2e + +import ( + "encoding/json" + "fmt" + "github.com/gofiber/fiber/v2" + "github.com/stretchr/testify/assert" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" + "penahub.gitlab.yandexcloud.net/backend/verification/tests/helpers" + "testing" +) + +func Test_GetVerifyAdmin(t *testing.T) { + url := "http://localhost:8081/verification/64e53ed187392e122e5d3d50" + client := fiber.AcquireClient() + + token, err := helpers.CreateJwt("64e53ed187392e122e5d3d51") + assert.NoError(t, err) + + agent := client.Get(url) + agent.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + + statusCode, respBody, errs := agent.Bytes() + if len(errs) > 0 { + assert.NoError(t, errs[0]) + } + assert.Equal(t, 200, statusCode) + + var resp models.Verification + err = json.Unmarshal(respBody, &resp) + assert.NoError(t, err) + fmt.Println(resp) + + url = "http://localhost:8081/verification" + client2 := fiber.AcquireClient() + + req := models.ReqSetVerification{ + ID: resp.ID, + Status: "nko", + Comment: "MOLODEC, GOOD JOB", + Accepted: true, + TaxNumber: "000-000-000", + } + + reqBody, err := json.Marshal(req) + assert.NoError(t, err) + + agent2 := client2.Patch(url).Body(reqBody).ContentType("application/json") + agent2.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + + statusCode, _, errs = agent2.Bytes() + if len(errs) > 0 { + fmt.Println(errs[0]) + assert.NoError(t, errs[0]) + } + assert.Equal(t, 200, statusCode) +} diff --git a/tests/e2e/get_verify_user_test.go b/tests/e2e/get_verify_user_test.go new file mode 100644 index 0000000..6c81abc --- /dev/null +++ b/tests/e2e/get_verify_user_test.go @@ -0,0 +1,33 @@ +package e2e + +import ( + "encoding/json" + "fmt" + "github.com/gofiber/fiber/v2" + "github.com/stretchr/testify/assert" + "penahub.gitlab.yandexcloud.net/backend/verification/internal/models" + "penahub.gitlab.yandexcloud.net/backend/verification/tests/helpers" + "testing" +) + +func Test_Get_Verify_User(t *testing.T) { + url := "http://localhost:8080/verification" + client := fiber.AcquireClient() + + token, err := helpers.CreateJwt("64e53ed187392e122e5d3d50") + assert.NoError(t, err) + + agent := client.Get(url) + agent.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + + statusCode, respBody, errs := agent.Bytes() + if len(errs) > 0 { + assert.NoError(t, errs[0]) + } + assert.Equal(t, 200, statusCode) + + var resp models.Verification + err = json.Unmarshal(respBody, &resp) + assert.NoError(t, err) + fmt.Println(resp) +} diff --git a/tests/e2e/set_verify_file_user_test.go b/tests/e2e/set_verify_file_user_test.go new file mode 100644 index 0000000..d296fde --- /dev/null +++ b/tests/e2e/set_verify_file_user_test.go @@ -0,0 +1,60 @@ +package e2e + +import ( + "bytes" + "fmt" + "github.com/gofiber/fiber/v2" + "github.com/stretchr/testify/assert" + "io" + "mime/multipart" + "os" + "penahub.gitlab.yandexcloud.net/backend/verification/tests/helpers" + "testing" +) + +func Test_PutFile(t *testing.T) { + url := "http://localhost:8080/verification" + client := fiber.AcquireClient() + + token, err := helpers.CreateJwt("64e53ed187392e122e5d3d51") + assert.NoError(t, err) + + fmt.Println(token) + + assert.NoError(t, err) + + var requestBody bytes.Buffer + writer := multipart.NewWriter(&requestBody) + + files := []struct { + fieldName string + filePath string + }{ + {"inn", "files/inn"}, + {"rule", "files/rule"}, + {"egrule", "files/egrule"}, + {"certificate", "files/certificate"}, + } + for _, file := range files { + fileWriter, err := writer.CreateFormFile(file.fieldName, file.filePath) + assert.NoError(t, err) + + f, err := os.Open(file.filePath) + assert.NoError(t, err) + defer f.Close() + _, err = io.Copy(fileWriter, f) + assert.NoError(t, err) + } + + writer.Close() + + agent := client.Put(url).Body(requestBody.Bytes()).ContentType(writer.FormDataContentType()) + agent.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + statusCode, respBody, errs := agent.Bytes() + if len(errs) > 0 { + assert.NoError(t, errs[0]) + } + assert.Equal(t, 200, statusCode) + + fmt.Println(string(respBody)) +} diff --git a/tests/helpers/jwt.go b/tests/helpers/jwt.go new file mode 100644 index 0000000..2bcb00a --- /dev/null +++ b/tests/helpers/jwt.go @@ -0,0 +1,43 @@ +package helpers + +import ( + "github.com/dgrijalva/jwt-go" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/jwt_adapter" + "strings" + "time" +) + +func CreateJwt(userID string) (string, error) { + var publicKey = strings.Replace(`-----BEGIN PUBLIC KEY----- + MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgHgnvr7O2tiApjJfid1orFnIGm69 + 80fZp+Lpbjo+NC/0whMFga2Biw5b1G2Q/B2u0tpO1Fs/E8z7Lv1nYfr5jx2S8x6B + dA4TS2kB9Kf0wn0+7wSlyikHoKhbtzwXHZl17GsyEi6wHnsqNBSauyIWhpha8i+Y + +3GyaOY536H47qyXAgMBAAE= + -----END PUBLIC KEY-----`, "\t", "", -1) + + var privateKey = strings.Replace(`-----BEGIN RSA PRIVATE KEY----- + MIICWwIBAAKBgHgnvr7O2tiApjJfid1orFnIGm6980fZp+Lpbjo+NC/0whMFga2B + iw5b1G2Q/B2u0tpO1Fs/E8z7Lv1nYfr5jx2S8x6BdA4TS2kB9Kf0wn0+7wSlyikH + oKhbtzwXHZl17GsyEi6wHnsqNBSauyIWhpha8i+Y+3GyaOY536H47qyXAgMBAAEC + gYAOphnVPXbk6lpYzdkLC1Xn5EOEuNfOLLURLxBnPWozZo26r/Mtahu/9mYhrYlv + PP8r6mxta3VIil8iOdZyOLa/4d1LPd+UehgEXIJEiYXLtn7RS5eUnoPuQxssfs1k + OWjdN8p6SzppleegFTvGRX4KM3cDLfSphOk8JuBCrpSSYQJBAOdqizTSrdKMTuVe + c7Jk1JOJkyFuFs+N5zeryyeFGH7IpRdWy0rkWMxIUAi8Ap1vYVBPHv4tDOo3sy5X + VLc/knkCQQCE62pg+0TmsrhO/2Pgog6MLBkzlzXYMRp/01HbmznwYF+ejfPnzLkz + hnUlxRUNK3lhXM/7H6oAjvqF2R72u/OPAkEAterkmdbQfEZ+MwNoEiH/lie9OLdx + SSI1VGdBYcTYN7qFRW6eizYstBJYkDU0HQ0Uw+we4hMKJwk4W0KdvxxDiQJAeqlB + V1QqBneBbK10PzVuFV8QtrJhJyxRVwrtbKq38iMNuqUnI4+ijXEUpJFWVvv6nKXo + 7McQvEk12dU/JNTX8wJAOlAtSNjp9tVwpMpC0w2St1eKc1L2SknjeohA5ldoBz8sGeZsPhTU3eHSD1neAZXLKN5K68z3zFBr20ubY9nyLw== + -----END RSA PRIVATE KEY-----`, "\t", "", -1) + + token, err := jwt_adapter.Create(userID, jwt_adapter.ForCreate{ + PrivateKey: []byte(privateKey), + PublicKey: []byte(publicKey), + Audience: "pena", + Issuer: "pena-auth-service", + Algorithm: jwt.SigningMethodRS256, + ExpiresIn: 15 * time.Minute, + }) + + return token, err +}