generated from PenaSide/GolangTemplate
update cfg after codeconv
This commit is contained in:
parent
3640fdd415
commit
2dea2c21b9
@ -28,17 +28,17 @@ func main() {
|
||||
}
|
||||
|
||||
urls := []string{
|
||||
config.AuthServiceURL,
|
||||
config.HubadminServiceURL,
|
||||
config.CurrencyServiceURL,
|
||||
config.DiscountServiceGRPCURL,
|
||||
config.CodewordServiceGRPCURL,
|
||||
config.PaymentServiceGRPCURL,
|
||||
config.VerificationServiceURL,
|
||||
config.TemplategenServiceURL,
|
||||
config.AuthMicroserviceURL,
|
||||
config.HubadminMicroserviceURL,
|
||||
config.CurrencyMicroserviceURL,
|
||||
config.DiscountMicroserviceGRPC,
|
||||
config.CodewordMicroserviceGRPC,
|
||||
config.PaymentMicroserviceGRPC,
|
||||
config.VerificationMicroservice,
|
||||
config.TemplategenMicroserviceURL,
|
||||
config.TrashLogHost,
|
||||
config.AdminURL,
|
||||
config.ExternalCfg.MailClientCfg.ApiUrl,
|
||||
config.ExternalCfg.MailClientCfg.ApiURL,
|
||||
}
|
||||
if err = validateURLs(urls); err != nil {
|
||||
log.Fatalf("error validating urls: %v", err)
|
||||
@ -72,16 +72,16 @@ func loadConfig() (*models.Config, error) {
|
||||
config := models.Config{
|
||||
ExternalCfg: models.ExternalCfg{
|
||||
JwtCfg: models.JWTConfiguration{
|
||||
JwtPublicKey: os.Getenv("JWT_PUBLIC_KEY"),
|
||||
JwtAudience: os.Getenv("JWT_AUDIENCE"),
|
||||
JwtIssuer: os.Getenv("JWT_ISSUER"),
|
||||
PublicKey: os.Getenv("JWT_PUBLIC_KEY"),
|
||||
Audience: os.Getenv("JWT_AUDIENCE"),
|
||||
Issuer: os.Getenv("JWT_ISSUER"),
|
||||
},
|
||||
Database: mongo.Configuration{
|
||||
URL: os.Getenv("MONGO_URL"),
|
||||
DatabaseName: os.Getenv("MONGO_DB_NAME"),
|
||||
},
|
||||
MailClientCfg: models.MailClientCfg{
|
||||
ApiUrl: os.Getenv("API_URL"),
|
||||
ApiURL: os.Getenv("API_URL"),
|
||||
Sender: os.Getenv("MAIL_SENDER"),
|
||||
ApiKey: os.Getenv("MAIL_API_KEY"),
|
||||
MailAddress: os.Getenv("MAIL_ADDRESS"),
|
||||
@ -97,18 +97,18 @@ func loadConfig() (*models.Config, error) {
|
||||
GrpcDomain: os.Getenv("GRPC_DOMAIN"),
|
||||
KafkaBrokers: strings.Split(os.Getenv("KAFKA_BROKERS"), ","),
|
||||
KafkaTopicTariff: os.Getenv("KAFKA_TOPIC_TARIFF"),
|
||||
AuthServiceURL: os.Getenv("AUTH_SERVICE_URL"),
|
||||
HubadminServiceURL: os.Getenv("HUBADMIN_SERVICE_URL"),
|
||||
CurrencyServiceURL: os.Getenv("CURRENCY_SERVICE_URL"),
|
||||
DiscountServiceGRPCURL: os.Getenv("DISCOUNT_SERVICE_GRPC_URL"),
|
||||
PaymentServiceGRPCURL: os.Getenv("PAYMENT_SERVICE_GRPC_URL"),
|
||||
VerificationServiceURL: os.Getenv("VERIFICATION_SERVICE_URL"),
|
||||
TemplategenServiceURL: os.Getenv("TEMPLATEGEN_SERVICE_URL"),
|
||||
CodewordServiceGRPCURL: os.Getenv("CODEWORD_SERVICE_GRPC_URL"),
|
||||
AuthMicroserviceURL: os.Getenv("AUTH_MICROSERVICE_URL"),
|
||||
HubadminMicroserviceURL: os.Getenv("HUBADMIN_MICROSERVICE_URL"),
|
||||
CurrencyMicroserviceURL: os.Getenv("CURRENCY_MICROSERVICE_URL"),
|
||||
DiscountMicroserviceGRPC: os.Getenv("DISCOUNT_MICROSERVICE_GRPC_URL"),
|
||||
PaymentMicroserviceGRPC: os.Getenv("PAYMENT_MICROSERVICE_GRPC_URL"),
|
||||
VerificationMicroservice: os.Getenv("VERIFICATION_MICROSERVICE_URL"),
|
||||
TemplategenMicroserviceURL: os.Getenv("TEMPLATEGEN_MICROSERVICE_URL"),
|
||||
CodewordMicroserviceGRPC: os.Getenv("CODEWORD_MICROSERVICE_GRPC_URL"),
|
||||
TrashLogHost: os.Getenv("TRASH_LOG_HOST"),
|
||||
NotificationBotToken: os.Getenv("NOTIFICATION_BOT_TOKEN"),
|
||||
NotificationRsPayChannel: envToInt64(os.Getenv("NOTIFICATION_RS_PAY_CHANNEL")),
|
||||
NotificationChannel: envToInt64(os.Getenv("NOTIFICATION_CHANNEL")),
|
||||
NotificationBotToken: os.Getenv("TELEGRAM_TOKEN"),
|
||||
NotificationRsPayChannel: envToInt64(os.Getenv("TELEGRAM_RS_PAY_CHANNEL_ID")),
|
||||
NotificationChannel: envToInt64(os.Getenv("TELEGRAM_NOTIFICATION_CHANNEL_ID")),
|
||||
AdminURL: os.Getenv("ADMIN_FRONT_URL"),
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ func validateMail(cfg models.MailClientCfg) error {
|
||||
return fmt.Errorf("mail address is empty")
|
||||
}
|
||||
|
||||
if cfg.ApiUrl == "" {
|
||||
if cfg.ApiURL == "" {
|
||||
return fmt.Errorf("mail api url is empty")
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ func TestValidateTG(t *testing.T) {
|
||||
|
||||
func TestValidateMail(t *testing.T) {
|
||||
err := validateMail(models.MailClientCfg{
|
||||
ApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
||||
ApiURL: "https://api.smtp.bz/v1/smtp/send",
|
||||
Sender: "noreply@mailing.pena.digital",
|
||||
ApiKey: "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev",
|
||||
MailAddress: "sells@pena.digital",
|
||||
@ -97,22 +97,22 @@ func TestLoadConfig(t *testing.T) {
|
||||
"MONGO_DB_NAME": "admin",
|
||||
"KAFKA_BROKERS": "localhost:9092",
|
||||
"KAFKA_TOPIC_TARIFF": "test-topic",
|
||||
"AUTH_SERVICE_URL": "http://localhost:8000/user",
|
||||
"HUBADMIN_SERVICE_URL": "http://localhost:8001/tariff",
|
||||
"CURRENCY_SERVICE_URL": "http://cbrfworker-service:8000/change",
|
||||
"DISCOUNT_SERVICE_GRPC_URL": "localhost:9040",
|
||||
"PAYMENT_SERVICE_GRPC_URL": "treasurer-service:9085",
|
||||
"VERIFICATION_SERVICE_URL": "http://10.8.0.8:7035/verification",
|
||||
"TEMPLATEGEN_SERVICE_URL": "10.6.0.17",
|
||||
"CODEWORD_SERVICE_GRPC_URL": "http://localhost:8000/user",
|
||||
"AUTH_MICROSERVICE_URL": "http://localhost:8000/user",
|
||||
"HUBADMIN_MICROSERVICE_URL": "http://localhost:8001/tariff",
|
||||
"CURRENCY_MICROSERVICE_URL": "http://cbrfworker-service:8000/change",
|
||||
"DISCOUNT_MICROSERVICE_GRPC_URL": "localhost:9040",
|
||||
"PAYMENT_MICROSERVICE_GRPC_URL": "treasurer-service:9085",
|
||||
"VERIFICATION_MICROSERVICE_URL": "http://10.8.0.8:7035/verification",
|
||||
"TEMPLATEGEN_MICROSERVICE_URL": "10.6.0.17",
|
||||
"CODEWORD_MICROSERVICE_GRPC_URL": "http://localhost:8000/user",
|
||||
"TRASH_LOG_HOST": "localhost:7113",
|
||||
"API_URL": "https://api.smtp.bz/v1/smtp/send",
|
||||
"MAIL_SENDER": "noreply@mailing.pena.digital",
|
||||
"MAIL_API_KEY": "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev",
|
||||
"MAIL_ADDRESS": "mail@mail.com",
|
||||
"NOTIFICATION_BOT_TOKEN": "7127966184:AAG1steOCH4wDvHRe9QcsXJPS4dWRyRYsqg",
|
||||
"NOTIFICATION_CHANNEL": "-1002177203276",
|
||||
"NOTIFICATION_RS_PAY_CHANNEL": "-1002177203276",
|
||||
"TELEGRAM_TOKEN": "7127966184:AAG1steOCH4wDvHRe9QcsXJPS4dWRyRYsqg",
|
||||
"TELEGRAM_NOTIFICATION_CHANNEL_ID": "-1002177203276",
|
||||
"TELEGRAM_RS_PAY_CHANNEL_ID": "-1002177203276",
|
||||
"ADMIN_FRONT_URL": "https://admin-front.ru",
|
||||
}
|
||||
|
||||
@ -135,17 +135,17 @@ func TestLoadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
urls := []string{
|
||||
cfg.AuthServiceURL,
|
||||
cfg.HubadminServiceURL,
|
||||
cfg.CurrencyServiceURL,
|
||||
cfg.DiscountServiceGRPCURL,
|
||||
cfg.CodewordServiceGRPCURL,
|
||||
cfg.PaymentServiceGRPCURL,
|
||||
cfg.VerificationServiceURL,
|
||||
cfg.TemplategenServiceURL,
|
||||
cfg.AuthMicroserviceURL,
|
||||
cfg.HubadminMicroserviceURL,
|
||||
cfg.CurrencyMicroserviceURL,
|
||||
cfg.DiscountMicroserviceGRPC,
|
||||
cfg.CodewordMicroserviceGRPC,
|
||||
cfg.PaymentMicroserviceGRPC,
|
||||
cfg.VerificationMicroservice,
|
||||
cfg.TemplategenMicroserviceURL,
|
||||
cfg.TrashLogHost,
|
||||
cfg.AdminURL,
|
||||
cfg.ExternalCfg.MailClientCfg.ApiUrl,
|
||||
cfg.ExternalCfg.MailClientCfg.ApiURL,
|
||||
}
|
||||
if err = validateURLs(urls); err != nil {
|
||||
assert.NoError(t, err)
|
||||
|
@ -22,20 +22,20 @@ services:
|
||||
- MONGO_URL = TODO
|
||||
- MONGO_DB_NAME=customer
|
||||
# - MONGO_AUTH=customer
|
||||
- NOTIFICATION_RS_PAY_CHANNEL=-1002338593104
|
||||
- TELEGRAM_RS_PAY_CHANNEL_ID=-1002338593104
|
||||
|
||||
- KAFKA_BROKERS=10.8.0.6:9092
|
||||
- KAFKA_TOPIC_TARIFF=tariffs
|
||||
|
||||
- AUTH_SERVICE_URL=http://10.8.0.6:59300
|
||||
- HUBADMIN_SERVICE_URL=http://10.8.0.6:59303
|
||||
- CURRENCY_SERVICE_URL=http://10.8.0.6:3131
|
||||
- DISCOUNT_SERVICE_GRPC_URL=10.8.0.6:9001
|
||||
- PAYMENT_SERVICE_GRPC_URL=10.8.0.6:9085
|
||||
- VERIFICATION_SERVICE_URL=http://10.8.0.6:7036
|
||||
- TEMPLATEGEN_SERVICE_URL=http://10.6.0.17
|
||||
- AUTH_MICROSERVICE_URL=http://10.8.0.6:59300
|
||||
- HUBADMIN_MICROSERVICE_URL=http://10.8.0.6:59303
|
||||
- CURRENCY_MICROSERVICE_URL=http://10.8.0.6:3131
|
||||
- DISCOUNT_MICROSERVICE_GRPC_URL=10.8.0.6:9001
|
||||
- PAYMENT_MICROSERVICE_GRPC_URL=10.8.0.6:9085
|
||||
- VERIFICATION_MICROSERVICE_URL=http://10.8.0.6:7036
|
||||
- TEMPLATEGEN_MICROSERVICE_URL=http://10.6.0.17
|
||||
- API_URL=https://api.smtp.bz/v1/smtp/send
|
||||
- CODEWORD_SERVICE_GRPC_URL=10.8.0.6:59665
|
||||
- CODEWORD_MICROSERVICE_GRPC_URL=10.8.0.6:59665
|
||||
- MAIL_SENDER=noreply@mailing.pena.digital
|
||||
- MAIL_API_KEY=P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev
|
||||
- MAIL_ADDRESS=sells@pena.digital
|
||||
@ -47,7 +47,7 @@ services:
|
||||
- ENCRYPT_PRIVATE_KEY=$USER_PRIVATEKEY
|
||||
- ADMIN_FRONT_URL=https://sadmin.pena
|
||||
- TRASH_LOG_HOST=10.8.0.15:7113
|
||||
- NOTIFICATION_BOT_TOKEN=6112841016:AAH2nO1c6mqfMewBvHwdXCDp5PCclOuc99s
|
||||
- TELEGRAM_TOKEN=6112841016:AAH2nO1c6mqfMewBvHwdXCDp5PCclOuc99s
|
||||
ports:
|
||||
- 10.8.0.6:8067:8065
|
||||
- 10.8.0.6:8070:8066
|
||||
|
@ -117,15 +117,15 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
||||
|
||||
clients := initialize.NewClients(initialize.ClientsDeps{
|
||||
Logger: logger,
|
||||
AuthURL: config.AuthServiceURL,
|
||||
HubadminURL: config.HubadminServiceURL,
|
||||
CurrencyURL: config.CurrencyServiceURL,
|
||||
DiscountServiceURL: config.DiscountServiceGRPCURL,
|
||||
PaymentServiceURL: config.PaymentServiceGRPCURL,
|
||||
VerificationURL: config.VerificationServiceURL,
|
||||
TemplategenURL: config.TemplategenServiceURL,
|
||||
AuthURL: config.AuthMicroserviceURL,
|
||||
HubadminURL: config.HubadminMicroserviceURL,
|
||||
CurrencyURL: config.CurrencyMicroserviceURL,
|
||||
DiscountServiceURL: config.DiscountMicroserviceGRPC,
|
||||
PaymentServiceURL: config.PaymentMicroserviceGRPC,
|
||||
VerificationURL: config.VerificationMicroservice,
|
||||
TemplategenURL: config.TemplategenMicroserviceURL,
|
||||
MailClient: config.ExternalCfg.MailClientCfg,
|
||||
CodewordServiceHost: config.CodewordServiceGRPCURL,
|
||||
CodewordServiceHost: config.CodewordMicroserviceGRPC,
|
||||
Notifier: notificationBot,
|
||||
NotificationRsPayChannel: config.NotificationRsPayChannel,
|
||||
})
|
||||
|
@ -59,21 +59,21 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
||||
AdminHttpURL: "localhost:8081",
|
||||
GrpcURL: "localhost:8081",
|
||||
GrpcDomain: "domain",
|
||||
AuthServiceURL: defaultAuthURL,
|
||||
AuthMicroserviceURL: defaultAuthURL,
|
||||
KafkaTopicTariff: "topic",
|
||||
KafkaBrokers: []string{"localhost:8080", "localhost:8081"},
|
||||
HubadminServiceURL: defaultHubAdminURL,
|
||||
CurrencyServiceURL: defaultCurrencyURL,
|
||||
DiscountServiceGRPCURL: "domen",
|
||||
PaymentServiceGRPCURL: "domen",
|
||||
VerificationServiceURL: "domen",
|
||||
TemplategenServiceURL: "domen",
|
||||
HubadminMicroserviceURL: defaultHubAdminURL,
|
||||
CurrencyMicroserviceURL: defaultCurrencyURL,
|
||||
DiscountMicroserviceGRPC: "domen",
|
||||
PaymentMicroserviceGRPC: "domen",
|
||||
VerificationMicroservice: "domen",
|
||||
TemplategenMicroserviceURL: "domen",
|
||||
ExternalCfg: models.ExternalCfg{
|
||||
JwtCfg: models.JWTConfiguration{
|
||||
JwtPrivateKey: "jwt private key",
|
||||
JwtPublicKey: "jwt public key",
|
||||
JwtIssuer: "issuer",
|
||||
JwtAudience: "audience",
|
||||
PrivateKey: "jwt private key",
|
||||
PublicKey: "jwt public key",
|
||||
Issuer: "issuer",
|
||||
Audience: "audience",
|
||||
Algorithm: *jwt.SigningMethodRS256,
|
||||
ExpiresIn: 15 * time.Minute,
|
||||
},
|
||||
@ -87,21 +87,21 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
||||
t.Setenv("GRPC_URL", defaultConfiguration.GrpcURL)
|
||||
t.Setenv("GRPC_DOMAIN", defaultConfiguration.GrpcDomain)
|
||||
|
||||
t.Setenv("JWT_PUBLIC_KEY", defaultConfiguration.ExternalCfg.JwtCfg.JwtPublicKey)
|
||||
t.Setenv("JWT_PRIVATE_KEY", defaultConfiguration.ExternalCfg.JwtCfg.JwtPrivateKey)
|
||||
t.Setenv("JWT_ISSUER", defaultConfiguration.ExternalCfg.JwtCfg.JwtIssuer)
|
||||
t.Setenv("JWT_AUDIENCE", defaultConfiguration.ExternalCfg.JwtCfg.JwtAudience)
|
||||
t.Setenv("JWT_PUBLIC_KEY", defaultConfiguration.ExternalCfg.JwtCfg.PublicKey)
|
||||
t.Setenv("JWT_PRIVATE_KEY", defaultConfiguration.ExternalCfg.JwtCfg.PrivateKey)
|
||||
t.Setenv("JWT_ISSUER", defaultConfiguration.ExternalCfg.JwtCfg.Issuer)
|
||||
t.Setenv("JWT_AUDIENCE", defaultConfiguration.ExternalCfg.JwtCfg.Audience)
|
||||
|
||||
t.Setenv("KAFKA_BROKERS", "localhost:8080,localhost:8081")
|
||||
t.Setenv("KAFKA_TOPIC_TARIFF", defaultConfiguration.KafkaTopicTariff)
|
||||
|
||||
t.Setenv("AUTH_SERVICE_URL", defaultConfiguration.AuthServiceURL)
|
||||
t.Setenv("HUBADMIN_SERVICE_URL", defaultConfiguration.HubadminServiceURL)
|
||||
t.Setenv("CURRENCY_SERVICE_URL", defaultConfiguration.CurrencyServiceURL)
|
||||
t.Setenv("DISCOUNT_SERVICE_GRPC_URL", defaultConfiguration.DiscountServiceGRPCURL)
|
||||
t.Setenv("PAYMENT_SERVICE_GRPC_URL", defaultConfiguration.PaymentServiceGRPCURL)
|
||||
t.Setenv("VERIFICATION_SERVICE_URL", defaultConfiguration.VerificationServiceURL)
|
||||
t.Setenv("TEMPLATEGEN_SERVICE_URL", defaultConfiguration.TemplategenServiceURL)
|
||||
t.Setenv("AUTH_MICROSERVICE_URL", defaultConfiguration.AuthMicroserviceURL)
|
||||
t.Setenv("HUBADMIN_MICROSERVICE_URL", defaultConfiguration.HubadminMicroserviceURL)
|
||||
t.Setenv("CURRENCY_MICROSERVICE_URL", defaultConfiguration.CurrencyMicroserviceURL)
|
||||
t.Setenv("DISCOUNT_MICROSERVICE_GRPC_URL", defaultConfiguration.DiscountMicroserviceGRPC)
|
||||
t.Setenv("PAYMENT_MICROSERVICE_GRPC_URL", defaultConfiguration.PaymentMicroserviceGRPC)
|
||||
t.Setenv("VERIFICATION_MICROSERVICE_URL", defaultConfiguration.VerificationMicroservice)
|
||||
t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.TemplategenMicroserviceURL)
|
||||
|
||||
t.Setenv("MONGO_URL", defaultConfiguration.ExternalCfg.Database.URL)
|
||||
t.Setenv("MONGO_DB_NAME", defaultConfiguration.ExternalCfg.Database.DatabaseName)
|
||||
|
@ -24,7 +24,7 @@ func NewMailClient(deps models.MailClientCfg, logger *zap.Logger) *MailClient {
|
||||
deps.FiberClient = fiber.AcquireClient()
|
||||
}
|
||||
return &MailClient{
|
||||
apiUrl: deps.ApiUrl,
|
||||
apiUrl: deps.ApiURL,
|
||||
sender: deps.Sender,
|
||||
apiKey: deps.ApiKey,
|
||||
fiberClient: deps.FiberClient,
|
||||
|
@ -13,21 +13,21 @@ type Config struct {
|
||||
AdminHttpURL string `env:"ADMIN_HTTP_URL,default=localhost:8081"`
|
||||
GrpcURL string `env:"GRPC_URL,default=localhost:8081"`
|
||||
GrpcDomain string `env:"GRPC_DOMAIN,default=https://domen.ru"`
|
||||
AuthServiceURL string `env:"AUTH_SERVICE_URL,required"` // http://10.8.0.6:59300/user
|
||||
HubadminServiceURL string `env:"HUBADMIN_SERVICE_URL,required"` // http://10.8.0.6:59303/tariff
|
||||
CurrencyServiceURL string `env:"CURRENCY_SERVICE_URL,required"` // http://10.8.0.6:3131/change
|
||||
DiscountServiceGRPCURL string `env:"DISCOUNT_SERVICE_GRPC_URL,required"`
|
||||
CodewordServiceGRPCURL string `env:"CODEWORD_SERVICE_GRPC_URL,required"`
|
||||
PaymentServiceGRPCURL string `env:"PAYMENT_SERVICE_GRPC_URL,required"`
|
||||
VerificationServiceURL string `env:"VERIFICATION_SERVICE_URL,required"` // http://10.8.0.6:7036/verification
|
||||
TemplategenServiceURL string `env:"TEMPLATEGEN_SERVICE_URL,required"` // http://10.6.0.17/generator/service
|
||||
AuthMicroserviceURL string `env:"AUTH_MICROSERVICE_URL,required"` // http://10.8.0.6:59300/user
|
||||
HubadminMicroserviceURL string `env:"HUBADMIN_MICROSERVICE_URL,required"` // http://10.8.0.6:59303/tariff
|
||||
CurrencyMicroserviceURL string `env:"CURRENCY_MICROSERVICE_URL,required"` // http://10.8.0.6:3131/change
|
||||
DiscountMicroserviceGRPC string `env:"DISCOUNT_MICROSERVICE_GRPC_URL,required"`
|
||||
CodewordMicroserviceGRPC string `env:"CODEWORD_MICROSERVICE_GRPC_URL,required"`
|
||||
PaymentMicroserviceGRPC string `env:"PAYMENT_MICROSERVICE_GRPC_URL,required"`
|
||||
VerificationMicroservice string `env:"VERIFICATION_MICROSERVICE_URL,required"` // http://10.8.0.6:7036/verification
|
||||
TemplategenMicroserviceURL string `env:"TEMPLATEGEN_MICROSERVICE_URL,required"` // http://10.6.0.17/generator/service
|
||||
KafkaTopicTariff string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
|
||||
KafkaBrokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
||||
TrashLogHost string `env:"TRASH_LOG_HOST"`
|
||||
NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"`
|
||||
NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"`
|
||||
NotificationBotToken string `env:"TELEGRAM_TOKEN"`
|
||||
NotificationChannel int64 `env:"TELEGRAM_NOTIFICATION_CHANNEL_ID"`
|
||||
AdminURL string `env:"ADMIN_FRONT_URL"`
|
||||
NotificationRsPayChannel int64 `env:"NOTIFICATION_RS_PAY_CHANNEL"`
|
||||
NotificationRsPayChannel int64 `env:"TELEGRAM_RS_PAY_CHANNEL_ID"`
|
||||
ExternalCfg ExternalCfg
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ type ExternalCfg struct {
|
||||
}
|
||||
|
||||
type MailClientCfg struct {
|
||||
ApiUrl string `env:"API_URL,required"`
|
||||
ApiURL string `env:"API_URL,required"`
|
||||
Sender string `env:"MAIL_SENDER,required"`
|
||||
ApiKey string `env:"MAIL_API_KEY,required"`
|
||||
FiberClient *fiber.Client
|
||||
@ -47,10 +47,10 @@ type MailClientCfg struct {
|
||||
}
|
||||
|
||||
type JWTConfiguration struct {
|
||||
JwtPrivateKey string `env:"JWT_PRIVATE_KEY"`
|
||||
JwtPublicKey string `env:"JWT_PUBLIC_KEY,required"`
|
||||
JwtIssuer string `env:"JWT_ISSUER,required"`
|
||||
JwtAudience string `env:"JWT_AUDIENCE,required"`
|
||||
PrivateKey string `env:"JWT_PRIVATE_KEY"`
|
||||
PublicKey string `env:"JWT_PUBLIC_KEY,required"`
|
||||
Issuer string `env:"JWT_ISSUER,required"`
|
||||
Audience string `env:"JWT_AUDIENCE,required"`
|
||||
Algorithm jwt.SigningMethodRSA
|
||||
ExpiresIn time.Duration
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ type JWT struct {
|
||||
|
||||
func NewJWT(configuration *models.JWTConfiguration) *JWT {
|
||||
return &JWT{
|
||||
privateKey: []byte(configuration.JwtPrivateKey),
|
||||
publicKey: []byte(configuration.JwtPublicKey),
|
||||
privateKey: []byte(configuration.PrivateKey),
|
||||
publicKey: []byte(configuration.PublicKey),
|
||||
algorithm: &configuration.Algorithm,
|
||||
expiresIn: configuration.ExpiresIn,
|
||||
issuer: configuration.JwtIssuer,
|
||||
audience: configuration.JwtAudience,
|
||||
issuer: configuration.Issuer,
|
||||
audience: configuration.Audience,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,12 @@ func TestJWT(t *testing.T) {
|
||||
privateKey = strings.Replace(privateKey, "\t", "", -1)
|
||||
|
||||
jwt := utils.NewJWT(&models.JWTConfiguration{
|
||||
JwtPrivateKey: privateKey,
|
||||
JwtPublicKey: publicKey,
|
||||
PrivateKey: privateKey,
|
||||
PublicKey: publicKey,
|
||||
Algorithm: *jwt.SigningMethodRS256,
|
||||
ExpiresIn: 15 * time.Minute,
|
||||
JwtIssuer: "issuer1",
|
||||
JwtAudience: "audience1",
|
||||
Issuer: "issuer1",
|
||||
Audience: "audience1",
|
||||
})
|
||||
|
||||
t.Run("Успешная генерация токена", func(t *testing.T) {
|
||||
|
@ -33,10 +33,10 @@ func InitializeJWT() *utils.JWT {
|
||||
-----END RSA PRIVATE KEY-----`, "\t", "", -1)
|
||||
|
||||
return utils.NewJWT(&models.JWTConfiguration{
|
||||
JwtPrivateKey: privateKey,
|
||||
JwtPublicKey: publicKey,
|
||||
JwtAudience: "pena",
|
||||
JwtIssuer: "pena-auth-service",
|
||||
PrivateKey: privateKey,
|
||||
PublicKey: publicKey,
|
||||
Audience: "pena",
|
||||
Issuer: "pena-auth-service",
|
||||
Algorithm: *jwt.SigningMethodRS256,
|
||||
ExpiresIn: 15 * time.Minute,
|
||||
})
|
||||
|
@ -14,7 +14,7 @@ func TestSendMessage(t *testing.T) {
|
||||
apiKey := "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"
|
||||
|
||||
mailClient := client.NewMailClient(models.MailClientCfg{
|
||||
ApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
||||
ApiURL: "https://api.smtp.bz/v1/smtp/send",
|
||||
Sender: sender,
|
||||
ApiKey: apiKey,
|
||||
FiberClient: fiber.AcquireClient(),
|
||||
|
Loading…
Reference in New Issue
Block a user