@@ -21,14 +21,11 @@ import (
2121 "net/http"
2222 "testing"
2323
24- "github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2018-03-31 /containerservice"
24+ "github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2022-01-01 /containerservice"
2525 "github.com/Azure/go-autorest/autorest"
2626 "github.com/Azure/go-autorest/autorest/to"
27- xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
2827 "github.com/google/go-cmp/cmp"
2928 "github.com/pkg/errors"
30- v1 "k8s.io/api/core/v1"
31- "sigs.k8s.io/controller-runtime/pkg/client"
3229
3330 "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
3431 "github.com/crossplane/crossplane-runtime/pkg/resource"
@@ -38,11 +35,6 @@ import (
3835 "github.com/crossplane/provider-azure/pkg/clients/compute/fake"
3936)
4037
41- const (
42- testPasswd = "pass123"
43- testExistingSecret = "existingSecret"
44- )
45-
4638type modifier func (* v1alpha3.AKSCluster )
4739
4840func withState (state string ) modifier {
@@ -63,12 +55,6 @@ func withEndpoint(ep string) modifier {
6355 }
6456}
6557
66- func withConnectionSecretRef (ref * xpv1.SecretReference ) modifier {
67- return func (c * v1alpha3.AKSCluster ) {
68- c .Spec .WriteConnectionSecretToReference = ref
69- }
70- }
71-
7258func aksCluster (m ... modifier ) * v1alpha3.AKSCluster {
7359 ac := & v1alpha3.AKSCluster {}
7460
@@ -84,7 +70,7 @@ func TestObserve(t *testing.T) {
8470 id := "koolAD"
8571 stateSucceeded := "Succeeded"
8672 stateWat := "Wat"
87- endpoint := "http ://wat.example.org"
73+ endpoint := "https ://wat.example.org"
8874
8975 type args struct {
9076 ctx context.Context
@@ -241,23 +227,10 @@ func TestCreate(t *testing.T) {
241227 err : errors .New (errNotAKSCluster ),
242228 },
243229 },
244- "ErrGeneratePassword" : {
245- e : & external {
246- newPasswordFn : func () (string , error ) { return "" , errBoom },
247- },
248- args : args {
249- ctx : context .Background (),
250- mg : aksCluster (),
251- },
252- want : want {
253- err : errors .Wrap (errBoom , errGenPassword ),
254- },
255- },
256230 "ErrEnsureCluster" : {
257231 e : & external {
258- newPasswordFn : func () (string , error ) { return "" , nil },
259232 client : fake.AKSClient {
260- MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster , _ string ) error {
233+ MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster ) error {
261234 return errBoom
262235 },
263236 },
@@ -268,18 +241,13 @@ func TestCreate(t *testing.T) {
268241 },
269242 want : want {
270243 err : errors .Wrap (errBoom , errCreateAKSCluster ),
271- ec : managed.ExternalCreation {
272- ConnectionDetails : map [string ][]byte {
273- "password" : {},
274- },
275- },
244+ ec : managed.ExternalCreation {},
276245 },
277246 },
278247 "SuccessEnsureCluster" : {
279248 e : & external {
280- newPasswordFn : func () (string , error ) { return testPasswd , nil },
281249 client : fake.AKSClient {
282- MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster , _ string ) error {
250+ MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster ) error {
283251 return nil
284252 },
285253 },
@@ -289,102 +257,7 @@ func TestCreate(t *testing.T) {
289257 mg : aksCluster (),
290258 },
291259 want : want {
292- ec : managed.ExternalCreation {
293- ConnectionDetails : map [string ][]byte {
294- "password" : []byte (testPasswd ),
295- },
296- },
297- },
298- },
299- "SuccessExistingEmptyAppSecret" : {
300- e : & external {
301- newPasswordFn : func () (string , error ) { return testPasswd , nil },
302- client : fake.AKSClient {
303- MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster , _ string ) error {
304- return nil
305- },
306- },
307- kube : & test.MockClient {
308- MockGet : func (_ context.Context , _ client.ObjectKey , o client.Object ) error {
309- s , ok := o .(* v1.Secret )
310- if ! ok {
311- t .Fatalf ("not a *v1.Secret" )
312- }
313- s .Data = map [string ][]byte {"password" : {}}
314- return nil
315- },
316- },
317- },
318- args : args {
319- ctx : context .Background (),
320- mg : aksCluster (withConnectionSecretRef (& xpv1.SecretReference {
321- Name : "test-secret" ,
322- Namespace : "test-ns" ,
323- })),
324- },
325- want : want {
326- ec : managed.ExternalCreation {
327- ConnectionDetails : map [string ][]byte {
328- "password" : []byte (testPasswd ),
329- },
330- },
331- },
332- },
333- "SuccessExistingNonEmptyAppSecret" : {
334- e : & external {
335- newPasswordFn : func () (string , error ) { return testPasswd , nil },
336- client : fake.AKSClient {
337- MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster , _ string ) error {
338- return nil
339- },
340- },
341- kube : & test.MockClient {
342- MockGet : func (_ context.Context , _ client.ObjectKey , o client.Object ) error {
343- s , ok := o .(* v1.Secret )
344- if ! ok {
345- t .Fatalf ("not a *v1.Secret" )
346- }
347- s .Data = map [string ][]byte {"password" : []byte (testExistingSecret )}
348- return nil
349- },
350- },
351- },
352- args : args {
353- ctx : context .Background (),
354- mg : aksCluster (withConnectionSecretRef (& xpv1.SecretReference {
355- Name : "test-secret" ,
356- Namespace : "test-ns" ,
357- })),
358- },
359- want : want {
360- ec : managed.ExternalCreation {
361- ConnectionDetails : map [string ][]byte {
362- "password" : []byte (testExistingSecret ),
363- },
364- },
365- },
366- },
367- "ErrExistingAppSecret" : {
368- e : & external {
369- newPasswordFn : func () (string , error ) { return testPasswd , nil },
370- client : fake.AKSClient {
371- MockEnsureManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster , _ string ) error {
372- return nil
373- },
374- },
375- kube : & test.MockClient {
376- MockGet : test .NewMockGetFn (errBoom ),
377- },
378- },
379- args : args {
380- ctx : context .Background (),
381- mg : aksCluster (withConnectionSecretRef (& xpv1.SecretReference {
382- Name : "test-secret" ,
383- Namespace : "test-ns" ,
384- })),
385- },
386- want : want {
387- err : errors .Wrap (errBoom , errGetConnSecret ),
260+ ec : managed.ExternalCreation {},
388261 },
389262 },
390263 }
@@ -425,7 +298,6 @@ func TestDelete(t *testing.T) {
425298 },
426299 "ErrDeleteCluster" : {
427300 e : & external {
428- newPasswordFn : func () (string , error ) { return "" , nil },
429301 client : fake.AKSClient {
430302 MockDeleteManagedCluster : func (_ context.Context , _ * v1alpha3.AKSCluster ) error {
431303 return errBoom
0 commit comments