You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
873 B
Go
30 lines
873 B
Go
package constraint
|
|
|
|
import (
|
|
"github.com/creekorful/bathyscaphe/internal/configapi/client"
|
|
"github.com/creekorful/bathyscaphe/internal/configapi/client_mock"
|
|
"github.com/golang/mock/gomock"
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckHostnameAllowed(t *testing.T) {
|
|
mockCtrl := gomock.NewController(t)
|
|
defer mockCtrl.Finish()
|
|
|
|
configClientMock := client_mock.NewMockClient(mockCtrl)
|
|
|
|
configClientMock.EXPECT().GetForbiddenHostnames().Return([]client.ForbiddenHostname{
|
|
{Hostname: "google.onion"},
|
|
}, nil)
|
|
if allowed, err := CheckHostnameAllowed(configClientMock, "https://google.onion"); allowed || err != nil {
|
|
t.Fail()
|
|
}
|
|
|
|
configClientMock.EXPECT().GetForbiddenHostnames().Return([]client.ForbiddenHostname{
|
|
{Hostname: "google.onion"},
|
|
}, nil)
|
|
if allowed, err := CheckHostnameAllowed(configClientMock, "https://google2.onion"); !allowed || err != nil {
|
|
t.Fail()
|
|
}
|
|
}
|