authclient: auto-detect https for a bare AUTHGUARD_URL host, extend Java client to full surface
AUTHGUARD_URL only needs to name a host/IP now - all four language clients (Go/Node/Python/Java) assume https:// when no scheme is given, so a bare value like 192.168.1.50:8080 works instead of failing outright; an explicit http://scheme is still left alone for local/LAN deployments. Java's AuthClient was validate-only; it now mirrors the Go/Node/Python clients' full surface (register/login/logout/me/totp*/passwordReset*/ managedUsers*/setupStatus) using Jackson for the request/response JSON this larger surface has to build and parse, since MegaBasterd (this package's only verified consumer) already depends on Jackson.
This commit is contained in:
1 parent
f164e0d0d2
commit
de9b599232
9 files changed
+697
-44
No files matched your search
@@ -8,6 +8,32 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewNormalizesBaseURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
input string
|
||||
want string
|
||||
}{
|
||||
{name: "bare host gets https", input: "auth.example.com", want: "https://auth.example.com"},
|
||||
{name: "bare host:port gets https", input: "192.168.1.50:8080", want: "https://192.168.1.50:8080"},
|
||||
{name: "explicit http is left alone", input: "http://auth.example.com", want: "http://auth.example.com"},
|
||||
{name: "explicit https is left alone", input: "https://auth.example.com", want: "https://auth.example.com"},
|
||||
{name: "scheme match is case-insensitive", input: "HTTP://auth.example.com", want: "HTTP://auth.example.com"},
|
||||
{name: "trailing slash stripped before scheme check", input: "auth.example.com/", want: "https://auth.example.com"},
|
||||
{name: "surrounding whitespace trimmed", input: " auth.example.com ", want: "https://auth.example.com"},
|
||||
{name: "empty stays empty", input: "", want: ""},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
client := New(tc.input)
|
||||
if got := client.baseURL; got != tc.want {
|
||||
t.Fatalf("New(%q).baseURL = %q, want %q", tc.input, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupStatus(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user