-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apiserver/apiclient: unix socket support
- Loading branch information
Showing
18 changed files
with
476 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,5 @@ msi | |
__pycache__ | ||
*.py[cod] | ||
*.egg-info | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/crowdsecurity/crowdsec/pkg/csconfig" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestPrepareApiURL_NoProtocol(t *testing.T) { | ||
url, err := prepareApiURL(nil, "localhost:81") | ||
require.NoError(t, err) | ||
assert.Equal(t, "http://localhost:81/", url.String()) | ||
} | ||
|
||
func TestPrepareApiURL_Http(t *testing.T) { | ||
url, err := prepareApiURL(nil, "http://localhost:81") | ||
require.NoError(t, err) | ||
assert.Equal(t, "http://localhost:81/", url.String()) | ||
} | ||
|
||
func TestPrepareApiURL_Https(t *testing.T) { | ||
url, err := prepareApiURL(nil, "https://localhost:81") | ||
require.NoError(t, err) | ||
assert.Equal(t, "https://localhost:81/", url.String()) | ||
} | ||
|
||
func TestPrepareApiURL_UnixSocket(t *testing.T) { | ||
url, err := prepareApiURL(nil, "/path/socket") | ||
require.NoError(t, err) | ||
assert.Equal(t, "/path/socket/", url.String()) | ||
} | ||
|
||
func TestPrepareApiURL_Empty(t *testing.T) { | ||
_, err := prepareApiURL(nil, "") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestPrepareApiURL_Empty_ConfigOverride(t *testing.T) { | ||
url, err := prepareApiURL(&csconfig.LocalApiClientCfg{ | ||
Credentials: &csconfig.ApiCredentialsCfg{ | ||
URL: "localhost:80", | ||
}, | ||
}, "") | ||
require.NoError(t, err) | ||
assert.Equal(t, "http://localhost:80/", url.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.