Skip to content

Commit bfce916

Browse files
authored
Merge pull request kubernetes#77786 from SataQiu/fix-golint-test-20190512
Fix golint failures of test/e2e/auth
2 parents 9b2231a + a4825d1 commit bfce916

File tree

10 files changed

+112
-112
lines changed

10 files changed

+112
-112
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
600600
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller
601601
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1
602602
test/e2e
603-
test/e2e/auth
604603
test/e2e/autoscaling
605604
test/e2e/chaosmonkey
606605
test/e2e/common

test/e2e/auth/audit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
imageutils "k8s.io/kubernetes/test/utils/image"
4343

4444
jsonpatch "github.com/evanphx/json-patch"
45-
. "github.com/onsi/ginkgo"
45+
"github.com/onsi/ginkgo"
4646
)
4747

4848
var (
@@ -62,12 +62,12 @@ var (
6262
var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
6363
f := framework.NewDefaultFramework("audit")
6464
var namespace string
65-
BeforeEach(func() {
65+
ginkgo.BeforeEach(func() {
6666
framework.SkipUnlessProviderIs("gce")
6767
namespace = f.Namespace.Name
6868
})
6969

70-
It("should audit API calls to create, get, update, patch, delete, list, watch pods.", func() {
70+
ginkgo.It("should audit API calls to create, get, update, patch, delete, list, watch pods.", func() {
7171
pod := &apiv1.Pod{
7272
ObjectMeta: metav1.ObjectMeta{
7373
Name: "audit-pod",
@@ -201,7 +201,7 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
201201
})
202202
})
203203

204-
It("should audit API calls to create, get, update, patch, delete, list, watch deployments.", func() {
204+
ginkgo.It("should audit API calls to create, get, update, patch, delete, list, watch deployments.", func() {
205205
podLabels := map[string]string{"name": "audit-deployment-pod"}
206206
d := e2edeploy.NewDeployment("audit-deployment", int32(1), podLabels, "redis", imageutils.GetE2EImage(imageutils.Redis), apps.RecreateDeploymentStrategyType)
207207

@@ -328,7 +328,7 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
328328
})
329329
})
330330

331-
It("should audit API calls to create, get, update, patch, delete, list, watch configmaps.", func() {
331+
ginkgo.It("should audit API calls to create, get, update, patch, delete, list, watch configmaps.", func() {
332332
configMap := &apiv1.ConfigMap{
333333
ObjectMeta: metav1.ObjectMeta{
334334
Name: "audit-configmap",
@@ -461,7 +461,7 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
461461
})
462462
})
463463

464-
It("should audit API calls to create, get, update, patch, delete, list, watch secrets.", func() {
464+
ginkgo.It("should audit API calls to create, get, update, patch, delete, list, watch secrets.", func() {
465465
secret := &apiv1.Secret{
466466
ObjectMeta: metav1.ObjectMeta{
467467
Name: "audit-secret",
@@ -593,7 +593,7 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
593593
})
594594
})
595595

596-
It("should audit API calls to create and delete custom resource definition.", func() {
596+
ginkgo.It("should audit API calls to create and delete custom resource definition.", func() {
597597
config, err := framework.LoadConfig()
598598
framework.ExpectNoError(err, "failed to load config")
599599
apiExtensionClient, err := apiextensionclientset.NewForConfig(config)
@@ -654,12 +654,12 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
654654
})
655655

656656
// test authorizer annotations, RBAC is required.
657-
It("should audit API calls to get a pod with unauthorized user.", func() {
657+
ginkgo.It("should audit API calls to get a pod with unauthorized user.", func() {
658658
if !auth.IsRBACEnabled(f.ClientSet.RbacV1beta1()) {
659659
framework.Skipf("RBAC not enabled.")
660660
}
661661

662-
By("Creating a kubernetes client that impersonates an unauthorized anonymous user")
662+
ginkgo.By("Creating a kubernetes client that impersonates an unauthorized anonymous user")
663663
config, err := framework.LoadConfig()
664664
framework.ExpectNoError(err)
665665
config.Impersonate = restclient.ImpersonationConfig{
@@ -691,8 +691,8 @@ var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
691691
})
692692
})
693693

694-
It("should list pods as impersonated user.", func() {
695-
By("Creating a kubernetes client that impersonates an authorized user")
694+
ginkgo.It("should list pods as impersonated user.", func() {
695+
ginkgo.By("Creating a kubernetes client that impersonates an authorized user")
696696
config, err := framework.LoadConfig()
697697
framework.ExpectNoError(err)
698698
config.Impersonate = restclient.ImpersonationConfig{

test/e2e/auth/audit_dynamic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"time"
2323

24-
. "github.com/onsi/ginkgo"
24+
"github.com/onsi/ginkgo"
2525

2626
auditregv1alpha1 "k8s.io/api/auditregistration/v1alpha1"
2727
apiv1 "k8s.io/api/core/v1"
@@ -44,10 +44,10 @@ import (
4444
var _ = SIGDescribe("[Feature:DynamicAudit]", func() {
4545
f := framework.NewDefaultFramework("audit")
4646

47-
It("should dynamically audit API calls", func() {
47+
ginkgo.It("should dynamically audit API calls", func() {
4848
namespace := f.Namespace.Name
4949

50-
By("Creating a kubernetes client that impersonates an unauthorized anonymous user")
50+
ginkgo.By("Creating a kubernetes client that impersonates an unauthorized anonymous user")
5151
config, err := framework.LoadConfig()
5252
framework.ExpectNoError(err, "failed to fetch config")
5353

test/e2e/auth/certificates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ import (
3131
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
3232
"k8s.io/kubernetes/test/utils"
3333

34-
. "github.com/onsi/ginkgo"
34+
"github.com/onsi/ginkgo"
3535
)
3636

3737
var _ = SIGDescribe("Certificates API", func() {
3838
f := framework.NewDefaultFramework("certificates")
3939

40-
It("should support building a client with a CSR", func() {
40+
ginkgo.It("should support building a client with a CSR", func() {
4141
const commonName = "tester-csr"
4242

4343
pk, err := utils.NewPrivateKey()

test/e2e/auth/framework.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package auth
1818

1919
import "github.com/onsi/ginkgo"
2020

21+
// SIGDescribe annotates the test with the SIG label.
2122
func SIGDescribe(text string, body func()) bool {
2223
return ginkgo.Describe("[sig-auth] "+text, body)
2324
}

test/e2e/auth/metadata_concealment.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ import (
2323
"k8s.io/kubernetes/test/e2e/framework"
2424
jobutil "k8s.io/kubernetes/test/e2e/framework/job"
2525

26-
. "github.com/onsi/ginkgo"
26+
"github.com/onsi/ginkgo"
2727
imageutil "k8s.io/kubernetes/test/utils/image"
2828
)
2929

3030
var _ = SIGDescribe("Metadata Concealment", func() {
3131
f := framework.NewDefaultFramework("metadata-concealment")
3232

33-
It("should run a check-metadata-concealment job to completion", func() {
33+
ginkgo.It("should run a check-metadata-concealment job to completion", func() {
3434
framework.SkipUnlessProviderIs("gce")
35-
By("Creating a job")
35+
ginkgo.By("Creating a job")
3636
job := &batch.Job{
3737
ObjectMeta: metav1.ObjectMeta{
3838
Name: "check-metadata-concealment",
@@ -57,7 +57,7 @@ var _ = SIGDescribe("Metadata Concealment", func() {
5757
job, err := jobutil.CreateJob(f.ClientSet, f.Namespace.Name, job)
5858
framework.ExpectNoError(err, "failed to create job (%s:%s)", f.Namespace.Name, job.Name)
5959

60-
By("Ensuring job reaches completions")
60+
ginkgo.By("Ensuring job reaches completions")
6161
err = jobutil.WaitForJobComplete(f.ClientSet, f.Namespace.Name, job.Name, int32(1))
6262
framework.ExpectNoError(err, "failed to ensure job completion (%s:%s)", f.Namespace.Name, job.Name)
6363
})

test/e2e/auth/node_authn.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ import (
2525
"k8s.io/kubernetes/test/e2e/framework"
2626
imageutils "k8s.io/kubernetes/test/utils/image"
2727

28-
. "github.com/onsi/ginkgo"
29-
. "github.com/onsi/gomega"
28+
"github.com/onsi/ginkgo"
29+
"github.com/onsi/gomega"
3030
)
3131

3232
var _ = SIGDescribe("[Feature:NodeAuthenticator]", func() {
3333

3434
f := framework.NewDefaultFramework("node-authn")
3535
var ns string
3636
var nodeIPs []string
37-
BeforeEach(func() {
37+
ginkgo.BeforeEach(func() {
3838
ns = f.Namespace.Name
3939

4040
nodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
4141
framework.ExpectNoError(err, "failed to list nodes in namespace: %s", ns)
42-
Expect(len(nodeList.Items)).NotTo(BeZero())
42+
gomega.Expect(len(nodeList.Items)).NotTo(gomega.BeZero())
4343

4444
pickedNode := nodeList.Items[0]
4545
nodeIPs = framework.GetNodeAddresses(&pickedNode, v1.NodeExternalIP)
@@ -50,20 +50,20 @@ var _ = SIGDescribe("[Feature:NodeAuthenticator]", func() {
5050
saName := "default"
5151
sa, err := f.ClientSet.CoreV1().ServiceAccounts(ns).Get(saName, metav1.GetOptions{})
5252
framework.ExpectNoError(err, "failed to retrieve service account (%s:%s)", ns, saName)
53-
Expect(len(sa.Secrets)).NotTo(BeZero())
53+
gomega.Expect(len(sa.Secrets)).NotTo(gomega.BeZero())
5454
})
5555

56-
It("The kubelet's main port 10250 should reject requests with no credentials", func() {
56+
ginkgo.It("The kubelet's main port 10250 should reject requests with no credentials", func() {
5757
pod := createNodeAuthTestPod(f)
5858
for _, nodeIP := range nodeIPs {
5959
// Anonymous authentication is disabled by default
6060
result := framework.RunHostCmdOrDie(ns, pod.Name, fmt.Sprintf("curl -sIk -o /dev/null -w '%s' https://%s:%v/metrics", "%{http_code}", nodeIP, ports.KubeletPort))
61-
Expect(result).To(Or(Equal("401"), Equal("403")), "the kubelet's main port 10250 should reject requests with no credentials")
61+
gomega.Expect(result).To(gomega.Or(gomega.Equal("401"), gomega.Equal("403")), "the kubelet's main port 10250 should reject requests with no credentials")
6262
}
6363
})
6464

65-
It("The kubelet can delegate ServiceAccount tokens to the API server", func() {
66-
By("create a new ServiceAccount for authentication")
65+
ginkgo.It("The kubelet can delegate ServiceAccount tokens to the API server", func() {
66+
ginkgo.By("create a new ServiceAccount for authentication")
6767
trueValue := true
6868
newSA := &v1.ServiceAccount{
6969
ObjectMeta: metav1.ObjectMeta{
@@ -84,7 +84,7 @@ var _ = SIGDescribe("[Feature:NodeAuthenticator]", func() {
8484
"%{http_code}",
8585
"cat /var/run/secrets/kubernetes.io/serviceaccount/token",
8686
nodeIP, ports.KubeletPort))
87-
Expect(result).To(Or(Equal("401"), Equal("403")), "the kubelet can delegate ServiceAccount tokens to the API server")
87+
gomega.Expect(result).To(gomega.Or(gomega.Equal("401"), gomega.Equal("403")), "the kubelet can delegate ServiceAccount tokens to the API server")
8888
}
8989
})
9090
})

test/e2e/auth/node_authz.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import (
3030
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
3131
imageutils "k8s.io/kubernetes/test/utils/image"
3232

33-
. "github.com/onsi/ginkgo"
34-
. "github.com/onsi/gomega"
33+
"github.com/onsi/ginkgo"
34+
"github.com/onsi/gomega"
3535
)
3636

3737
const (
38-
NodesGroup = "system:nodes"
39-
NodeNamePrefix = "system:node:"
38+
nodesGroup = "system:nodes"
39+
nodeNamePrefix = "system:node:"
4040
)
4141

4242
var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
@@ -48,47 +48,47 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
4848
var asUser string
4949
var defaultSaSecret string
5050
var nodeName string
51-
BeforeEach(func() {
51+
ginkgo.BeforeEach(func() {
5252
ns = f.Namespace.Name
5353

5454
nodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
5555
framework.ExpectNoError(err, "failed to list nodes in namespace: %s", ns)
56-
Expect(len(nodeList.Items)).NotTo(Equal(0))
56+
gomega.Expect(len(nodeList.Items)).NotTo(gomega.Equal(0))
5757
nodeName = nodeList.Items[0].Name
58-
asUser = NodeNamePrefix + nodeName
58+
asUser = nodeNamePrefix + nodeName
5959
saName := "default"
6060
sa, err := f.ClientSet.CoreV1().ServiceAccounts(ns).Get(saName, metav1.GetOptions{})
61-
Expect(len(sa.Secrets)).NotTo(Equal(0))
61+
gomega.Expect(len(sa.Secrets)).NotTo(gomega.Equal(0))
6262
framework.ExpectNoError(err, "failed to retrieve service account (%s:%s)", ns, saName)
6363
defaultSaSecret = sa.Secrets[0].Name
64-
By("Creating a kubernetes client that impersonates a node")
64+
ginkgo.By("Creating a kubernetes client that impersonates a node")
6565
config, err := framework.LoadConfig()
6666
framework.ExpectNoError(err, "failed to load kubernetes client config")
6767
config.Impersonate = restclient.ImpersonationConfig{
6868
UserName: asUser,
69-
Groups: []string{NodesGroup},
69+
Groups: []string{nodesGroup},
7070
}
7171
c, err = clientset.NewForConfig(config)
7272
framework.ExpectNoError(err, "failed to create Clientset for the given config: %+v", *config)
7373

7474
})
75-
It("Getting a non-existent secret should exit with the Forbidden error, not a NotFound error", func() {
75+
ginkgo.It("Getting a non-existent secret should exit with the Forbidden error, not a NotFound error", func() {
7676
_, err := c.CoreV1().Secrets(ns).Get("foo", metav1.GetOptions{})
77-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
77+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
7878
})
7979

80-
It("Getting an existing secret should exit with the Forbidden error", func() {
80+
ginkgo.It("Getting an existing secret should exit with the Forbidden error", func() {
8181
_, err := c.CoreV1().Secrets(ns).Get(defaultSaSecret, metav1.GetOptions{})
82-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
82+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
8383
})
8484

85-
It("Getting a non-existent configmap should exit with the Forbidden error, not a NotFound error", func() {
85+
ginkgo.It("Getting a non-existent configmap should exit with the Forbidden error, not a NotFound error", func() {
8686
_, err := c.CoreV1().ConfigMaps(ns).Get("foo", metav1.GetOptions{})
87-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
87+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
8888
})
8989

90-
It("Getting an existing configmap should exit with the Forbidden error", func() {
91-
By("Create a configmap for testing")
90+
ginkgo.It("Getting an existing configmap should exit with the Forbidden error", func() {
91+
ginkgo.By("Create a configmap for testing")
9292
configmap := &v1.ConfigMap{
9393
ObjectMeta: metav1.ObjectMeta{
9494
Namespace: ns,
@@ -101,11 +101,11 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
101101
_, err := f.ClientSet.CoreV1().ConfigMaps(ns).Create(configmap)
102102
framework.ExpectNoError(err, "failed to create configmap (%s:%s) %+v", ns, configmap.Name, *configmap)
103103
_, err = c.CoreV1().ConfigMaps(ns).Get(configmap.Name, metav1.GetOptions{})
104-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
104+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
105105
})
106106

107-
It("Getting a secret for a workload the node has access to should succeed", func() {
108-
By("Create a secret for testing")
107+
ginkgo.It("Getting a secret for a workload the node has access to should succeed", func() {
108+
ginkgo.By("Create a secret for testing")
109109
secret := &v1.Secret{
110110
ObjectMeta: metav1.ObjectMeta{
111111
Namespace: ns,
@@ -118,11 +118,11 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
118118
_, err := f.ClientSet.CoreV1().Secrets(ns).Create(secret)
119119
framework.ExpectNoError(err, "failed to create secret (%s:%s)", ns, secret.Name)
120120

121-
By("Node should not get the secret")
121+
ginkgo.By("Node should not get the secret")
122122
_, err = c.CoreV1().Secrets(ns).Get(secret.Name, metav1.GetOptions{})
123-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
123+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
124124

125-
By("Create a pod that use the secret")
125+
ginkgo.By("Create a pod that use the secret")
126126
pod := &v1.Pod{
127127
ObjectMeta: metav1.ObjectMeta{
128128
Name: "pause",
@@ -151,7 +151,7 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
151151
_, err = f.ClientSet.CoreV1().Pods(ns).Create(pod)
152152
framework.ExpectNoError(err, "failed to create pod (%s:%s)", ns, pod.Name)
153153

154-
By("The node should able to access the secret")
154+
ginkgo.By("The node should able to access the secret")
155155
itv := framework.Poll
156156
dur := 1 * time.Minute
157157
err = wait.Poll(itv, dur, func() (bool, error) {
@@ -165,22 +165,22 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
165165
framework.ExpectNoError(err, "failed to get secret after trying every %v for %v (%s:%s)", itv, dur, ns, secret.Name)
166166
})
167167

168-
It("A node shouldn't be able to create another node", func() {
168+
ginkgo.It("A node shouldn't be able to create another node", func() {
169169
node := &v1.Node{
170170
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
171171
TypeMeta: metav1.TypeMeta{
172172
Kind: "Node",
173173
APIVersion: "v1",
174174
},
175175
}
176-
By(fmt.Sprintf("Create node foo by user: %v", asUser))
176+
ginkgo.By(fmt.Sprintf("Create node foo by user: %v", asUser))
177177
_, err := c.CoreV1().Nodes().Create(node)
178-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
178+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
179179
})
180180

181-
It("A node shouldn't be able to delete another node", func() {
182-
By(fmt.Sprintf("Create node foo by user: %v", asUser))
181+
ginkgo.It("A node shouldn't be able to delete another node", func() {
182+
ginkgo.By(fmt.Sprintf("Create node foo by user: %v", asUser))
183183
err := c.CoreV1().Nodes().Delete("foo", &metav1.DeleteOptions{})
184-
Expect(apierrors.IsForbidden(err)).Should(Equal(true))
184+
gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.Equal(true))
185185
})
186186
})

0 commit comments

Comments
 (0)