|
|
|
@ -69,7 +69,7 @@ func TestHandleMessageForbiddenExtensions(t *testing.T) {
|
|
|
|
|
subscriberMock := event_mock.NewMockSubscriber(mockCtrl)
|
|
|
|
|
configClientMock := client_mock.NewMockClient(mockCtrl)
|
|
|
|
|
|
|
|
|
|
urls := []string{"https://example.onion/image.png?id=12&test=2", "https://example.onion/image.PNG"}
|
|
|
|
|
urls := []string{"https://example.onion/image.PNG?id=12&test=2", "https://example.onion/favicon.ico"}
|
|
|
|
|
|
|
|
|
|
for _, url := range urls {
|
|
|
|
|
msg := event.RawMessage{}
|
|
|
|
@ -78,7 +78,7 @@ func TestHandleMessageForbiddenExtensions(t *testing.T) {
|
|
|
|
|
SetArg(1, event.FoundURLEvent{URL: url}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenMimeTypes().Return([]client.MimeType{{Extensions: []string{"png"}}}, nil)
|
|
|
|
|
configClientMock.EXPECT().GetAllowedMimeTypes().Return([]client.MimeType{{Extensions: []string{"php", "html"}}}, nil)
|
|
|
|
|
|
|
|
|
|
s := State{
|
|
|
|
|
configClient: configClientMock,
|
|
|
|
@ -128,7 +128,7 @@ func TestHandleMessageHostnameForbidden(t *testing.T) {
|
|
|
|
|
SetArg(1, event.FoundURLEvent{URL: test.url}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenMimeTypes().Return([]client.MimeType{}, nil)
|
|
|
|
|
configClientMock.EXPECT().GetAllowedMimeTypes().Return([]client.MimeType{{Extensions: []string{"png", "php"}}}, nil)
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenHostnames().Return(test.forbiddenHostnames, nil)
|
|
|
|
|
|
|
|
|
|
s := State{
|
|
|
|
@ -148,24 +148,29 @@ func TestHandleMessage(t *testing.T) {
|
|
|
|
|
subscriberMock := event_mock.NewMockSubscriber(mockCtrl)
|
|
|
|
|
configClientMock := client_mock.NewMockClient(mockCtrl)
|
|
|
|
|
|
|
|
|
|
msg := event.RawMessage{}
|
|
|
|
|
subscriberMock.EXPECT().
|
|
|
|
|
Read(&msg, &event.FoundURLEvent{}).
|
|
|
|
|
SetArg(1, event.FoundURLEvent{URL: "https://www.facebookcorewwwi.onion/recover/initiate?ars=facebook_login"}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
urls := []string{"https://example.onion/index.php", "http://google.onion/admin/login.html",
|
|
|
|
|
"https://example.onion", "https://www.facebookcorewwwi.onion/recover/initiate?ars=facebook_login"}
|
|
|
|
|
|
|
|
|
|
subscriberMock.EXPECT().
|
|
|
|
|
PublishEvent(&event.NewURLEvent{URL: "https://www.facebookcorewwwi.onion/recover/initiate?ars=facebook_login"}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
for _, u := range urls {
|
|
|
|
|
msg := event.RawMessage{}
|
|
|
|
|
subscriberMock.EXPECT().
|
|
|
|
|
Read(&msg, &event.FoundURLEvent{}).
|
|
|
|
|
SetArg(1, event.FoundURLEvent{URL: u}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenMimeTypes().Return([]client.MimeType{}, nil)
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenHostnames().Return([]client.ForbiddenHostname{}, nil)
|
|
|
|
|
subscriberMock.EXPECT().
|
|
|
|
|
PublishEvent(&event.NewURLEvent{URL: u}).
|
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
|
|
s := State{
|
|
|
|
|
configClient: configClientMock,
|
|
|
|
|
}
|
|
|
|
|
configClientMock.EXPECT().GetAllowedMimeTypes().Return([]client.MimeType{{Extensions: []string{"html", "php"}}}, nil)
|
|
|
|
|
configClientMock.EXPECT().GetForbiddenHostnames().Return([]client.ForbiddenHostname{}, nil)
|
|
|
|
|
|
|
|
|
|
s := State{
|
|
|
|
|
configClient: configClientMock,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := s.handleURLFoundEvent(subscriberMock, msg); err != nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
if err := s.handleURLFoundEvent(subscriberMock, msg); err != nil {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|