Merge pull request #117110 from pohly/test-integration-race-detection-auth
test/integration/auth: fix data race
This commit is contained in:
		@@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"sync"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	authorizationapi "k8s.io/api/authorization/v1"
 | 
						authorizationapi "k8s.io/api/authorization/v1"
 | 
				
			||||||
@@ -148,8 +149,12 @@ func TestSubjectAccessReview(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestSelfSubjectAccessReview(t *testing.T) {
 | 
					func TestSelfSubjectAccessReview(t *testing.T) {
 | 
				
			||||||
 | 
						var mutex sync.Mutex
 | 
				
			||||||
	username := "alice"
 | 
						username := "alice"
 | 
				
			||||||
	authenticatorFunc := func(req *http.Request) (*authenticator.Response, bool, error) {
 | 
						authenticatorFunc := func(req *http.Request) (*authenticator.Response, bool, error) {
 | 
				
			||||||
 | 
							mutex.Lock()
 | 
				
			||||||
 | 
							defer mutex.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return &authenticator.Response{
 | 
							return &authenticator.Response{
 | 
				
			||||||
			User: &user.DefaultInfo{
 | 
								User: &user.DefaultInfo{
 | 
				
			||||||
				Name:   username,
 | 
									Name:   username,
 | 
				
			||||||
@@ -216,7 +221,9 @@ func TestSelfSubjectAccessReview(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, test := range tests {
 | 
						for _, test := range tests {
 | 
				
			||||||
 | 
							mutex.Lock()
 | 
				
			||||||
		username = test.username
 | 
							username = test.username
 | 
				
			||||||
 | 
							mutex.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		response, err := clientset.AuthorizationV1().SelfSubjectAccessReviews().Create(context.TODO(), test.sar, metav1.CreateOptions{})
 | 
							response, err := clientset.AuthorizationV1().SelfSubjectAccessReviews().Create(context.TODO(), test.sar, metav1.CreateOptions{})
 | 
				
			||||||
		switch {
 | 
							switch {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user