func TestCSRSignerNameFieldSelector(t *testing.T) {
	_, s, closeFn := framework.RunAMaster(nil)
	defer closeFn()

	client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
	csrClient := client.CertificatesV1beta1().CertificateSigningRequests()
	csr1 := createTestingCSR(t, csrClient, "csr-1", "example.com/signer-name-1", "")
	csr2 := createTestingCSR(t, csrClient, "csr-2", "example.com/signer-name-2", "")
	// csr3 has the same signerName as csr2 so we can ensure multiple items are returned when running a filtered
	// LIST call.
	csr3 := createTestingCSR(t, csrClient, "csr-3", "example.com/signer-name-2", "")

	signerOneList, err := client.CertificatesV1beta1().CertificateSigningRequests().List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.signerName=example.com/signer-name-1"})
	if err != nil {
		t.Errorf("unable to list CSRs with spec.signerName=example.com/signer-name-1")
		return
	}
	if len(signerOneList.Items) != 1 {
		t.Errorf("expected one CSR to be returned but got %d", len(signerOneList.Items))
	} else if signerOneList.Items[0].Name != csr1.Name {
		t.Errorf("expected CSR named 'csr-1' to be returned but got %q", signerOneList.Items[0].Name)
	}

	signerTwoList, err := client.CertificatesV1beta1().CertificateSigningRequests().List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.signerName=example.com/signer-name-2"})
	if err != nil {
		t.Errorf("unable to list CSRs with spec.signerName=example.com/signer-name-2")
		return
	}
	if len(signerTwoList.Items) != 2 {
		t.Errorf("expected one CSR to be returned but got %d", len(signerTwoList.Items))
	} else if signerTwoList.Items[0].Name != csr2.Name {
		t.Errorf("expected CSR named 'csr-2' to be returned but got %q", signerTwoList.Items[0].Name)
	} else if signerTwoList.Items[1].Name != csr3.Name {
		t.Errorf("expected CSR named 'csr-3' to be returned but got %q", signerTwoList.Items[1].Name)
	}
}
// Verifies that the 'spec.signerName' field can be correctly used as a field selector on LIST requests
Verifies that the 'spec.signerName' field can be correctly used as a field selector on LIST requests
// Verifies that the ' spec . signerName ' field can be correctly used as a field selector on LIST requests
func TestCSRSignerNameFieldSelector(t *testing.T) {
	_, s, closeFn := framework.RunAMaster(nil)
	defer closeFn()
	client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
	csrClient := client.CertificatesV1beta1().CertificateSigningRequests()
	csr1 := createTestingCSR(t, csrClient, "csr-1", "example.com/signer-name-1", "")
	csr2 := createTestingCSR(t, csrClient, "csr-2", "example.com/signer-name-2", "")
	csr3 := createTestingCSR(t, csrClient, "csr-3", "example.com/signer-name-2", "")
	signerOneList, err := client.CertificatesV1beta1().CertificateSigningRequests().List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.signerName=example.com/signer-name-1"})
	if err != nil {
		t.Errorf("unable to list CSRs with spec.signerName=example.com/signer-name-1")
		return
	}
	if len(signerOneList.Items) != 1 {
		t.Errorf("expected one CSR to be returned but got %d", len(signerOneList.Items))
	} else if signerOneList.Items[0].Name != csr1.Name {
		t.Errorf("expected CSR named 'csr-1' to be returned but got %q", signerOneList.Items[0].Name)
	}
	signerTwoList, err := client.CertificatesV1beta1().CertificateSigningRequests().List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.signerName=example.com/signer-name-2"})
	if err != nil {
		t.Errorf("unable to list CSRs with spec.signerName=example.com/signer-name-2")
		return
	}
	if len(signerTwoList.Items) != 2 {
		t.Errorf("expected one CSR to be returned but got %d", len(signerTwoList.Items))
	} else if signerTwoList.Items[0].Name != csr2.Name {
		t.Errorf("expected CSR named 'csr-2' to be returned but got %q", signerTwoList.Items[0].Name)
	} else if signerTwoList.Items[1].Name != csr3.Name {
		t.Errorf("expected CSR named 'csr-3' to be returned but got %q", signerTwoList.Items[1].Name)
	}
}
func TestCSRSignerNameFieldSelector ( t * testing . T ) { _ , s , closeFn := framework . RunAMaster ( nil ) defer closeFn ( ) client := clientset . NewForConfigOrDie ( & restclient . Config { Host : s . URL , ContentConfig : restclient . ContentConfig { GroupVersion : & schema . GroupVersion { Group : " " , Version : " " } } } ) csrClient := client . CertificatesV1beta1 ( ) . CertificateSigningRequests ( ) csr1 := createTestingCSR ( t , csrClient , " " , " " , " " ) csr2 := createTestingCSR ( t , csrClient , " " , " " , " " ) csr3 := createTestingCSR ( t , csrClient , " " , " " , " " ) signerOneList , err := client . CertificatesV1beta1 ( ) . CertificateSigningRequests ( ) . List ( context . TODO ( ) , metav1 . ListOptions { FieldSelector : " " } ) if err != nil { t . Errorf ( " " ) return } if len ( signerOneList . Items ) != 1 { t . Errorf ( " " , len ( signerOneList . Items ) ) } else if signerOneList . Items [ 0 ] . Name != csr1 . Name { t . Errorf ( " " , signerOneList . Items [ 0 ] . Name ) } signerTwoList , err := client . CertificatesV1beta1 ( ) . CertificateSigningRequests ( ) . List ( context . TODO ( ) , metav1 . ListOptions { FieldSelector : " " } ) if err != nil { t . Errorf ( " " ) return } if len ( signerTwoList . Items ) != 2 { t . Errorf ( " " , len ( signerTwoList . Items ) ) } else if signerTwoList . Items [ 0 ] . Name != csr2 . Name { t . Errorf ( " " , signerTwoList . Items [ 0 ] . Name ) } else if signerTwoList . Items [ 1 ] . Name != csr3 . Name { t . Errorf ( " " , signerTwoList . Items [ 1 ] . Name ) } }
Verifies that the 'spec.signerName' field can be correctly used as a field selector on LIST requests
Verifies that the ' spec . signerName ' field can be correctly used as a field selector on LIST requests
// csr3 has the same signerName as csr2 so we can ensure multiple items are returned when running a filtered // LIST call.