Skip to content

Commit

Permalink
Fix tests broken by f285be5
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Nov 11, 2024
1 parent 2c96d5c commit b649bf4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
47 changes: 27 additions & 20 deletions psiphon/common/inproxy/inproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,29 @@ func runTestInproxy(doMustUpgrade bool) error {
return errors.Trace(err)
}

// API parameter handlers

apiParameterValidator := func(params common.APIParameters) error {
if len(params) != len(baseAPIParameters) {
return errors.TraceNew("unexpected base API parameter count")
}
for name, value := range params {
if value.(string) != baseAPIParameters[name].(string) {
return errors.Tracef(
"unexpected base API parameter: %v: %v != %v",
name,
value.(string),
baseAPIParameters[name].(string))
}
}
return nil
}

apiParameterLogFieldFormatter := func(
_ string, _ common.GeoIPData, params common.APIParameters) common.LogFields {
return common.LogFields(params)
}

// Start broker

logger.WithTrace().Info("START BROKER")
Expand Down Expand Up @@ -231,26 +254,9 @@ func runTestInproxy(doMustUpgrade bool) error {

CommonCompartmentIDs: testCommonCompartmentIDs,

APIParameterValidator: func(params common.APIParameters) error {
if len(params) != len(baseAPIParameters) {
return errors.TraceNew("unexpected base API parameter count")
}
for name, value := range params {
if value.(string) != baseAPIParameters[name].(string) {
return errors.Tracef(
"unexpected base API parameter: %v: %v != %v",
name,
value.(string),
baseAPIParameters[name].(string))
}
}
return nil
},
APIParameterValidator: apiParameterValidator,

APIParameterLogFieldFormatter: func(
geoIPData common.GeoIPData, params common.APIParameters) common.LogFields {
return common.LogFields(params)
},
APIParameterLogFieldFormatter: apiParameterLogFieldFormatter,

GetTacticsPayload: func(_ common.GeoIPData, _ common.APIParameters) ([]byte, string, error) {
// Exercise both new and unchanged tactics
Expand Down Expand Up @@ -297,7 +303,8 @@ func runTestInproxy(doMustUpgrade bool) error {
// handler into the destination echo server)

serverSessions, err := NewServerBrokerSessions(
serverPrivateKey, serverRootObfuscationSecret, []SessionPublicKey{brokerPublicKey})
serverPrivateKey, serverRootObfuscationSecret, []SessionPublicKey{brokerPublicKey},
apiParameterValidator, apiParameterLogFieldFormatter, "")
if err != nil {
return errors.Trace(err)
}
Expand Down
6 changes: 2 additions & 4 deletions psiphon/common/inproxy/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,7 @@ func BenchmarkMatcherQueue(b *testing.B) {
NATType: NATTypePortRestrictedCone,
PortMappingTypes: []PortMappingType{},
},
ProxyID: ID{},
ProxyProtocolVersion: ProxyProtocolVersion1,
ProxyID: ID{},
},
offerChan: make(chan *MatchOffer, 1),
}
Expand Down Expand Up @@ -1102,8 +1101,7 @@ func BenchmarkMatcherQueue(b *testing.B) {
NATType: NATTypePortRestrictedCone,
PortMappingTypes: []PortMappingType{},
},
ProxyID: ID{},
ProxyProtocolVersion: ProxyProtocolVersion1,
ProxyID: ID{},
},
offerChan: make(chan *MatchOffer, 1),
}
Expand Down
3 changes: 2 additions & 1 deletion psiphon/common/tactics/tactics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ func TestTactics(t *testing.T) {
}

formatter := func(
geoIPData common.GeoIPData,
_ string,
_ common.GeoIPData,
apiParams common.APIParameters) common.LogFields {

return common.LogFields(apiParams)
Expand Down

0 comments on commit b649bf4

Please sign in to comment.