fix(lint): warning from golangci-lint tool
https://github.com/appleboy/gorush/issues/704 Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
89bc97d15e
commit
4ef30a0cdc
|
@ -33,6 +33,7 @@ type LogPushEntry struct {
|
||||||
|
|
||||||
var isTerm bool
|
var isTerm bool
|
||||||
|
|
||||||
|
//nolint
|
||||||
func init() {
|
func init() {
|
||||||
isTerm = isatty.IsTerminal(os.Stdout.Fd())
|
isTerm = isatty.IsTerminal(os.Stdout.Fd())
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,15 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var invalidLevel = "invalid"
|
||||||
|
|
||||||
func TestSetLogLevel(t *testing.T) {
|
func TestSetLogLevel(t *testing.T) {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
|
|
||||||
err := SetLogLevel(log, "debug")
|
err := SetLogLevel(log, "debug")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = SetLogLevel(log, "invalid")
|
err = SetLogLevel(log, invalidLevel)
|
||||||
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
|
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ func TestInitDefaultLog(t *testing.T) {
|
||||||
cfg.Log.ErrorLog,
|
cfg.Log.ErrorLog,
|
||||||
))
|
))
|
||||||
|
|
||||||
cfg.Log.AccessLevel = "invalid"
|
cfg.Log.AccessLevel = invalidLevel
|
||||||
|
|
||||||
assert.NotNil(t, InitLog(
|
assert.NotNil(t, InitLog(
|
||||||
cfg.Log.AccessLevel,
|
cfg.Log.AccessLevel,
|
||||||
|
@ -71,7 +73,7 @@ func TestInitDefaultLog(t *testing.T) {
|
||||||
func TestAccessLevel(t *testing.T) {
|
func TestAccessLevel(t *testing.T) {
|
||||||
cfg, _ := config.LoadConf()
|
cfg, _ := config.LoadConf()
|
||||||
|
|
||||||
cfg.Log.AccessLevel = "invalid"
|
cfg.Log.AccessLevel = invalidLevel
|
||||||
|
|
||||||
assert.NotNil(t, InitLog(
|
assert.NotNil(t, InitLog(
|
||||||
cfg.Log.AccessLevel,
|
cfg.Log.AccessLevel,
|
||||||
|
@ -84,7 +86,7 @@ func TestAccessLevel(t *testing.T) {
|
||||||
func TestErrorLevel(t *testing.T) {
|
func TestErrorLevel(t *testing.T) {
|
||||||
cfg, _ := config.LoadConf()
|
cfg, _ := config.LoadConf()
|
||||||
|
|
||||||
cfg.Log.ErrorLevel = "invalid"
|
cfg.Log.ErrorLevel = invalidLevel
|
||||||
|
|
||||||
assert.NotNil(t, InitLog(
|
assert.NotNil(t, InitLog(
|
||||||
cfg.Log.AccessLevel,
|
cfg.Log.AccessLevel,
|
||||||
|
|
1
main.go
1
main.go
|
@ -28,6 +28,7 @@ import (
|
||||||
redisdb "github.com/golang-queue/redisdb-stream"
|
redisdb "github.com/golang-queue/redisdb-stream"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gocyclo
|
||||||
func main() {
|
func main() {
|
||||||
opts := config.ConfYaml{}
|
opts := config.ConfYaml{}
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,8 @@ var (
|
||||||
// MaxConcurrentIOSPushes pool to limit the number of concurrent iOS pushes
|
// MaxConcurrentIOSPushes pool to limit the number of concurrent iOS pushes
|
||||||
MaxConcurrentIOSPushes chan struct{}
|
MaxConcurrentIOSPushes chan struct{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HIGH = "high"
|
||||||
|
NORMAL = "nornal"
|
||||||
|
)
|
||||||
|
|
|
@ -101,22 +101,24 @@ type PushNotification struct {
|
||||||
FastAppTarget int `json:"fast_app_target,omitempty"`
|
FastAppTarget int `json:"fast_app_target,omitempty"`
|
||||||
|
|
||||||
// iOS
|
// iOS
|
||||||
Expiration *int64 `json:"expiration,omitempty"`
|
Expiration *int64 `json:"expiration,omitempty"`
|
||||||
ApnsID string `json:"apns_id,omitempty"`
|
ApnsID string `json:"apns_id,omitempty"`
|
||||||
CollapseID string `json:"collapse_id,omitempty"`
|
CollapseID string `json:"collapse_id,omitempty"`
|
||||||
Topic string `json:"topic,omitempty"`
|
Topic string `json:"topic,omitempty"`
|
||||||
PushType string `json:"push_type,omitempty"`
|
PushType string `json:"push_type,omitempty"`
|
||||||
Badge *int `json:"badge,omitempty"`
|
Badge *int `json:"badge,omitempty"`
|
||||||
Category string `json:"category,omitempty"`
|
Category string `json:"category,omitempty"`
|
||||||
ThreadID string `json:"thread-id,omitempty"`
|
ThreadID string `json:"thread-id,omitempty"`
|
||||||
URLArgs []string `json:"url-args,omitempty"`
|
URLArgs []string `json:"url-args,omitempty"`
|
||||||
Alert Alert `json:"alert,omitempty"`
|
Alert Alert `json:"alert,omitempty"`
|
||||||
Production bool `json:"production,omitempty"`
|
Production bool `json:"production,omitempty"`
|
||||||
Development bool `json:"development,omitempty"`
|
Development bool `json:"development,omitempty"`
|
||||||
SoundName string `json:"name,omitempty"`
|
SoundName string `json:"name,omitempty"`
|
||||||
SoundVolume float32 `json:"volume,omitempty"`
|
SoundVolume float32 `json:"volume,omitempty"`
|
||||||
Apns D `json:"apns,omitempty"`
|
Apns D `json:"apns,omitempty"`
|
||||||
InterruptionLevel string `json:"interruption_level,omitempty"` // ref: https://github.com/sideshow/apns2/blob/54928d6193dfe300b6b88dad72b7e2ae138d4f0a/payload/builder.go#L7-L24
|
|
||||||
|
// ref: https://github.com/sideshow/apns2/blob/54928d6193dfe300b6b88dad72b7e2ae138d4f0a/payload/builder.go#L7-L24
|
||||||
|
InterruptionLevel string `json:"interruption_level,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bytes for queue message
|
// Bytes for queue message
|
||||||
|
|
|
@ -30,6 +30,12 @@ var (
|
||||||
tcpKeepAlive = 60 * time.Second
|
tcpKeepAlive = 60 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dotP8 = ".p8"
|
||||||
|
dotPEM = ".pem"
|
||||||
|
dotP12 = ".p12"
|
||||||
|
)
|
||||||
|
|
||||||
var doOnce sync.Once
|
var doOnce sync.Once
|
||||||
|
|
||||||
// DialTLS is the default dial function for creating TLS connections for
|
// DialTLS is the default dial function for creating TLS connections for
|
||||||
|
@ -63,11 +69,11 @@ func InitAPNSClient(cfg *config.ConfYaml) error {
|
||||||
ext = filepath.Ext(cfg.Ios.KeyPath)
|
ext = filepath.Ext(cfg.Ios.KeyPath)
|
||||||
|
|
||||||
switch ext {
|
switch ext {
|
||||||
case ".p12":
|
case dotP12:
|
||||||
certificateKey, err = certificate.FromP12File(cfg.Ios.KeyPath, cfg.Ios.Password)
|
certificateKey, err = certificate.FromP12File(cfg.Ios.KeyPath, cfg.Ios.Password)
|
||||||
case ".pem":
|
case dotPEM:
|
||||||
certificateKey, err = certificate.FromPemFile(cfg.Ios.KeyPath, cfg.Ios.Password)
|
certificateKey, err = certificate.FromPemFile(cfg.Ios.KeyPath, cfg.Ios.Password)
|
||||||
case ".p8":
|
case dotP8:
|
||||||
authKey, err = token.AuthKeyFromFile(cfg.Ios.KeyPath)
|
authKey, err = token.AuthKeyFromFile(cfg.Ios.KeyPath)
|
||||||
default:
|
default:
|
||||||
err = errors.New("wrong certificate key extension")
|
err = errors.New("wrong certificate key extension")
|
||||||
|
@ -87,11 +93,11 @@ func InitAPNSClient(cfg *config.ConfYaml) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch ext {
|
switch ext {
|
||||||
case ".p12":
|
case dotP12:
|
||||||
certificateKey, err = certificate.FromP12Bytes(key, cfg.Ios.Password)
|
certificateKey, err = certificate.FromP12Bytes(key, cfg.Ios.Password)
|
||||||
case ".pem":
|
case dotPEM:
|
||||||
certificateKey, err = certificate.FromPemBytes(key, cfg.Ios.Password)
|
certificateKey, err = certificate.FromPemBytes(key, cfg.Ios.Password)
|
||||||
case ".p8":
|
case dotP8:
|
||||||
authKey, err = token.AuthKeyFromBytes(key)
|
authKey, err = token.AuthKeyFromBytes(key)
|
||||||
default:
|
default:
|
||||||
err = errors.New("wrong certificate key type")
|
err = errors.New("wrong certificate key type")
|
||||||
|
@ -104,7 +110,7 @@ func InitAPNSClient(cfg *config.ConfYaml) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ext == ".p8" {
|
if ext == dotP8 {
|
||||||
if cfg.Ios.KeyID == "" || cfg.Ios.TeamID == "" {
|
if cfg.Ios.KeyID == "" || cfg.Ios.TeamID == "" {
|
||||||
msg := "you should provide ios.KeyID and ios.TeamID for p8 token"
|
msg := "you should provide ios.KeyID and ios.TeamID for p8 token"
|
||||||
logx.LogError.Error(msg)
|
logx.LogError.Error(msg)
|
||||||
|
@ -154,6 +160,7 @@ func newApnsClient(cfg *config.ConfYaml, certificate tls.Certificate) (*apns2.Cl
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gosec
|
||||||
tlsConfig := &tls.Config{
|
tlsConfig := &tls.Config{
|
||||||
Certificates: []tls.Certificate{certificate},
|
Certificates: []tls.Certificate{certificate},
|
||||||
}
|
}
|
||||||
|
@ -307,7 +314,7 @@ func GetIOSNotification(req *PushNotification) *apns2.Notification {
|
||||||
if len(req.Priority) > 0 {
|
if len(req.Priority) > 0 {
|
||||||
if req.Priority == "normal" {
|
if req.Priority == "normal" {
|
||||||
notification.Priority = apns2.PriorityLow
|
notification.Priority = apns2.PriorityLow
|
||||||
} else if req.Priority == "high" {
|
} else if req.Priority == HIGH {
|
||||||
notification.Priority = apns2.PriorityHigh
|
notification.Priority = apns2.PriorityHigh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,13 @@ const (
|
||||||
authkeyValidP8 = `LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZ0ViVnpmUG5aUHhmQXl4cUUKWlYwNWxhQW9KQWwrLzZYdDJPNG1PQjYxMXNPaFJBTkNBQVNnRlRLandKQUFVOTVnKysvdnpLV0hrekFWbU5NSQp0QjV2VGpaT09Jd25FYjcwTXNXWkZJeVVGRDFQOUd3c3R6NCtha0hYN3ZJOEJINmhIbUJtZmVRbAotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==`
|
authkeyValidP8 = `LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZ0ViVnpmUG5aUHhmQXl4cUUKWlYwNWxhQW9KQWwrLzZYdDJPNG1PQjYxMXNPaFJBTkNBQVNnRlRLandKQUFVOTVnKysvdnpLV0hrekFWbU5NSQp0QjV2VGpaT09Jd25FYjcwTXNXWkZJeVVGRDFQOUd3c3R6NCtha0hYN3ZJOEJINmhIbUJtZmVRbAotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
testMessage = "test"
|
||||||
|
testKeyPathP8 = "../certificate/authkey-valid.p8"
|
||||||
|
testKeyPath = "../certificate/certificate-valid.pem"
|
||||||
|
welcomeMessage = "Welcome notification Server"
|
||||||
|
)
|
||||||
|
|
||||||
func TestDisabledAndroidIosConf(t *testing.T) {
|
func TestDisabledAndroidIosConf(t *testing.T) {
|
||||||
cfg, _ := config.LoadConf()
|
cfg, _ := config.LoadConf()
|
||||||
cfg.Android.Enabled = false
|
cfg.Android.Enabled = false
|
||||||
|
@ -60,20 +67,19 @@ func TestIOSNotificationStructure(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
unix := time.Now().Unix()
|
unix := time.Now().Unix()
|
||||||
|
|
||||||
test := "test"
|
|
||||||
expectBadge := 0
|
expectBadge := 0
|
||||||
message := "Welcome notification Server"
|
message := welcomeMessage
|
||||||
expiration := time.Now().Unix()
|
expiration := time.Now().Unix()
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Expiration: &expiration,
|
Expiration: &expiration,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Badge: &expectBadge,
|
Badge: &expectBadge,
|
||||||
Sound: Sound{
|
Sound: Sound{
|
||||||
Critical: 1,
|
Critical: 1,
|
||||||
Name: test,
|
Name: testMessage,
|
||||||
Volume: 1.0,
|
Volume: 1.0,
|
||||||
},
|
},
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
|
@ -81,7 +87,7 @@ func TestIOSNotificationStructure(t *testing.T) {
|
||||||
"key1": "test",
|
"key1": "test",
|
||||||
"key2": 2,
|
"key2": 2,
|
||||||
},
|
},
|
||||||
Category: test,
|
Category: testMessage,
|
||||||
URLArgs: []string{"a", "b"},
|
URLArgs: []string{"a", "b"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,20 +112,20 @@ func TestIOSNotificationStructure(t *testing.T) {
|
||||||
aps := dat["aps"].(map[string]interface{})
|
aps := dat["aps"].(map[string]interface{})
|
||||||
urlArgs := aps["url-args"].([]interface{})
|
urlArgs := aps["url-args"].([]interface{})
|
||||||
|
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, test, notification.Topic)
|
assert.Equal(t, testMessage, notification.Topic)
|
||||||
assert.Equal(t, unix, notification.Expiration.Unix())
|
assert.Equal(t, unix, notification.Expiration.Unix())
|
||||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||||
assert.Equal(t, message, alert)
|
assert.Equal(t, message, alert)
|
||||||
assert.Equal(t, expectBadge, int(badge))
|
assert.Equal(t, expectBadge, int(badge))
|
||||||
assert.Equal(t, expectBadge, *req.Badge)
|
assert.Equal(t, expectBadge, *req.Badge)
|
||||||
assert.Equal(t, test, soundName)
|
assert.Equal(t, testMessage, soundName)
|
||||||
assert.Equal(t, 1.0, soundVolume)
|
assert.Equal(t, 1.0, soundVolume)
|
||||||
assert.Equal(t, int64(1), soundCritical)
|
assert.Equal(t, int64(1), soundCritical)
|
||||||
assert.Equal(t, 1, int(contentAvailable))
|
assert.Equal(t, 1, int(contentAvailable))
|
||||||
assert.Equal(t, "test", key1)
|
assert.Equal(t, "test", key1)
|
||||||
assert.Equal(t, 2, int(key2.(float64)))
|
assert.Equal(t, 2, int(key2.(float64)))
|
||||||
assert.Equal(t, test, category)
|
assert.Equal(t, testMessage, category)
|
||||||
assert.Contains(t, urlArgs, "a")
|
assert.Contains(t, urlArgs, "a")
|
||||||
assert.Contains(t, urlArgs, "b")
|
assert.Contains(t, urlArgs, "b")
|
||||||
}
|
}
|
||||||
|
@ -127,16 +133,15 @@ func TestIOSNotificationStructure(t *testing.T) {
|
||||||
func TestIOSSoundAndVolume(t *testing.T) {
|
func TestIOSSoundAndVolume(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
message := welcomeMessage
|
||||||
message := "Welcome notification Server"
|
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Sound: Sound{
|
Sound: Sound{
|
||||||
Critical: 3,
|
Critical: 3,
|
||||||
Name: test,
|
Name: testMessage,
|
||||||
Volume: 4.5,
|
Volume: 4.5,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -155,11 +160,11 @@ func TestIOSSoundAndVolume(t *testing.T) {
|
||||||
soundCritical, _ := jsonparser.GetInt(data, "aps", "sound", "critical")
|
soundCritical, _ := jsonparser.GetInt(data, "aps", "sound", "critical")
|
||||||
soundVolume, _ := jsonparser.GetFloat(data, "aps", "sound", "volume")
|
soundVolume, _ := jsonparser.GetFloat(data, "aps", "sound", "volume")
|
||||||
|
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, test, notification.Topic)
|
assert.Equal(t, testMessage, notification.Topic)
|
||||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||||
assert.Equal(t, message, alert)
|
assert.Equal(t, message, alert)
|
||||||
assert.Equal(t, test, soundName)
|
assert.Equal(t, testMessage, soundName)
|
||||||
assert.Equal(t, 4.5, soundVolume)
|
assert.Equal(t, 4.5, soundVolume)
|
||||||
assert.Equal(t, int64(3), soundCritical)
|
assert.Equal(t, int64(3), soundCritical)
|
||||||
|
|
||||||
|
@ -181,8 +186,8 @@ func TestIOSSoundAndVolume(t *testing.T) {
|
||||||
assert.Equal(t, "foobar", soundName)
|
assert.Equal(t, "foobar", soundName)
|
||||||
|
|
||||||
req = &PushNotification{
|
req = &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Sound: map[string]interface{}{
|
Sound: map[string]interface{}{
|
||||||
|
@ -208,8 +213,8 @@ func TestIOSSoundAndVolume(t *testing.T) {
|
||||||
assert.Equal(t, "test", soundName)
|
assert.Equal(t, "test", soundName)
|
||||||
|
|
||||||
req = &PushNotification{
|
req = &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Sound: "default",
|
Sound: "default",
|
||||||
|
@ -230,11 +235,10 @@ func TestIOSSoundAndVolume(t *testing.T) {
|
||||||
func TestIOSSummaryArg(t *testing.T) {
|
func TestIOSSummaryArg(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
message := welcomeMessage
|
||||||
message := "Welcome notification Server"
|
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Alert: Alert{
|
Alert: Alert{
|
||||||
|
@ -252,8 +256,8 @@ func TestIOSSummaryArg(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, test, notification.Topic)
|
assert.Equal(t, testMessage, notification.Topic)
|
||||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||||
assert.Equal(t, "test", dat["aps"].(map[string]interface{})["alert"].(map[string]interface{})["summary-arg"])
|
assert.Equal(t, "test", dat["aps"].(map[string]interface{})["alert"].(map[string]interface{})["summary-arg"])
|
||||||
assert.Equal(t, float64(3), dat["aps"].(map[string]interface{})["alert"].(map[string]interface{})["summary-arg-count"])
|
assert.Equal(t, float64(3), dat["aps"].(map[string]interface{})["alert"].(map[string]interface{})["summary-arg-count"])
|
||||||
|
@ -264,17 +268,16 @@ func TestIOSSummaryArg(t *testing.T) {
|
||||||
func TestSendZeroValueForBadgeKey(t *testing.T) {
|
func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
message := welcomeMessage
|
||||||
message := "Welcome notification Server"
|
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Sound: test,
|
Sound: testMessage,
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
MutableContent: true,
|
MutableContent: true,
|
||||||
ThreadID: test,
|
ThreadID: testMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
notification := GetIOSNotification(req)
|
notification := GetIOSNotification(req)
|
||||||
|
@ -298,13 +301,13 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
t.Errorf("req.Badge must be nil")
|
t.Errorf("req.Badge must be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, test, notification.Topic)
|
assert.Equal(t, testMessage, notification.Topic)
|
||||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||||
assert.Equal(t, message, alert)
|
assert.Equal(t, message, alert)
|
||||||
assert.Equal(t, 0, int(badge))
|
assert.Equal(t, 0, int(badge))
|
||||||
assert.Equal(t, test, sound)
|
assert.Equal(t, testMessage, sound)
|
||||||
assert.Equal(t, test, threadID)
|
assert.Equal(t, testMessage, threadID)
|
||||||
assert.Equal(t, 1, int(contentAvailable))
|
assert.Equal(t, 1, int(contentAvailable))
|
||||||
assert.Equal(t, 1, int(mutableContent))
|
assert.Equal(t, 1, int(mutableContent))
|
||||||
|
|
||||||
|
@ -338,11 +341,10 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
func TestCheckSilentNotification(t *testing.T) {
|
func TestCheckSilentNotification(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
CollapseID: test,
|
CollapseID: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
}
|
}
|
||||||
|
@ -357,9 +359,9 @@ func TestCheckSilentNotification(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, test, notification.CollapseID)
|
assert.Equal(t, testMessage, notification.CollapseID)
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, test, notification.Topic)
|
assert.Equal(t, testMessage, notification.Topic)
|
||||||
assert.Nil(t, dat["aps"].(map[string]interface{})["alert"])
|
assert.Nil(t, dat["aps"].(map[string]interface{})["alert"])
|
||||||
assert.Nil(t, dat["aps"].(map[string]interface{})["sound"])
|
assert.Nil(t, dat["aps"].(map[string]interface{})["sound"])
|
||||||
assert.Nil(t, dat["aps"].(map[string]interface{})["badge"])
|
assert.Nil(t, dat["aps"].(map[string]interface{})["badge"])
|
||||||
|
@ -383,13 +385,12 @@ func TestCheckSilentNotification(t *testing.T) {
|
||||||
func TestAlertStringExample2ForIos(t *testing.T) {
|
func TestAlertStringExample2ForIos(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
|
||||||
title := "Game Request"
|
title := "Game Request"
|
||||||
body := "Bob wants to play poker"
|
body := "Bob wants to play poker"
|
||||||
actionLocKey := "PLAY"
|
actionLocKey := "PLAY"
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Alert: Alert{
|
Alert: Alert{
|
||||||
Title: title,
|
Title: title,
|
||||||
|
@ -428,15 +429,14 @@ func TestAlertStringExample2ForIos(t *testing.T) {
|
||||||
func TestAlertStringExample3ForIos(t *testing.T) {
|
func TestAlertStringExample3ForIos(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
|
||||||
badge := 9
|
badge := 9
|
||||||
sound := "bingbong.aiff"
|
sound := "bingbong.aiff"
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
Message: test,
|
Message: testMessage,
|
||||||
Badge: &badge,
|
Badge: &badge,
|
||||||
Sound: sound,
|
Sound: sound,
|
||||||
}
|
}
|
||||||
|
@ -453,18 +453,17 @@ func TestAlertStringExample3ForIos(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, sound, dat["aps"].(map[string]interface{})["sound"])
|
assert.Equal(t, sound, dat["aps"].(map[string]interface{})["sound"])
|
||||||
assert.Equal(t, float64(badge), dat["aps"].(map[string]interface{})["badge"].(float64))
|
assert.Equal(t, float64(badge), dat["aps"].(map[string]interface{})["badge"].(float64))
|
||||||
assert.Equal(t, test, dat["aps"].(map[string]interface{})["alert"])
|
assert.Equal(t, testMessage, dat["aps"].(map[string]interface{})["alert"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMessageAndTitle(t *testing.T) {
|
func TestMessageAndTitle(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
message := welcomeMessage
|
||||||
message := "Welcome notification Server"
|
|
||||||
title := "Welcome notification Server title"
|
title := "Welcome notification Server title"
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
ApnsID: test,
|
ApnsID: testMessage,
|
||||||
Topic: test,
|
Topic: testMessage,
|
||||||
Priority: "normal",
|
Priority: "normal",
|
||||||
Message: message,
|
Message: message,
|
||||||
Title: title,
|
Title: title,
|
||||||
|
@ -485,7 +484,7 @@ func TestMessageAndTitle(t *testing.T) {
|
||||||
alertBody, _ := jsonparser.GetString(data, "aps", "alert", "body")
|
alertBody, _ := jsonparser.GetString(data, "aps", "alert", "body")
|
||||||
alertTitle, _ := jsonparser.GetString(data, "aps", "alert", "title")
|
alertTitle, _ := jsonparser.GetString(data, "aps", "alert", "title")
|
||||||
|
|
||||||
assert.Equal(t, test, notification.ApnsID)
|
assert.Equal(t, testMessage, notification.ApnsID)
|
||||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||||
assert.Equal(t, message, alertBody)
|
assert.Equal(t, message, alertBody)
|
||||||
assert.Equal(t, title, alertTitle)
|
assert.Equal(t, title, alertTitle)
|
||||||
|
@ -515,22 +514,21 @@ func TestMessageAndTitle(t *testing.T) {
|
||||||
func TestIOSAlertNotificationStructure(t *testing.T) {
|
func TestIOSAlertNotificationStructure(t *testing.T) {
|
||||||
var dat map[string]interface{}
|
var dat map[string]interface{}
|
||||||
|
|
||||||
test := "test"
|
|
||||||
req := &PushNotification{
|
req := &PushNotification{
|
||||||
Message: "Welcome",
|
Message: "Welcome",
|
||||||
Title: test,
|
Title: testMessage,
|
||||||
Alert: Alert{
|
Alert: Alert{
|
||||||
Action: test,
|
Action: testMessage,
|
||||||
ActionLocKey: test,
|
ActionLocKey: testMessage,
|
||||||
Body: test,
|
Body: testMessage,
|
||||||
LaunchImage: test,
|
LaunchImage: testMessage,
|
||||||
LocArgs: []string{"a", "b"},
|
LocArgs: []string{"a", "b"},
|
||||||
LocKey: test,
|
LocKey: testMessage,
|
||||||
Subtitle: test,
|
Subtitle: testMessage,
|
||||||
TitleLocArgs: []string{"a", "b"},
|
TitleLocArgs: []string{"a", "b"},
|
||||||
TitleLocKey: test,
|
TitleLocKey: testMessage,
|
||||||
},
|
},
|
||||||
InterruptionLevel: test,
|
InterruptionLevel: testMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
notification := GetIOSNotification(req)
|
notification := GetIOSNotification(req)
|
||||||
|
@ -557,15 +555,15 @@ func TestIOSAlertNotificationStructure(t *testing.T) {
|
||||||
titleLocArgs := alert["title-loc-args"].([]interface{})
|
titleLocArgs := alert["title-loc-args"].([]interface{})
|
||||||
locArgs := alert["loc-args"].([]interface{})
|
locArgs := alert["loc-args"].([]interface{})
|
||||||
|
|
||||||
assert.Equal(t, test, action)
|
assert.Equal(t, testMessage, action)
|
||||||
assert.Equal(t, test, actionLocKey)
|
assert.Equal(t, testMessage, actionLocKey)
|
||||||
assert.Equal(t, test, body)
|
assert.Equal(t, testMessage, body)
|
||||||
assert.Equal(t, test, launchImage)
|
assert.Equal(t, testMessage, launchImage)
|
||||||
assert.Equal(t, test, locKey)
|
assert.Equal(t, testMessage, locKey)
|
||||||
assert.Equal(t, test, title)
|
assert.Equal(t, testMessage, title)
|
||||||
assert.Equal(t, test, subtitle)
|
assert.Equal(t, testMessage, subtitle)
|
||||||
assert.Equal(t, test, titleLocKey)
|
assert.Equal(t, testMessage, titleLocKey)
|
||||||
assert.Equal(t, test, interruptionLevel)
|
assert.Equal(t, testMessage, interruptionLevel)
|
||||||
assert.Contains(t, titleLocArgs, "a")
|
assert.Contains(t, titleLocArgs, "a")
|
||||||
assert.Contains(t, titleLocArgs, "b")
|
assert.Contains(t, titleLocArgs, "b")
|
||||||
assert.Contains(t, locArgs, "a")
|
assert.Contains(t, locArgs, "a")
|
||||||
|
@ -613,7 +611,7 @@ func TestAPNSClientProdHost(t *testing.T) {
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.Production = true
|
cfg.Ios.Production = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := InitAPNSClient(cfg)
|
err := InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, apns2.HostProduction, ApnsClient.Host)
|
assert.Equal(t, apns2.HostProduction, ApnsClient.Host)
|
||||||
|
@ -642,7 +640,7 @@ func TestAPNSClientInvaildToken(t *testing.T) {
|
||||||
|
|
||||||
// empty key-id or team-id
|
// empty key-id or team-id
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
cfg.Ios.KeyPath = testKeyPathP8
|
||||||
err = InitAPNSClient(cfg)
|
err = InitAPNSClient(cfg)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
@ -661,7 +659,7 @@ func TestAPNSClientVaildToken(t *testing.T) {
|
||||||
cfg, _ := config.LoadConf()
|
cfg, _ := config.LoadConf()
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
cfg.Ios.KeyPath = testKeyPathP8
|
||||||
cfg.Ios.KeyID = "key-id"
|
cfg.Ios.KeyID = "key-id"
|
||||||
cfg.Ios.TeamID = "team-id"
|
cfg.Ios.TeamID = "team-id"
|
||||||
err := InitAPNSClient(cfg)
|
err := InitAPNSClient(cfg)
|
||||||
|
@ -706,7 +704,7 @@ func TestAPNSClientUseProxy(t *testing.T) {
|
||||||
expectedProxyURL, _ := url.ParseRequestURI(cfg.Core.HTTPProxy)
|
expectedProxyURL, _ := url.ParseRequestURI(cfg.Core.HTTPProxy)
|
||||||
assert.Equal(t, expectedProxyURL, actualProxyURL)
|
assert.Equal(t, expectedProxyURL, actualProxyURL)
|
||||||
|
|
||||||
cfg.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
cfg.Ios.KeyPath = testKeyPathP8
|
||||||
cfg.Ios.TeamID = "example.team"
|
cfg.Ios.TeamID = "example.team"
|
||||||
cfg.Ios.KeyID = "example.key"
|
cfg.Ios.KeyID = "example.key"
|
||||||
err = InitAPNSClient(cfg)
|
err = InitAPNSClient(cfg)
|
||||||
|
@ -729,7 +727,7 @@ func TestPushToIOS(t *testing.T) {
|
||||||
MaxConcurrentIOSPushes = make(chan struct{}, cfg.Ios.MaxConcurrentPushes)
|
MaxConcurrentIOSPushes = make(chan struct{}, cfg.Ios.MaxConcurrentPushes)
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := InitAPNSClient(cfg)
|
err := InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
err = status.InitAppStatus(cfg)
|
err = status.InitAppStatus(cfg)
|
||||||
|
@ -752,7 +750,7 @@ func TestApnsHostFromRequest(t *testing.T) {
|
||||||
cfg, _ := config.LoadConf()
|
cfg, _ := config.LoadConf()
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := InitAPNSClient(cfg)
|
err := InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
err = status.InitAppStatus(cfg)
|
err = status.InitAppStatus(cfg)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func GetAndroidNotification(req *PushNotification) *fcm.Message {
|
||||||
notification.RegistrationIDs = req.Tokens
|
notification.RegistrationIDs = req.Tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Priority == "high" || req.Priority == "normal" {
|
if req.Priority == HIGH || req.Priority == "normal" {
|
||||||
notification.Priority = req.Priority
|
notification.Priority = req.Priority
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ func TestAndroidNotificationStructure(t *testing.T) {
|
||||||
Tokens: []string{"a", "b"},
|
Tokens: []string{"a", "b"},
|
||||||
Message: "Welcome",
|
Message: "Welcome",
|
||||||
To: test,
|
To: test,
|
||||||
Priority: "high",
|
Priority: HIGH,
|
||||||
CollapseKey: "1",
|
CollapseKey: "1",
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
DelayWhileIdle: true,
|
DelayWhileIdle: true,
|
||||||
|
@ -242,7 +242,7 @@ func TestAndroidNotificationStructure(t *testing.T) {
|
||||||
notification := GetAndroidNotification(req)
|
notification := GetAndroidNotification(req)
|
||||||
|
|
||||||
assert.Equal(t, test, notification.To)
|
assert.Equal(t, test, notification.To)
|
||||||
assert.Equal(t, "high", notification.Priority)
|
assert.Equal(t, HIGH, notification.Priority)
|
||||||
assert.Equal(t, "1", notification.CollapseKey)
|
assert.Equal(t, "1", notification.CollapseKey)
|
||||||
assert.True(t, notification.ContentAvailable)
|
assert.True(t, notification.ContentAvailable)
|
||||||
assert.True(t, notification.DelayWhileIdle)
|
assert.True(t, notification.DelayWhileIdle)
|
||||||
|
|
|
@ -87,7 +87,7 @@ func GetHuaweiNotification(req *PushNotification) (*model.MessageRequest, error)
|
||||||
msgRequest.Message.Condition = req.Condition
|
msgRequest.Message.Condition = req.Condition
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Priority == "high" {
|
if req.Priority == HIGH {
|
||||||
msgRequest.Message.Android.Urgency = "HIGH"
|
msgRequest.Message.Android.Urgency = "HIGH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestCorrectConf(t *testing.T) {
|
||||||
cfg.Android.APIKey = "xxxxx"
|
cfg.Android.APIKey = "xxxxx"
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
|
|
||||||
err := CheckPushConf(cfg)
|
err := CheckPushConf(cfg)
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ func autoTLSServer(cfg *config.ConfYaml, q *queue.Queue) *http.Server {
|
||||||
Cache: autocert.DirCache(cfg.Core.AutoTLS.Folder),
|
Cache: autocert.DirCache(cfg.Core.AutoTLS.Folder),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gosec
|
||||||
return &http.Server{
|
return &http.Server{
|
||||||
Addr: ":https",
|
Addr: ":https",
|
||||||
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
|
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
|
||||||
|
|
|
@ -28,6 +28,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
|
//nolint:gosec
|
||||||
server = &http.Server{
|
server = &http.Server{
|
||||||
Addr: cfg.Core.Address + ":" + cfg.Core.Port,
|
Addr: cfg.Core.Address + ":" + cfg.Core.Port,
|
||||||
Handler: routerEngine(cfg, q),
|
Handler: routerEngine(cfg, q),
|
||||||
|
@ -40,6 +41,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
|
||||||
if cfg.Core.AutoTLS.Enabled {
|
if cfg.Core.AutoTLS.Enabled {
|
||||||
return startServer(ctx, autoTLSServer(cfg, q), cfg)
|
return startServer(ctx, autoTLSServer(cfg, q), cfg)
|
||||||
} else if cfg.Core.SSL {
|
} else if cfg.Core.SSL {
|
||||||
|
//nolint
|
||||||
config := &tls.Config{
|
config := &tls.Config{
|
||||||
MinVersion: tls.VersionTLS10,
|
MinVersion: tls.VersionTLS10,
|
||||||
}
|
}
|
||||||
|
@ -49,6 +51,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Certificates = make([]tls.Certificate, 1)
|
config.Certificates = make([]tls.Certificate, 1)
|
||||||
|
//nolint:gocritic
|
||||||
if cfg.Core.CertPath != "" && cfg.Core.KeyPath != "" {
|
if cfg.Core.CertPath != "" && cfg.Core.KeyPath != "" {
|
||||||
config.Certificates[0], err = tls.LoadX509KeyPair(cfg.Core.CertPath, cfg.Core.KeyPath)
|
config.Certificates[0], err = tls.LoadX509KeyPair(cfg.Core.CertPath, cfg.Core.KeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -26,8 +26,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
goVersion = runtime.Version()
|
goVersion = runtime.Version()
|
||||||
q *queue.Queue
|
q *queue.Queue
|
||||||
|
testKeyPath = "../certificate/certificate-valid.pem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@ -471,7 +472,7 @@ func TestSenMultipleNotifications(t *testing.T) {
|
||||||
cfg := initTest()
|
cfg := initTest()
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := notify.InitAPNSClient(cfg)
|
err := notify.InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
@ -507,7 +508,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
|
||||||
cfg := initTest()
|
cfg := initTest()
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := notify.InitAPNSClient(cfg)
|
err := notify.InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
@ -543,7 +544,7 @@ func TestSyncModeForNotifications(t *testing.T) {
|
||||||
cfg := initTest()
|
cfg := initTest()
|
||||||
|
|
||||||
cfg.Ios.Enabled = true
|
cfg.Ios.Enabled = true
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := notify.InitAPNSClient(cfg)
|
err := notify.InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
@ -654,7 +655,7 @@ func TestDisabledIosNotifications(t *testing.T) {
|
||||||
cfg := initTest()
|
cfg := initTest()
|
||||||
|
|
||||||
cfg.Ios.Enabled = false
|
cfg.Ios.Enabled = false
|
||||||
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
cfg.Ios.KeyPath = testKeyPath
|
||||||
err := notify.InitAPNSClient(cfg)
|
err := notify.InitAPNSClient(cfg)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ func (c *healthClient) Check(ctx context.Context) (bool, error) {
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
//nolint:exhaustive
|
||||||
switch status.Code(err) {
|
switch status.Code(err) {
|
||||||
case
|
case
|
||||||
codes.Aborted,
|
codes.Aborted,
|
||||||
|
|
|
@ -58,6 +58,7 @@ func InitAppStatus(conf *config.ConfYaml) error {
|
||||||
logx.LogAccess.Info("Init App Status Engine as ", conf.Stat.Engine)
|
logx.LogAccess.Info("Init App Status Engine as ", conf.Stat.Engine)
|
||||||
|
|
||||||
var store core.Storage
|
var store core.Storage
|
||||||
|
//nolint:goconst
|
||||||
switch conf.Stat.Engine {
|
switch conf.Stat.Engine {
|
||||||
case "memory":
|
case "memory":
|
||||||
store = memory.New()
|
store = memory.New()
|
||||||
|
|
Loading…
Reference in New Issue