feat(sources): add managed RSS feeds (#41)
This commit is contained in:
28
backend/internal/sourcefeeds/config_test.go
Normal file
28
backend/internal/sourcefeeds/config_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package sourcefeeds
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAdminAndRuntimeUseClosedSourceSpecificFeedAllowlist(t *testing.T) {
|
||||
for _, source := range []string{Bloomberg, Investing} {
|
||||
defaults := Defaults(source)
|
||||
if _, err := Validate(source, defaults); err != nil {
|
||||
t.Fatal("approved defaults rejected")
|
||||
}
|
||||
for _, bad := range [][]string{nil, {""}, {"http://" + Host + "/feed/investing-news.xml"}, {"https://127.0.0.1/feed/investing-news.xml"}, {"https://" + Host + ".evil.invalid/feed/investing-news.xml"}, {"https://user:secret@" + Host + "/feed/investing-news.xml"}, {"https://" + Host + ":444/feed/investing-news.xml"}, {"https://" + Host + "/feed/unknown.xml"}, {defaults[0] + "?key=secret"}, {defaults[0] + "#"}, {defaults[0], defaults[0]}, {"https://" + Host + "/feed/%69nvesting-news.xml"}} {
|
||||
if _, err := Validate(source, bad); err != ErrInvalid {
|
||||
t.Fatal("invalid source feed configuration accepted")
|
||||
}
|
||||
}
|
||||
}
|
||||
if _, err := Validate(Bloomberg, Defaults(Investing)); err != ErrInvalid {
|
||||
t.Fatal("cross-source feed accepted")
|
||||
}
|
||||
if _, err := Validate("yahoo_finance", Defaults(Investing)); err != ErrUnsupported {
|
||||
t.Fatal("non-RSS source accepted feed mutation")
|
||||
}
|
||||
original := Defaults(Bloomberg)
|
||||
original[0] = "private"
|
||||
if Defaults(Bloomberg)[0] == "private" {
|
||||
t.Fatal("mutable allowlist")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user