fixed #91 Remove pem_cert_path config setting.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-05-27 14:53:54 +08:00
parent 137c085560
commit 49c376a765
6 changed files with 18 additions and 22 deletions

View File

@ -48,8 +48,7 @@ android:
ios: ios:
enabled: false enabled: false
pem_cert_path: "cert.pem" pem_path: "key.pem"
pem_key_path: "key.pem"
production: false production: false
log: log:

View File

@ -45,8 +45,7 @@ type SectionAndroid struct {
// SectionIos is sub seciont of config. // SectionIos is sub seciont of config.
type SectionIos struct { type SectionIos struct {
Enabled bool `yaml:"enabled"` Enabled bool `yaml:"enabled"`
PemCertPath string `yaml:"pem_cert_path"` PemPath string `yaml:"pem_path"`
PemKeyPath string `yaml:"pem_key_path"`
Production bool `yaml:"production"` Production bool `yaml:"production"`
} }
@ -106,8 +105,7 @@ func BuildDefaultPushConf() ConfYaml {
// iOS // iOS
conf.Ios.Enabled = false conf.Ios.Enabled = false
conf.Ios.PemCertPath = "cert.pem" conf.Ios.PemPath = "key.pem"
conf.Ios.PemKeyPath = "key.pem"
conf.Ios.Production = false conf.Ios.Production = false
// log // log

View File

@ -20,8 +20,7 @@ android:
ios: ios:
enabled: false enabled: false
pem_cert_path: "cert.pem" pem_path: "key.pem"
pem_key_path: "key.pem"
production: false production: false
log: log:

View File

@ -58,7 +58,7 @@ func main() {
} }
if *certificateKeyPath != "" { if *certificateKeyPath != "" {
gorush.PushConf.Ios.PemKeyPath = *certificateKeyPath gorush.PushConf.Ios.PemPath = *certificateKeyPath
} }
if *apiKey != "" { if *apiKey != "" {

View File

@ -122,7 +122,7 @@ func CheckPushConf() error {
} }
if PushConf.Ios.Enabled { if PushConf.Ios.Enabled {
if PushConf.Ios.PemKeyPath == "" { if PushConf.Ios.PemPath == "" {
return errors.New("Missing iOS certificate path") return errors.New("Missing iOS certificate path")
} }
} }
@ -141,7 +141,7 @@ func InitAPNSClient() error {
if PushConf.Ios.Enabled { if PushConf.Ios.Enabled {
var err error var err error
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemKeyPath, "") CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, "")
if err != nil { if err != nil {
LogError.Error("Cert Error:", err.Error()) LogError.Error("Cert Error:", err.Error())

View File

@ -26,7 +26,7 @@ func TestMissingIOSCertificate(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "" PushConf.Ios.PemPath = ""
err := CheckPushConf() err := CheckPushConf()
@ -53,7 +53,7 @@ func TestCorrectConf(t *testing.T) {
PushConf.Android.APIKey = "xxxxx" PushConf.Android.APIKey = "xxxxx"
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "xxxxx" PushConf.Ios.PemPath = "xxxxx"
err := CheckPushConf() err := CheckPushConf()
@ -221,7 +221,7 @@ func TestPushToIOS(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
InitAppStatus() InitAppStatus()
@ -331,7 +331,7 @@ func TestSenMultipleNotifications(t *testing.T) {
InitWorkers(2, 2) InitWorkers(2, 2)
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
PushConf.Android.Enabled = true PushConf.Android.Enabled = true
@ -364,7 +364,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
PushConf.Android.Enabled = false PushConf.Android.Enabled = false
@ -397,7 +397,7 @@ func TestDisabledIosNotifications(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = false PushConf.Ios.Enabled = false
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
PushConf.Android.Enabled = true PushConf.Android.Enabled = true
@ -430,7 +430,7 @@ func TestMissingIosCertificate(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "test" PushConf.Ios.PemPath = "test"
err := InitAPNSClient() err := InitAPNSClient()
assert.Error(t, err) assert.Error(t, err)
@ -440,7 +440,7 @@ func TestAPNSClientDevHost(t *testing.T) {
PushConf = config.BuildDefaultPushConf() PushConf = config.BuildDefaultPushConf()
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host) assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
@ -451,7 +451,7 @@ func TestAPNSClientProdHost(t *testing.T) {
PushConf.Ios.Enabled = true PushConf.Ios.Enabled = true
PushConf.Ios.Production = true PushConf.Ios.Production = true
PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" PushConf.Ios.PemPath = "../certificate/certificate-valid.pem"
InitAPNSClient() InitAPNSClient()
assert.Equal(t, apns2.HostProduction, ApnsClient.Host) assert.Equal(t, apns2.HostProduction, ApnsClient.Host)