import Testing @testable import ManaWebShell @Suite("WebShellConfig — Host-Whitelist") struct WebShellConfigTests { private func config(_ hosts: [String]) -> WebShellConfig { WebShellConfig(allowedHosts: hosts, userAgent: "TestNative/0.1") } @Test("Exakter Host matched") func exactMatch() { let c = config(["seepuls.mana.how"]) #expect(c.isAllowed(host: "seepuls.mana.how")) #expect(!c.isAllowed(host: "other.mana.how")) #expect(!c.isAllowed(host: "mana.how")) #expect(!c.isAllowed(host: "evil.com")) } @Test("Wildcard *.root matched Subdomain") func wildcardSubdomain() { let c = config(["*.mana.how"]) #expect(c.isAllowed(host: "seepuls.mana.how")) #expect(c.isAllowed(host: "auth.mana.how")) #expect(c.isAllowed(host: "deep.nested.mana.how")) } @Test("Wildcard *.root matched Root selbst") func wildcardCoversRoot() { let c = config(["*.mana.how"]) #expect(c.isAllowed(host: "mana.how")) } @Test("Wildcard matched nicht andere TLDs") func wildcardScoped() { let c = config(["*.mana.how"]) #expect(!c.isAllowed(host: "mana.com")) #expect(!c.isAllowed(host: "fake-mana.how")) #expect(!c.isAllowed(host: "evil.com")) } @Test("Mehrere Patterns kombinieren") func mixedPatterns() { let c = config(["zitare.com", "www.zitare.com", "*.mana.how"]) #expect(c.isAllowed(host: "zitare.com")) #expect(c.isAllowed(host: "www.zitare.com")) #expect(c.isAllowed(host: "auth.mana.how")) #expect(c.isAllowed(host: "mana.how")) #expect(!c.isAllowed(host: "other.zitare.com")) } @Test("Leere Whitelist verbietet alles") func emptyDenies() { let c = config([]) #expect(!c.isAllowed(host: "anything.com")) } }