mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-10-08 08:21:12 +02:00
added script support in aitm proxy for setting dynamic upstream proxy
Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
10 files changed
+276
-12
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package service
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestValidateSessionScript checks that a config naming a session script is
|
||||
// only accepted when the Scripts feature is enabled on the instance.
|
||||
func TestValidateSessionScript(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
script string
|
||||
enabled bool
|
||||
wantErr bool
|
||||
}{
|
||||
{"empty script, feature off", "", false, false},
|
||||
{"empty script, feature on", "", true, false},
|
||||
{"whitespace script, feature off", " ", false, false},
|
||||
{"script set, feature on", "pick-proxy", true, false},
|
||||
{"script set, feature off", "pick-proxy", false, true},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
m := &Proxy{ScriptEnabled: tc.enabled}
|
||||
err := m.validateSessionScript(&ProxyServiceConfigYAML{Script: tc.script})
|
||||
if tc.wantErr && err == nil {
|
||||
t.Fatal("expected an error, got nil")
|
||||
}
|
||||
if !tc.wantErr && err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user