diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index b57de6fcdf..2b27dfb5d6 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -3,7 +3,7 @@ - [ ] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [ ] reference issue for this pull request: - [ ] if you changed anything related how experiments work and you need to reflect these changes in the ooni/spec repository, please link to the related ooni/spec pull request: -- [ ] if you change code inside an experiment, make sure you bump its version number +- [ ] if you changed code inside an experiment, make sure you bump its version number diff --git a/internal/cmd/apitool/main.go b/internal/cmd/apitool/main.go index 320a73a707..fef3dd4750 100644 --- a/internal/cmd/apitool/main.go +++ b/internal/cmd/apitool/main.go @@ -68,8 +68,6 @@ func main() { log.SetLevel(logmap[*debug]) client := newclient() switch *mode { - case "check": - check(client) case "meta": meta(client) case "raw": @@ -79,12 +77,6 @@ func main() { } } -func check(c probeservices.Client) { - found, err := c.CheckReportID(context.Background(), *reportid) - fatalOnError(err, "c.CheckReportID failed") - fmt.Printf("%+v\n", found) -} - func meta(c probeservices.Client) { pprint(mmeta(c, false)) } diff --git a/internal/engine/probeservices/checkreportid.go b/internal/engine/probeservices/checkreportid.go deleted file mode 100644 index 09ed20a5e5..0000000000 --- a/internal/engine/probeservices/checkreportid.go +++ /dev/null @@ -1,26 +0,0 @@ -package probeservices - -import ( - "context" - "net/url" - - "github.com/ooni/probe-cli/v3/internal/httpx" - "github.com/ooni/probe-cli/v3/internal/model" -) - -// CheckReportID checks whether the given ReportID exists. -func (c Client) CheckReportID(ctx context.Context, reportID string) (bool, error) { - query := url.Values{} - query.Add("report_id", reportID) - var response model.OOAPICheckReportIDResponse - err := (&httpx.APIClientTemplate{ - BaseURL: c.BaseURL, - HTTPClient: c.HTTPClient, - Logger: c.Logger, - UserAgent: c.UserAgent, - }).WithBodyLogging().Build().GetJSONWithQuery(ctx, "/api/_/check_report_id", query, &response) - if err != nil { - return false, err - } - return response.Found, nil -} diff --git a/internal/engine/probeservices/checkreportid_test.go b/internal/engine/probeservices/checkreportid_test.go deleted file mode 100644 index 102f36d4cb..0000000000 --- a/internal/engine/probeservices/checkreportid_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package probeservices - -import ( - "context" - "errors" - "net/http" - "testing" - - "github.com/apex/log" - "github.com/ooni/probe-cli/v3/internal/atomicx" - "github.com/ooni/probe-cli/v3/internal/httpx" - "github.com/ooni/probe-cli/v3/internal/kvstore" -) - -func TestCheckReportIDWorkingAsIntended(t *testing.T) { - if testing.Short() { - t.Skip("skip test in short mode") - } - client := Client{ - APIClientTemplate: httpx.APIClientTemplate{ - BaseURL: "https://api.ooni.io/", - HTTPClient: http.DefaultClient, - Logger: log.Log, - UserAgent: "miniooni/0.1.0-dev", - }, - LoginCalls: &atomicx.Int64{}, - RegisterCalls: &atomicx.Int64{}, - StateFile: NewStateFile(&kvstore.Memory{}), - } - reportID := `20201209T052225Z_urlgetter_IT_30722_n1_E1VUhMz08SEkgYFU` - ctx := context.Background() - found, err := client.CheckReportID(ctx, reportID) - if err != nil { - t.Fatal(err) - } - if found != true { - t.Fatal("unexpected found value") - } -} - -func TestCheckReportIDWorkingWithCancelledContext(t *testing.T) { - client := Client{ - APIClientTemplate: httpx.APIClientTemplate{ - BaseURL: "https://api.ooni.io/", - HTTPClient: http.DefaultClient, - Logger: log.Log, - UserAgent: "miniooni/0.1.0-dev", - }, - LoginCalls: &atomicx.Int64{}, - RegisterCalls: &atomicx.Int64{}, - StateFile: NewStateFile(&kvstore.Memory{}), - } - reportID := `20201209T052225Z_urlgetter_IT_30722_n1_E1VUhMz08SEkgYFU` - ctx, cancel := context.WithCancel(context.Background()) - cancel() // fail immediately - found, err := client.CheckReportID(ctx, reportID) - if !errors.Is(err, context.Canceled) { - t.Fatalf("not the error we expected: %+v", err) - } - if found != false { - t.Fatal("unexpected found value") - } -}