cleanup: merge httpheader and httpfailure into model (#758)

These two small packages could easily be merged into the model
package, since they're clearly model-like packages.

Part of https://github.com/ooni/probe/issues/2115
This commit is contained in:
Simone Basso
2022-05-25 09:54:50 +02:00
committed by GitHub
parent 928de50145
commit 2d721baa91
20 changed files with 74 additions and 90 deletions
@@ -13,7 +13,6 @@ import (
"time"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/runtimex"
)
@@ -109,11 +108,11 @@ func (tk *TestKeys) Update(v urlgetter.MultiOutput) {
if failure != nil {
// nothing to do here
} else if v.TestKeys.HTTPResponseStatus != 302 {
failure = &httpfailure.UnexpectedStatusCode
failure = &model.HTTPUnexpectedStatusCode
} else if len(v.TestKeys.HTTPResponseLocations) != 1 {
failure = &httpfailure.UnexpectedRedirectURL
failure = &model.HTTPUnexpectedRedirectURL
} else if v.TestKeys.HTTPResponseLocations[0] != WebHTTPSURL {
failure = &httpfailure.UnexpectedRedirectURL
failure = &model.HTTPUnexpectedRedirectURL
}
tk.WhatsappHTTPFailure = failure
}
@@ -12,7 +12,6 @@ import (
"github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/whatsapp"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure"
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
"github.com/ooni/probe-cli/v3/internal/model"
)
@@ -414,7 +413,7 @@ func TestTestKeysOnlyWebHTTPFailureNo302(t *testing.T) {
if tk.WhatsappEndpointsStatus != "ok" {
t.Fatal("invalid WhatsappEndpointsStatus")
}
if *tk.WhatsappWebFailure != httpfailure.UnexpectedStatusCode {
if *tk.WhatsappWebFailure != model.HTTPUnexpectedStatusCode {
t.Fatal("invalid WhatsappWebFailure")
}
if tk.WhatsappWebStatus != "blocked" {
@@ -459,7 +458,7 @@ func TestTestKeysOnlyWebHTTPFailureNoLocations(t *testing.T) {
if tk.WhatsappEndpointsStatus != "ok" {
t.Fatal("invalid WhatsappEndpointsStatus")
}
if *tk.WhatsappWebFailure != httpfailure.UnexpectedRedirectURL {
if *tk.WhatsappWebFailure != model.HTTPUnexpectedRedirectURL {
t.Fatal("invalid WhatsappWebFailure")
}
if tk.WhatsappWebStatus != "blocked" {
@@ -504,7 +503,7 @@ func TestTestKeysOnlyWebHTTPFailureNotExpectedURL(t *testing.T) {
if tk.WhatsappEndpointsStatus != "ok" {
t.Fatal("invalid WhatsappEndpointsStatus")
}
if *tk.WhatsappWebFailure != httpfailure.UnexpectedRedirectURL {
if *tk.WhatsappWebFailure != model.HTTPUnexpectedRedirectURL {
t.Fatal("invalid WhatsappWebFailure")
}
if tk.WhatsappWebStatus != "blocked" {
@@ -549,7 +548,7 @@ func TestTestKeysOnlyWebHTTPFailureTooManyURLs(t *testing.T) {
if tk.WhatsappEndpointsStatus != "ok" {
t.Fatal("invalid WhatsappEndpointsStatus")
}
if *tk.WhatsappWebFailure != httpfailure.UnexpectedRedirectURL {
if *tk.WhatsappWebFailure != model.HTTPUnexpectedRedirectURL {
t.Fatal("invalid WhatsappWebFailure")
}
if tk.WhatsappWebStatus != "blocked" {