4
4
"testing"
5
5
6
6
"github.com/stackup-app/stackup/lib/gateway"
7
+ "github.com/stackup-app/stackup/lib/settings"
7
8
"github.com/stretchr/testify/assert"
8
9
)
9
10
@@ -23,6 +24,49 @@ func TestGatewayDisable(t *testing.T) {
23
24
24
25
func TestGatewayAllowed (t * testing.T ) {
25
26
g := gateway .New ([]string {}, []string {"*.example.com" , "*.one.example.net" , "api.**.com" }, []string {}, []string {})
27
+ verifyChecksums := true
28
+ enableStats := false
29
+ gatewayAllow := "allow"
30
+ s := & settings.Settings {
31
+ AnonymousStatistics : & enableStats ,
32
+ DotEnvFiles : []string {".env" },
33
+ Cache : & settings.WorkflowSettingsCache {TtlMinutes : 15 },
34
+ ChecksumVerification : & verifyChecksums ,
35
+ Domains : & settings.WorkflowSettingsDomains {
36
+ Allowed : []string {"*.example.com" , "*.one.example.net" , "api.**.com" },
37
+ Hosts : []settings.WorkflowSettingsDomainsHosts {
38
+ {Hostname : "raw.githubusercontent.com" , Gateway : & gatewayAllow , Headers : nil },
39
+ {Hostname : "api.github.com" , Gateway : & gatewayAllow , Headers : nil },
40
+ },
41
+ },
42
+ Defaults : & settings.WorkflowSettingsDefaults {
43
+ Tasks : & settings.WorkflowSettingsDefaultsTasks {
44
+ Silent : false ,
45
+ Path : "./" ,
46
+ Platforms : []string {"windows" , "linux" , "darwin" },
47
+ },
48
+ },
49
+ Gateway : & settings.WorkflowSettingsGateway {
50
+ ContentTypes : & settings.GatewayContentTypes {
51
+ Blocked : []string {},
52
+ Allowed : []string {"*" },
53
+ },
54
+ FileExtensions : & settings.WorkflowSettingsGatewayFileExtensions {
55
+ Allow : []string {"*" },
56
+ Block : []string {},
57
+ },
58
+ Middleware : []string {},
59
+ },
60
+ Notifications : & settings.WorkflowSettingsNotifications {
61
+ Telegram : & settings.WorkflowSettingsNotificationsTelegram {
62
+ APIKey : "" ,
63
+ ChatIds : []string {},
64
+ },
65
+ },
66
+ }
67
+ gateway .GatewayMiddleware .AddPreMiddleware (& gateway .ValidateUrlMiddleware )
68
+
69
+ g .Initialize (s , nil , nil )
26
70
assert .True (t , g .Allowed ("https://www.example.com" ), "www.example.com should be allowed" )
27
71
assert .True (t , g .Allowed ("https://example.com" ), "example.com should be allowed" )
28
72
assert .False (t , g .Allowed ("https://www.example.net" ), "www.example.net should not be allowed" )
0 commit comments