diff --git a/example.scrutiny.yaml b/example.scrutiny.yaml index 17e23e6..593d484 100644 --- a/example.scrutiny.yaml +++ b/example.scrutiny.yaml @@ -49,7 +49,7 @@ notify: - "hangouts://chat.googleapis.com/v1/spaces/FOO/messages?key=bar&token=baz" - "zulip://bot-mail:bot-key@zulip-domain/?stream=name-or-id&topic=name" - "join://shoutrrr:api-key@join/?devices=device1[,device2, ...][&icon=icon][&title=title]" - - "script:///file/path/on/disk" #note the triple slashes "script:///" + - "script:///file/path/on/disk" - "https://www.example.com/path" collect: diff --git a/webapp/backend/pkg/notify/notify.go b/webapp/backend/pkg/notify/notify.go index a8f7d98..e2c4876 100644 --- a/webapp/backend/pkg/notify/notify.go +++ b/webapp/backend/pkg/notify/notify.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/AnalogJ/go-util/utils" + "github.com/analogj/go-util/utils" "github.com/analogj/scrutiny/webapp/backend/pkg/config" "github.com/containrrr/shoutrrr" log "github.com/sirupsen/logrus" diff --git a/webapp/backend/pkg/web/server_test.go b/webapp/backend/pkg/web/server_test.go index 1d6d205..785c9ed 100644 --- a/webapp/backend/pkg/web/server_test.go +++ b/webapp/backend/pkg/web/server_test.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/httptest" "os" + "strings" "testing" ) @@ -147,3 +148,25 @@ func TestPopulateMultiple(t *testing.T) { //assert } + +func TestSendTestNotificationRoute(t *testing.T) { + //setup + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + fakeConfig := mock_config.NewMockInterface(mockCtrl) + fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return("testdata/scrutiny_test.db") + fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return("testdata") + fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"}) + ae := web.AppEngine{ + Config: fakeConfig, + } + router := ae.Setup() + + //test + wr := httptest.NewRecorder() + req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}")) + router.ServeHTTP(wr, req) + + //assert + require.Equal(t, 200, wr.Code) +}