Ajout d'un numero identifiable pour pouvoir reproduire une erreur de numéro invalide cote powow #1
This commit is contained in:
@ -28,7 +28,8 @@ type DataConfig struct {
|
||||
}
|
||||
|
||||
type PowowConfig struct {
|
||||
APIKey string `yaml:"apiKey" env:"FAKESMS_POWOW_API_KEY"`
|
||||
APIKey string `yaml:"apiKey" env:"FAKESMS_POWOW_API_KEY"`
|
||||
InvalidPhoneNumber string `yaml:"invalidPhoneNumber" env:"FAKESMS_POWOW_INVALID_PHONE_NUMBER"`
|
||||
}
|
||||
|
||||
type PowowSMS struct {
|
||||
@ -78,7 +79,8 @@ func NewDefault() *Config {
|
||||
Path: "fakesms.db",
|
||||
},
|
||||
Powow: PowowConfig{
|
||||
APIKey: "powow",
|
||||
APIKey: "powow",
|
||||
InvalidPhoneNumber: "33666666666",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -81,16 +81,6 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
//data, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
//if err != nil {
|
||||
// logger.Error(ctx, "could not read body", logger.E(errors.WithStack(err)))
|
||||
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
||||
// return
|
||||
//}
|
||||
//defer r.Body.Close()
|
||||
|
||||
pr := &PowowRequest{
|
||||
Payload: make(map[string]interface{}),
|
||||
}
|
||||
@ -131,26 +121,12 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
pr.Payload = map[string]interface{}{
|
||||
"SmsID": smsid,
|
||||
"MobilePhoneNumber": r.FormValue("MobilePhoneNumber"),
|
||||
"MobilePhoneNumber": strings.TrimSpace(r.FormValue("MobilePhoneNumber")),
|
||||
"TimeToSend": r.FormValue("TimeToSend"),
|
||||
"CustomData": customData,
|
||||
}
|
||||
}
|
||||
|
||||
//if err := json.Unmarshal(data, pr); err != nil {
|
||||
// logger.Error(ctx, "could not parse request", logger.E(errors.WithStack(err)))
|
||||
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
||||
// return
|
||||
//}
|
||||
|
||||
//if err := json.Unmarshal(data, &pr.Payload); err != nil {
|
||||
// logger.Error(ctx, "could not parse request payload", logger.E(errors.WithStack(err)))
|
||||
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
||||
// return
|
||||
//}
|
||||
|
||||
// Authenticate user
|
||||
if conf.Powow.APIKey != pr.APIKey {
|
||||
res := &PowowResponse{
|
||||
@ -163,6 +139,20 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// If phone number must return an error
|
||||
spew.Dump(conf.Powow.InvalidPhoneNumber)
|
||||
spew.Dump(pr.Payload["MobilePhoneNumber"])
|
||||
if conf.Powow.InvalidPhoneNumber == pr.Payload["MobilePhoneNumber"] {
|
||||
res := &PowowResponse{
|
||||
Success: false,
|
||||
ErrorCode: map[int]ErrorCode{0: ErrorCodeTransactionSMSSendInvalidMobilePhoneNumber},
|
||||
}
|
||||
|
||||
sendPowowResponse(w, res)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Handle Powow command
|
||||
switch pr.Command {
|
||||
case CommandTransactionalSMSSend:
|
||||
|
Reference in New Issue
Block a user