From 9ab083f0af42f417349464c95ba257b9cd48c2c0 Mon Sep 17 00:00:00 2001 From: abacus3 <57175410+abacus3@users.noreply.github.com> Date: Thu, 24 Nov 2022 12:50:47 +0100 Subject: [PATCH] fix(cognitoidentity): Update broken AWS API function call for GroupUserMembership Signed-off-by: abacus3 <57175410+abacus3@users.noreply.github.com> --- .../groupusermembership/controller.go | 2 +- .../groupusermembership/controller_test.go | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/controller/cognitoidentityprovider/groupusermembership/controller.go b/pkg/controller/cognitoidentityprovider/groupusermembership/controller.go index ec4b3e31d2..c73e7bacb1 100644 --- a/pkg/controller/cognitoidentityprovider/groupusermembership/controller.go +++ b/pkg/controller/cognitoidentityprovider/groupusermembership/controller.go @@ -151,7 +151,7 @@ func (e *external) Observe(ctx context.Context, mgd resource.Managed) (managed.E return managed.ExternalObservation{}, errors.Wrap(err, errUnmarshal) } - attachedGroupObject, err := FindAttachedGroupObject(ctx, e, externalAnnotation.Username, externalAnnotation.UserPoolID, externalAnnotation.Groupname) + attachedGroupObject, err := FindAttachedGroupObject(ctx, e, externalAnnotation.UserPoolID, externalAnnotation.Username, externalAnnotation.Groupname) if err != nil { return managed.ExternalObservation{}, errors.Wrap(err, errGet) } diff --git a/pkg/controller/cognitoidentityprovider/groupusermembership/controller_test.go b/pkg/controller/cognitoidentityprovider/groupusermembership/controller_test.go index 06fd53178a..46e6b6dea7 100644 --- a/pkg/controller/cognitoidentityprovider/groupusermembership/controller_test.go +++ b/pkg/controller/cognitoidentityprovider/groupusermembership/controller_test.go @@ -19,6 +19,7 @@ package groupusermembership import ( "context" "encoding/json" + "strings" "testing" "github.com/crossplane-contrib/provider-aws/apis/cognitoidentityprovider/manualv1alpha1" @@ -111,14 +112,17 @@ func TestObserve(t *testing.T) { args: args{ cognitoidentityprovider: &fake.MockGroupUserMembershipClient{ MockAdminListGroupsForUser: func(ctx context.Context, input *awscognitoidentityprovider.AdminListGroupsForUserInput, opts []func(*awscognitoidentityprovider.Options)) (*awscognitoidentityprovider.AdminListGroupsForUserOutput, error) { - return &awscognitoidentityprovider.AdminListGroupsForUserOutput{ - Groups: []awscognitoidentityprovidertypes.GroupType{ - { - GroupName: &groupName, - UserPoolId: &userPoolID, + if strings.Compare(*input.UserPoolId, userPoolID) == 0 && strings.Compare(*input.Username, Username) == 0 { + return &awscognitoidentityprovider.AdminListGroupsForUserOutput{ + Groups: []awscognitoidentityprovidertypes.GroupType{ + { + GroupName: &groupName, + UserPoolId: &userPoolID, + }, }, - }, - }, nil + }, nil + } + return nil, &awscognitoidentityprovidertypes.ResourceNotFoundException{} }, }, cr: userGroup(withExternalName(groupName, Username, userPoolID)),