Skip to content

Commit 1ff4081

Browse files
committed
Merge branch 'master' into riseup_tests_improvements
2 parents 1fca652 + 4828c58 commit 1ff4081

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

internal/experiment/riseupvpn/riseupvpn.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const (
2323
tcpConnect = "tcpconnect://"
2424
)
2525

26-
// EipServiceV3 is the main JSON object of eip-service.json.
27-
type EipServiceV3 struct {
26+
// EIPServiceV3 is the main JSON object returned by eip-service.json.
27+
type EIPServiceV3 struct {
2828
Gateways []GatewayV3
2929
}
3030

@@ -38,7 +38,6 @@ type GatewayV3 struct {
3838
Capabilities CapabilitiesV3
3939
Host string
4040
IPAddress string `json:"ip_address"`
41-
Location string `json:"location"`
4241
}
4342

4443
// TransportV3 describes a transport.
@@ -204,7 +203,6 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
204203
NoTLSVerify: !testkeys.CACertStatus,
205204
}},
206205
}
207-
208206
for entry := range multi.CollectOverall(ctx, inputs, 1, 20, "riseupvpn", callbacks) {
209207
testkeys.UpdateProviderAPITestKeys(entry)
210208
}
@@ -238,6 +236,7 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
238236
// TODO(bassosimone): when urlgetter is able to do obfs4 handshakes, here
239237
// can possibly also test for the obfs4 handshake.
240238
// See https://github.com/ooni/probe/issues/1463.
239+
startCount += len(openvpnEndpoints)
241240
for entry := range multi.CollectOverall(
242241
ctx, obfs4Endpoints, startCount, overallCount, "riseupvpn", callbacks) {
243242
testkeys.AddGatewayConnectTestKeys(entry, "obfs4")
@@ -282,7 +281,7 @@ func parseGateways(testKeys *TestKeys) []GatewayV3 {
282281
// TODO(bassosimone,cyberta): is it reasonable that we discard
283282
// the error when the JSON we fetched cannot be parsed?
284283
// See https://github.com/ooni/probe/issues/1432
285-
eipService, err := DecodeEIP3(string(requestEntry.Response.Body))
284+
eipService, err := DecodeEIPServiceV3(string(requestEntry.Response.Body))
286285
if err == nil {
287286
return eipService.Gateways
288287
}
@@ -363,9 +362,9 @@ func (geoService *GeoService) isHealthyGateway(gateway GatewayV3) bool {
363362
return false
364363
}
365364

366-
// DecodeEIP3 decodes eip-service.json version 3
367-
func DecodeEIP3(body string) (*EipServiceV3, error) {
368-
var eip EipServiceV3
365+
// DecodeEIPServiceV3 decodes eip-service.json version 3
366+
func DecodeEIPServiceV3(body string) (*EIPServiceV3, error) {
367+
var eip EIPServiceV3
369368
err := json.Unmarshal([]byte(body), &eip)
370369
if err != nil {
371370
return nil, err

internal/experiment/riseupvpn/riseupvpn_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,29 @@ func TestFailureGateway1TransportNOK(t *testing.T) {
497497
}
498498
}
499499

500-
func TestIgnoreOverloadedGateways(t *testing.T) {
501-
eipService, err := riseupvpn.DecodeEIP3(eipservice)
500+
func TestFailureTransport(t *testing.T) {
501+
measurement := runDefaultMockTest(t, generateDefaultMockGetter(map[string]bool{
502+
cacerturl: true,
503+
eipserviceurl: true,
504+
providerurl: true,
505+
geoserviceurl: true,
506+
openvpnurl1: false,
507+
openvpnurl2: false,
508+
obfs4url1: false,
509+
}))
510+
tk := measurement.TestKeys.(*riseupvpn.TestKeys)
511+
512+
if tk.TransportStatus == nil || tk.TransportStatus["openvpn"] != "blocked" {
513+
t.Fatal("invalid TransportStatus: " + fmt.Sprint(tk.TransportStatus))
514+
}
515+
516+
if tk.TransportStatus == nil || tk.TransportStatus["obfs4"] != "blocked" {
517+
t.Fatal("invalid TransportStatus: " + fmt.Sprint(tk.TransportStatus))
518+
}
519+
}
520+
521+
func TestMissingTransport(t *testing.T) {
522+
eipService, err := riseupvpn.DecodeEIPServiceV3(eipservice)
502523
if err != nil {
503524
t.Fatal("Preconditions for the test are not met.")
504525
}

0 commit comments

Comments
 (0)