1package client
2
3import (
4	"encoding/hex"
5	"github.com/jcmturner/gokrb5/v8/config"
6	"github.com/jcmturner/gokrb5/v8/keytab"
7	"github.com/jcmturner/gokrb5/v8/test"
8	"github.com/jcmturner/gokrb5/v8/test/testdata"
9	"testing"
10)
11
12func TestClient_Login_DNSKDCs(t *testing.T) {
13	test.Privileged(t)
14
15	//ns := os.Getenv("DNSUTILS_OVERRIDE_NS")
16	//if ns == "" {
17	//	os.Setenv("DNSUTILS_OVERRIDE_NS", testdata.TEST_NS)
18	//}
19	c, _ := config.NewFromString(testdata.TEST_KRB5CONF)
20	// Set to lookup KDCs in DNS
21	c.LibDefaults.DNSLookupKDC = true
22	//Blank out the KDCs to ensure they are not being used
23	c.Realms = []config.Realm{}
24
25	b, _ := hex.DecodeString(testdata.TESTUSER1_KEYTAB)
26	kt := keytab.New()
27	kt.Unmarshal(b)
28	cl := NewWithKeytab("testuser1", "TEST.GOKRB5", kt, c)
29
30	err := cl.Login()
31	if err != nil {
32		t.Errorf("error on logging in using DNS lookup of KDCs: %v\n", err)
33	}
34}
35