mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 17:40:28 +00:00
feat: move native communication to FFI (#1457)
This commit is contained in:
86 files changed
+4558
-886
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestStartConfigValidateWebAPIToken(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config *StartConfig
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "web API token without web auth",
|
||||
config: &StartConfig{WebEnable: true, ApiToken: "token"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "web API token with web auth",
|
||||
config: &StartConfig{
|
||||
WebEnable: true,
|
||||
ApiToken: "token",
|
||||
WebAuth: &WebAuth{
|
||||
Username: "admin",
|
||||
Password: "secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "web without authentication",
|
||||
config: &StartConfig{WebEnable: true},
|
||||
},
|
||||
{
|
||||
name: "native REST API token",
|
||||
config: &StartConfig{NativeMode: true, ApiToken: "token"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.config.Validate()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("Validate() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user