github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/services/openvpn/client_test.go (about) 1 /* 2 * Copyright (C) 2018 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package openvpn 19 20 import ( 21 "context" 22 "testing" 23 24 "github.com/mysteriumnetwork/node/core/connection" 25 "github.com/mysteriumnetwork/node/core/ip" 26 "github.com/mysteriumnetwork/node/identity" 27 "github.com/stretchr/testify/assert" 28 ) 29 30 func fakeSignerFactory(_ identity.Identity) identity.Signer { 31 return &identity.SignerFake{} 32 } 33 34 func TestConnection_ErrorsOnInvalidConfig(t *testing.T) { 35 conn, err := NewClient("./", "./", "./", fakeSignerFactory, ip.NewResolverMock("1.1.1.1")) 36 connectionOptions := connection.ConnectOptions{} 37 assert.Nil(t, err) 38 err = conn.Start(context.Background(), connectionOptions) 39 assert.EqualError(t, err, "failed to unmarshal session config: unexpected end of JSON input") 40 } 41 42 func TestConnection_CreatesConnection(t *testing.T) { 43 conn, err := NewClient("./", "./", "./", fakeSignerFactory, ip.NewResolverMock("1.1.1.1")) 44 assert.Nil(t, err) 45 assert.NotNil(t, conn) 46 }