Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Waldz committed May 7, 2024
1 parent f6a2603 commit 88356b8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
--filter.zones=api.ipify.org
--exclude.hostnames=ipify.org
ports:
- "8000:8000"
- "8443:8443"

machine:
Expand Down
2 changes: 1 addition & 1 deletion e2e/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func getForwarderIP() (string, error) {
}

func checkIP(apiURL string) (string, error) {
cmd, args := execInTestMachineCmd("curl", "-s", apiURL)
cmd, args := execInTestMachineCmd("curl", "--silent", "--fail", "--max-time", "5", apiURL)
return sh.Output(cmd, args...)
}

Expand Down
20 changes: 19 additions & 1 deletion metrics/service.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
/*
* Copyright (C) 2024 The "MysteriumNetwork/openvpn-forwarder" Authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package metrics

import (
"time"

"github.com/mysteriumnetwork/openvpn-forwarder/proxy"
"github.com/prometheus/client_golang/prometheus"
"time"
)

var _ proxy.Listener = (*Service)(nil)
Expand Down
17 changes: 17 additions & 0 deletions proxy/context.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2024 The "MysteriumNetwork/openvpn-forwarder" Authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package proxy

import (
Expand Down
2 changes: 1 addition & 1 deletion proxy/dialer_http_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Test_dialerHTTPConnect_DialCreatesValidRequest(t *testing.T) {
server.run()
defer server.stop()

dialer := &dialerHTTPConnect{forwardDialer: DialerDirect, forwardAddress: ":6969"}
dialer := &dialerHTTPConnect{forwardDialer: DialerDirect, forwardURL: &url.URL{Host: ":6969"}}
conn, err := dialer.Dial("tcp", "domain.com:80")
assert.NotNil(t, conn)
assert.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func Test_Server_ServeHTTP(t *testing.T) {
upstreamAddr := upstreamServer.run()
defer upstreamServer.stop()

upstreamDialer := NewDialerHTTPConnect(DialerDirect, upstreamAddr, "", "", "")
upstreamDialer := NewDialerHTTPConnect(DialerDirect, &url.URL{Host: upstreamAddr}, "", "", "")

req, _ := http.NewRequest("GET", "http://domain.com", nil)

proxyServer := NewServer(nil, []net.IP{net.ParseIP("::1")}, upstreamDialer, &url.URL{}, &stickyMapperStub{}, &noopTracer{}, nil)
proxyServer := NewServer(nil, []net.IP{net.ParseIP("::1")}, upstreamDialer, &stickyMapperStub{}, &noopTracer{}, nil, nil)
proxyAddr := listenAndServe(proxyServer)

proxyURL, _ := url.Parse("http://" + proxyAddr)
Expand All @@ -63,11 +63,11 @@ func Test_Server_AuthHeaderAdded(t *testing.T) {
upstreamAddr := upstreamServer.run()
defer upstreamServer.stop()

upstreamDialer := NewDialerHTTPConnect(DialerDirect, upstreamAddr, "uuuu", "1234", "")
upstreamDialer := NewDialerHTTPConnect(DialerDirect, &url.URL{Host: upstreamAddr}, "uuuu", "1234", "")

req, _ := http.NewRequest("GET", "http://domain.com", nil)

proxyServer := NewServer(nil, []net.IP{net.ParseIP("::1")}, upstreamDialer, &url.URL{}, &stickyMapperStub{}, &noopTracer{}, nil)
proxyServer := NewServer(nil, []net.IP{net.ParseIP("::1")}, upstreamDialer, &stickyMapperStub{}, &noopTracer{}, nil, nil)
proxyAddr := listenAndServe(proxyServer)

proxyURL, _ := url.Parse("http://" + proxyAddr)
Expand Down

0 comments on commit 88356b8

Please sign in to comment.