rename pem_path to key_path.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
377fca0bae
commit
6be5e24833
|
@ -72,7 +72,7 @@ android:
|
|||
|
||||
ios:
|
||||
enabled: false
|
||||
pem_path: "key.pem"
|
||||
key_path: "key.pem"
|
||||
password: "" # certificate password, default as empty string.
|
||||
production: false
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ type SectionAndroid struct {
|
|||
// SectionIos is sub seciont of config.
|
||||
type SectionIos struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
PemPath string `yaml:"pem_path"`
|
||||
KeyPath string `yaml:"key_path"`
|
||||
Password string `yaml:"password"`
|
||||
Production bool `yaml:"production"`
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func BuildDefaultPushConf() ConfYaml {
|
|||
|
||||
// iOS
|
||||
conf.Ios.Enabled = false
|
||||
conf.Ios.PemPath = "key.pem"
|
||||
conf.Ios.KeyPath = "key.pem"
|
||||
conf.Ios.Password = ""
|
||||
conf.Ios.Production = false
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ android:
|
|||
|
||||
ios:
|
||||
enabled: false
|
||||
pem_path: "key.pem"
|
||||
key_path: "key.pem"
|
||||
password: ""
|
||||
production: false
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ func main() {
|
|||
flag.BoolVar(&showVersion, "v", false, "Print version information.")
|
||||
flag.StringVar(&configFile, "c", "", "Configuration file.")
|
||||
flag.StringVar(&configFile, "config", "", "Configuration file.")
|
||||
flag.StringVar(&opts.Ios.PemPath, "i", "", "iOS certificate key file path")
|
||||
flag.StringVar(&opts.Ios.PemPath, "pem", "", "iOS certificate key file path")
|
||||
flag.StringVar(&opts.Ios.KeyPath, "i", "", "iOS certificate key file path")
|
||||
flag.StringVar(&opts.Ios.KeyPath, "pem", "", "iOS certificate key file path")
|
||||
flag.StringVar(&opts.Ios.Password, "P", "", "iOS certificate password for gorush")
|
||||
flag.StringVar(&opts.Ios.Password, "password", "", "iOS certificate password for gorush")
|
||||
flag.StringVar(&opts.Android.APIKey, "k", "", "Android api key configuration for gorush")
|
||||
|
@ -110,8 +110,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
if opts.Ios.PemPath != "" {
|
||||
gorush.PushConf.Ios.PemPath = opts.Ios.PemPath
|
||||
if opts.Ios.KeyPath != "" {
|
||||
gorush.PushConf.Ios.KeyPath = opts.Ios.KeyPath
|
||||
}
|
||||
|
||||
if opts.Ios.Password != "" {
|
||||
|
|
|
@ -123,7 +123,7 @@ func CheckPushConf() error {
|
|||
}
|
||||
|
||||
if PushConf.Ios.Enabled {
|
||||
if PushConf.Ios.PemPath == "" {
|
||||
if PushConf.Ios.KeyPath == "" {
|
||||
return errors.New("Missing iOS certificate path")
|
||||
}
|
||||
}
|
||||
|
@ -141,15 +141,15 @@ func CheckPushConf() error {
|
|||
func InitAPNSClient() error {
|
||||
if PushConf.Ios.Enabled {
|
||||
var err error
|
||||
ext := filepath.Ext(PushConf.Ios.PemPath)
|
||||
ext := filepath.Ext(PushConf.Ios.KeyPath)
|
||||
|
||||
LogAccess.Debug("certificate ext is ", ext)
|
||||
|
||||
switch ext {
|
||||
case ".p12":
|
||||
CertificatePemIos, err = certificate.FromP12File(PushConf.Ios.PemPath, PushConf.Ios.Password)
|
||||
CertificatePemIos, err = certificate.FromP12File(PushConf.Ios.KeyPath, PushConf.Ios.Password)
|
||||
case ".pem":
|
||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, PushConf.Ios.Password)
|
||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.KeyPath, PushConf.Ios.Password)
|
||||
default:
|
||||
err = errors.New("Wrong Certificate key extension.")
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestMissingIOSCertificate(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = ""
|
||||
PushConf.Ios.KeyPath = ""
|
||||
|
||||
err := CheckPushConf()
|
||||
|
||||
|
@ -53,7 +53,7 @@ func TestCorrectConf(t *testing.T) {
|
|||
PushConf.Android.APIKey = "xxxxx"
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "xxxxx"
|
||||
PushConf.Ios.KeyPath = "xxxxx"
|
||||
|
||||
err := CheckPushConf()
|
||||
|
||||
|
@ -222,7 +222,7 @@ func TestPushToIOS(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
||||
InitAPNSClient()
|
||||
InitAppStatus()
|
||||
|
||||
|
@ -332,7 +332,7 @@ func TestSenMultipleNotifications(t *testing.T) {
|
|||
InitWorkers(2, 2)
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
||||
InitAPNSClient()
|
||||
|
||||
PushConf.Android.Enabled = true
|
||||
|
@ -365,7 +365,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
||||
InitAPNSClient()
|
||||
|
||||
PushConf.Android.Enabled = false
|
||||
|
@ -398,7 +398,7 @@ func TestDisabledIosNotifications(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = false
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
||||
InitAPNSClient()
|
||||
|
||||
PushConf.Android.Enabled = true
|
||||
|
@ -431,7 +431,7 @@ func TestWrongIosCertificateExt(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "test"
|
||||
PushConf.Ios.KeyPath = "test"
|
||||
err := InitAPNSClient()
|
||||
|
||||
assert.Error(t, err)
|
||||
|
@ -442,7 +442,7 @@ func TestAPNSClientDevHost(t *testing.T) {
|
|||
PushConf = config.BuildDefaultPushConf()
|
||||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.p12"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.p12"
|
||||
InitAPNSClient()
|
||||
|
||||
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
|
||||
|
@ -453,7 +453,7 @@ func TestAPNSClientProdHost(t *testing.T) {
|
|||
|
||||
PushConf.Ios.Enabled = true
|
||||
PushConf.Ios.Production = true
|
||||
PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
|
||||
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
|
||||
InitAPNSClient()
|
||||
|
||||
assert.Equal(t, apns2.HostProduction, ApnsClient.Host)
|
||||
|
|
Loading…
Reference in New Issue