@@ -3,6 +3,7 @@ package hoverclient
33import (
44 "context"
55 "os"
6+ "sort"
67 "strings"
78 "testing"
89)
@@ -26,6 +27,61 @@ func TestLiveBrowserLoginAndHTTPReuseProbe(t *testing.T) {
2627 t .Logf ("go_http_reuse_viable=%t domains=%d clearance_cookies=%v" , result .GoHTTPReuseViable , result .DomainCount , result .ClearanceCookieNames ())
2728}
2829
30+ func TestLiveSetNameserversNoop (t * testing.T ) {
31+ if os .Getenv ("HOVER_LIVE_TEST" ) != "1" {
32+ t .Skip ("set HOVER_LIVE_TEST=1 to run live Hover browser write probe" )
33+ }
34+ domain := strings .TrimSpace (os .Getenv ("HOVER_LIVE_NS_DOMAIN" ))
35+ if domain == "" {
36+ t .Skip ("set HOVER_LIVE_NS_DOMAIN to the disposable Hover domain to test" )
37+ }
38+ wantNS := splitLiveNameservers (os .Getenv ("HOVER_LIVE_NS_EXPECTED" ))
39+ if len (wantNS ) == 0 {
40+ t .Fatal ("set HOVER_LIVE_NS_EXPECTED to the current nameservers, comma-separated" )
41+ }
42+
43+ ctx := context .Background ()
44+ creds := liveCredentialsFromEnv (t )
45+ opts := liveBrowserOptionsFromEnv (t )
46+ c , err := NewClientWithOptions (creds , nil , ClientOptions {Browser : opts })
47+ if err != nil {
48+ t .Fatalf ("NewClientWithOptions: %v" , err )
49+ }
50+
51+ domains , err := c .ListDomains (ctx )
52+ if err != nil {
53+ t .Fatalf ("ListDomains before write: %v" , err )
54+ }
55+ var found bool
56+ for _ , d := range domains {
57+ if strings .EqualFold (d .Name , domain ) {
58+ found = true
59+ assertNameserversMatch (t , "ListDomains nameservers" , d .Nameservers , wantNS )
60+ break
61+ }
62+ }
63+ if ! found {
64+ t .Fatalf ("domain %q not found in Hover account" , domain )
65+ }
66+
67+ before , err := c .GetDomainDelegation (ctx , domain )
68+ if err != nil {
69+ t .Fatalf ("GetDomainDelegation before write: %v" , err )
70+ }
71+ assertNameserversMatch (t , "delegation before write" , before .Nameservers , wantNS )
72+
73+ if err := c .SetNameservers (ctx , domain , wantNS ); err != nil {
74+ t .Fatalf ("SetNameservers no-op write: %v" , err )
75+ }
76+
77+ after , err := c .GetDomainDelegation (ctx , domain )
78+ if err != nil {
79+ t .Fatalf ("GetDomainDelegation after write: %v" , err )
80+ }
81+ assertNameserversMatch (t , "delegation after write" , after .Nameservers , wantNS )
82+ t .Logf ("SetNameservers no-op write succeeded for %s with %s" , domain , strings .Join (wantNS , "," ))
83+ }
84+
2985func liveCredentialsFromEnv (t * testing.T ) Credentials {
3086 t .Helper ()
3187 var missing []string
@@ -51,6 +107,43 @@ func liveCredentialsFromEnv(t *testing.T) Credentials {
51107 return Credentials {Username : username , Password : password , TOTPSecret : totp }
52108}
53109
110+ func splitLiveNameservers (raw string ) []string {
111+ var out []string
112+ for _ , part := range strings .Split (raw , "," ) {
113+ ns := strings .Trim (strings .TrimSpace (part ), "." )
114+ if ns != "" {
115+ out = append (out , strings .ToLower (ns ))
116+ }
117+ }
118+ return out
119+ }
120+
121+ func assertNameserversMatch (t * testing.T , label string , got , want []string ) {
122+ t .Helper ()
123+ gotNorm := normalizeNameservers (got )
124+ wantNorm := normalizeNameservers (want )
125+ if len (gotNorm ) != len (wantNorm ) {
126+ t .Fatalf ("%s = %v, want %v" , label , gotNorm , wantNorm )
127+ }
128+ for i := range wantNorm {
129+ if gotNorm [i ] != wantNorm [i ] {
130+ t .Fatalf ("%s = %v, want %v" , label , gotNorm , wantNorm )
131+ }
132+ }
133+ }
134+
135+ func normalizeNameservers (ns []string ) []string {
136+ out := make ([]string , 0 , len (ns ))
137+ for _ , item := range ns {
138+ trimmed := strings .Trim (strings .TrimSpace (item ), "." )
139+ if trimmed != "" {
140+ out = append (out , strings .ToLower (trimmed ))
141+ }
142+ }
143+ sort .Strings (out )
144+ return out
145+ }
146+
54147func liveBrowserOptionsFromEnv (t * testing.T ) BrowserOptions {
55148 t .Helper ()
56149 opts , err := BrowserOptionsFromEnv ()
0 commit comments