client_dns_test.go 879 B

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