2019-12-02 16:59:37 +01:00
|
|
|
package nettests
|
2018-03-21 12:18:45 +01:00
|
|
|
|
|
|
|
// WhatsApp test implementation
|
|
|
|
type WhatsApp struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run starts the test
|
2019-12-02 16:59:37 +01:00
|
|
|
func (h WhatsApp) Run(ctl *Controller) error {
|
2020-06-04 11:19:38 +02:00
|
|
|
builder, err := ctl.Session.NewExperimentBuilder(
|
2019-10-28 14:05:05 +01:00
|
|
|
"whatsapp",
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return ctl.Run(builder, []string{""})
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// WhatsAppTestKeys for the test
|
|
|
|
type WhatsAppTestKeys struct {
|
|
|
|
RegistrationServerBlocking bool `json:"registration_server_blocking"`
|
|
|
|
WebBlocking bool `json:"whatsapp_web_blocking"`
|
|
|
|
EndpointsBlocking bool `json:"whatsapp_endpoints_blocking"`
|
|
|
|
IsAnomaly bool `json:"-"`
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// GetTestKeys generates a summary for a test run
|
2018-09-27 11:40:57 +02:00
|
|
|
func (h WhatsApp) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
2018-03-23 15:22:58 +01:00
|
|
|
var (
|
|
|
|
webBlocking bool
|
|
|
|
registrationBlocking bool
|
|
|
|
endpointsBlocking bool
|
|
|
|
)
|
|
|
|
|
|
|
|
var computeBlocking = func(key string) bool {
|
|
|
|
const blk = "blocked"
|
|
|
|
if tk[key] == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if tk[key].(string) == blk {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
registrationBlocking = computeBlocking("registration_server_status")
|
|
|
|
webBlocking = computeBlocking("whatsapp_web_status")
|
|
|
|
endpointsBlocking = computeBlocking("whatsapp_endpoints_status")
|
2018-03-21 12:18:45 +01:00
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
return WhatsAppTestKeys{
|
2018-03-23 15:22:58 +01:00
|
|
|
RegistrationServerBlocking: registrationBlocking,
|
|
|
|
WebBlocking: webBlocking,
|
|
|
|
EndpointsBlocking: endpointsBlocking,
|
2018-09-10 12:41:28 +02:00
|
|
|
IsAnomaly: registrationBlocking || webBlocking || endpointsBlocking,
|
2018-09-27 11:40:57 +02:00
|
|
|
}, nil
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// LogSummary writes the summary to the standard output
|
|
|
|
func (h WhatsApp) LogSummary(s string) error {
|
|
|
|
return nil
|
|
|
|
}
|