Support new Apple Token Based Authentication (JWT) (#300)
* Support new Apple Token Based Authentication (JWT) Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix testing Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -56,6 +56,8 @@ ios:
|
||||
password: "" # certificate password, default as empty string.
|
||||
production: false
|
||||
max_retry: 0 # resend fail notification, default value zero is disabled
|
||||
key_id: "" # KeyID from developer account (Certificates, Identifiers & Profiles -> Keys)
|
||||
team_id: "" # TeamID from developer account (View Account -> Membership)
|
||||
|
||||
log:
|
||||
format: "string" # string or json
|
||||
@@ -140,6 +142,8 @@ type SectionIos struct {
|
||||
Password string `yaml:"password"`
|
||||
Production bool `yaml:"production"`
|
||||
MaxRetry int `yaml:"max_retry"`
|
||||
KeyID string `yaml:"key_id"`
|
||||
TeamID string `yaml:"team_id"`
|
||||
}
|
||||
|
||||
// SectionLog is sub section of config.
|
||||
@@ -269,6 +273,8 @@ func LoadConf(confPath string) (ConfYaml, error) {
|
||||
conf.Ios.Password = viper.GetString("ios.password")
|
||||
conf.Ios.Production = viper.GetBool("ios.production")
|
||||
conf.Ios.MaxRetry = viper.GetInt("ios.max_retry")
|
||||
conf.Ios.KeyID = viper.GetString("ios.key_id")
|
||||
conf.Ios.TeamID = viper.GetString("ios.team_id")
|
||||
|
||||
// log
|
||||
conf.Log.Format = viper.GetString("log.format")
|
||||
|
||||
@@ -43,6 +43,8 @@ ios:
|
||||
password: "" # certificate password, default as empty string.
|
||||
production: false
|
||||
max_retry: 0 # resend fail notification, default value zero is disabled
|
||||
key_id: "" # KeyID from developer account (Certificates, Identifiers & Profiles -> Keys)
|
||||
team_id: "" # TeamID from developer account (View Account -> Membership)
|
||||
|
||||
log:
|
||||
format: "string" # string or json
|
||||
|
||||
@@ -76,6 +76,8 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.Password)
|
||||
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Production)
|
||||
assert.Equal(suite.T(), 0, suite.ConfGorushDefault.Ios.MaxRetry)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.KeyID)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.TeamID)
|
||||
|
||||
// log
|
||||
assert.Equal(suite.T(), "string", suite.ConfGorushDefault.Log.Format)
|
||||
@@ -141,6 +143,8 @@ func (suite *ConfigTestSuite) TestValidateConf() {
|
||||
assert.Equal(suite.T(), "", suite.ConfGorush.Ios.Password)
|
||||
assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Production)
|
||||
assert.Equal(suite.T(), 0, suite.ConfGorush.Ios.MaxRetry)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorush.Ios.KeyID)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorush.Ios.TeamID)
|
||||
|
||||
// log
|
||||
assert.Equal(suite.T(), "string", suite.ConfGorush.Log.Format)
|
||||
@@ -174,6 +178,8 @@ func TestLoadConfigFromEnv(t *testing.T) {
|
||||
os.Setenv("GORUSH_CORE_PORT", "9001")
|
||||
os.Setenv("GORUSH_GRPC_ENABLED", "true")
|
||||
os.Setenv("GORUSH_CORE_MAX_NOTIFICATION", "200")
|
||||
os.Setenv("GORUSH_IOS_KEY_ID", "ABC123DEFG")
|
||||
os.Setenv("GORUSH_IOS_TEAM_ID", "DEF123GHIJ")
|
||||
ConfGorush, err := LoadConf("config.yml")
|
||||
if err != nil {
|
||||
panic("failed to load config.yml from file")
|
||||
@@ -181,4 +187,6 @@ func TestLoadConfigFromEnv(t *testing.T) {
|
||||
assert.Equal(t, "9001", ConfGorush.Core.Port)
|
||||
assert.Equal(t, int64(200), ConfGorush.Core.MaxNotification)
|
||||
assert.True(t, ConfGorush.GRPC.Enabled)
|
||||
assert.Equal(t, "ABC123DEFG", ConfGorush.Ios.KeyID)
|
||||
assert.Equal(t, "DEF123GHIJ", ConfGorush.Ios.TeamID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user