Jonathan Turner 8 лет назад
Родитель
Сommit
8a0368879e

+ 28 - 0
client/client_integration_test.go

@@ -11,7 +11,9 @@ import (
 	"os"
 	"os/exec"
 	"os/user"
+	"runtime"
 	"testing"
+	"time"
 
 	"errors"
 	"fmt"
@@ -652,3 +654,29 @@ func TestClient_ChangePasswd(t *testing.T) {
 	}
 	assert.True(t, ok, "password was not changed back")
 }
+
+func TestClient_AutoRenew_Goroutine_Count(t *testing.T) {
+	// Tests that the auto renew of client credentials is not spawning goroutines out of control.
+	addr := os.Getenv("TEST_KDC_ADDR")
+	if addr == "" {
+		addr = testdata.TEST_KDC_ADDR
+	}
+	b, err := hex.DecodeString(testdata.TESTUSER1_KEYTAB)
+	kt, _ := keytab.Parse(b)
+	c, _ := config.NewConfigFromString(testdata.TEST_KRB5CONF)
+	c.Realms[0].KDC = []string{addr + ":" + testdata.TEST_KDC}
+	cl := NewClientWithKeytab("testuser1", "TEST.GOKRB5", kt)
+	cl.WithConfig(c)
+
+	err = cl.Login()
+	if err != nil {
+		t.Errorf("error on logging in: %v\n", err)
+	}
+	n := runtime.NumGoroutine()
+	for i := 0; i < 6; i++ {
+		time.Sleep(time.Second * 20)
+		if runtime.NumGoroutine() > n {
+			t.Fatalf("number of goroutines is increasing: should not be more than %d, is %d", n, runtime.NumGoroutine())
+		}
+	}
+}

+ 2 - 2
testenv/docker/krb5kdc/kdc.conf

@@ -5,8 +5,8 @@
 [realms]
  TEST.GOKRB5 = {
   master_key_type = aes256-cts-hmac-sha1-96
-  max_life = 12h 0m 0s
-  max_renewable_life = 7d 0h 0m 0s
+  max_life = 20s
+  max_renewable_life = 55s
   acl_file = /var/kerberos/krb5kdc/kadm5.acl
   dict_file = /usr/share/dict/words
   admin_keytab = /opt/krb5/data/kadm5.keytab

+ 2 - 2
testenv/krb5kdc-vagrant/kdc.conf

@@ -5,8 +5,8 @@
 [realms]
  __REALM__ = {
   master_key_type = aes256-cts-hmac-sha1-96
-  max_life = 12h 0m 0s
-  max_renewable_life = 7d 0h 0m 0s
+  max_life = 20s
+  max_renewable_life = 55s
   acl_file = /var/kerberos/krb5kdc/kadm5.acl
   dict_file = /usr/share/dict/words
   admin_keytab = /opt/krb5/data/kadm5.keytab