11//go:build integration
22// +build integration
33
4+ //revive:disable
45package identity_provider
56
67import (
@@ -21,10 +22,12 @@ import (
2122
2223 "github.com/pkg/errors"
2324
24- v1 "k8s.io/api/core/v1"
25+ // Register the OIDC provider
26+ _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
27+
28+ corev1 "k8s.io/api/core/v1"
2529 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2630 "k8s.io/client-go/kubernetes"
27- _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
2831 "k8s.io/client-go/tools/clientcmd"
2932 clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
3033
@@ -88,7 +91,19 @@ var _ = Describe("(Integration) [Identity Provider]", func() {
8891
8992 It ("should associate, get and disassociate identity provider" , func () {
9093 By ("associating a new identity provider" )
91- cmd := associateOIDCProviderCMD (oidcConfig , params .ClusterName , params .Region )
94+ identityProviderClusterConfig := makeIdentityProviderClusterConfig (oidcConfig , params .ClusterName , params .Region )
95+
96+ cmd := params .EksctlCmd .WithArgs (
97+ "associate" ,
98+ "identityprovider" ,
99+ "--config-file" , "-" ,
100+ "--verbose" , "4" ,
101+ "--wait" ,
102+ ).
103+ WithStdin (strings .NewReader (identityProviderClusterConfig )).
104+ WithoutArg ("--region" , params .Region ).
105+ WithTimeout (35 * time .Minute )
106+
92107 Expect (cmd ).To (RunSuccessfully ())
93108
94109 By ("getting the identity provider" )
@@ -115,16 +130,16 @@ var _ = Describe("(Integration) [Identity Provider]", func() {
115130 Expect (err ).NotTo (HaveOccurred ())
116131
117132 By ("reading Kubernetes resources" )
118- list , err := clientset .CoreV1 ().Nodes ().List (context .Background (), metav1.ListOptions {})
133+ list , err := clientset .CoreV1 ().Nodes ().List (context .TODO (), metav1.ListOptions {})
119134 Expect (err ).NotTo (HaveOccurred ())
120135 Expect (list .Items ).To (HaveLen (1 ))
121136
122- secrets , err := clientset .CoreV1 ().Secrets (metav1 .NamespaceAll ).List (context .Background (), metav1.ListOptions {})
137+ secrets , err := clientset .CoreV1 ().Secrets (metav1 .NamespaceAll ).List (context .TODO (), metav1.ListOptions {})
123138 Expect (err ).NotTo (HaveOccurred ())
124139 Expect (secrets .Items ).NotTo (BeEmpty ())
125140
126141 By ("ensuring the client does not have write access" )
127- _ , err = clientset .CoreV1 ().ConfigMaps (metav1 .NamespaceDefault ).Create (context .Background (), & v1 .ConfigMap {
142+ _ , err = clientset .CoreV1 ().ConfigMaps (metav1 .NamespaceDefault ).Create (context .TODO (), & corev1 .ConfigMap {
128143 ObjectMeta : metav1.ObjectMeta {
129144 Name : "testdata" ,
130145 },
@@ -140,10 +155,13 @@ var _ = Describe("(Integration) [Identity Provider]", func() {
140155 WithArgs (
141156 "disassociate" ,
142157 "identityprovider" ,
143- "--cluster " , params . ClusterName ,
158+ "--config-file " , "-" ,
144159 "--wait" ,
145160 ).
161+ WithStdin (strings .NewReader (identityProviderClusterConfig )).
162+ WithoutArg ("--region" , params .Region ).
146163 WithTimeout (30 * time .Minute )
164+
147165 Expect (cmd ).To (RunSuccessfully ())
148166
149167 })
@@ -341,8 +359,8 @@ func setupCognitoProvider(clusterName, region string) (*OIDCConfig, error) {
341359
342360}
343361
344- func associateOIDCProviderCMD (o * OIDCConfig , clusterName , region string ) Cmd {
345- clusterConfig := fmt .Sprintf (`apiVersion: eksctl.io/v1alpha5
362+ func makeIdentityProviderClusterConfig (o * OIDCConfig , clusterName , region string ) string {
363+ return fmt .Sprintf (`apiVersion: eksctl.io/v1alpha5
346364kind: ClusterConfig
347365
348366metadata:
@@ -358,15 +376,4 @@ identityProviders:
358376 groupsPrefix: "gid:"
359377 type: oidc
360378` , clusterName , region , o .idpIssuerURL , o .clientID )
361-
362- return params .EksctlCmd .WithArgs (
363- "associate" ,
364- "identityprovider" ,
365- "--config-file" , "-" ,
366- "--verbose" , "4" ,
367- "--wait" ,
368- ).
369- WithStdin (strings .NewReader (clusterConfig )).
370- WithoutArg ("--region" , region ).
371- WithTimeout (35 * time .Minute )
372379}
0 commit comments