fix: preserve pending support state on private profiles
Deploy olons-server production / deploy (push) Successful in 2m42s
Deploy olons-server production / deploy (push) Successful in 2m42s
This commit is contained in:
@@ -37,13 +37,15 @@ func (r *repositoryStub) SaveMemberIMIdentity(_ context.Context, identity *store
|
||||
}
|
||||
|
||||
type imStub struct {
|
||||
friendRequests int
|
||||
loginAttempts int
|
||||
resetPasswords int
|
||||
loginError error
|
||||
profileError error
|
||||
conversation *imclient.Conversation
|
||||
ensureP2PCalls int
|
||||
friendRequests int
|
||||
loginAttempts int
|
||||
resetPasswords int
|
||||
loginError error
|
||||
profileError error
|
||||
friendError error
|
||||
conversation *imclient.Conversation
|
||||
conversationErr error
|
||||
ensureP2PCalls int
|
||||
}
|
||||
|
||||
func (i *imStub) Ready() bool { return true }
|
||||
@@ -78,10 +80,16 @@ func (i *imStub) UserProfile(context.Context, string, string) (*imclient.UserPro
|
||||
}
|
||||
func (i *imStub) CreateFriendRequest(context.Context, string, string, string) (*imclient.FriendRequest, error) {
|
||||
i.friendRequests++
|
||||
if i.friendError != nil {
|
||||
return nil, i.friendError
|
||||
}
|
||||
return &imclient.FriendRequest{RequestID: "frq_1", Status: "accepted"}, nil
|
||||
}
|
||||
func (i *imStub) EnsureP2P(context.Context, string, string, string) (*imclient.Conversation, error) {
|
||||
i.ensureP2PCalls++
|
||||
if i.conversationErr != nil {
|
||||
return nil, i.conversationErr
|
||||
}
|
||||
if i.conversation != nil {
|
||||
return i.conversation, nil
|
||||
}
|
||||
@@ -132,8 +140,9 @@ func TestOpenSessionReturnsPendingWhenPrivateProfileHidesPendingRelationship(t *
|
||||
identity: &store.MemberIMIdentity{TenantID: 0, MemberID: 9, IMTenantCode: "allrich", IMUserID: "usr_member", IMUsername: "member01"},
|
||||
}
|
||||
im := &imStub{
|
||||
profileError: &imclient.Error{Status: 403, Reason: "PERMISSION_DENIED"},
|
||||
conversation: &imclient.Conversation{Topic: "p2p-topic", Relationship: "pending_outbound", CanSend: false},
|
||||
profileError: &imclient.Error{Status: 403, Reason: "PERMISSION_DENIED"},
|
||||
friendError: &imclient.Error{Status: 409, Reason: "FRIEND_REQUEST_CONFLICT"},
|
||||
conversationErr: &imclient.Error{Status: 403, Reason: "PERMISSION_DENIED"},
|
||||
}
|
||||
service := New(repository, im, config.AuthConfig{FinanceMasterKey: strings.Repeat("k", 32)})
|
||||
repository.identity.IMPasswordCipher, _ = service.encryptCredential("password")
|
||||
@@ -142,8 +151,8 @@ func TestOpenSessionReturnsPendingWhenPrivateProfileHidesPendingRelationship(t *
|
||||
if !errors.Is(err, ErrRelationPending) {
|
||||
t.Fatalf("error = %v, want ErrRelationPending", err)
|
||||
}
|
||||
if im.ensureP2PCalls != 1 || im.friendRequests != 0 {
|
||||
t.Fatalf("ensure p2p calls=%d friend requests=%d, want 1 and 0", im.ensureP2PCalls, im.friendRequests)
|
||||
if im.ensureP2PCalls != 0 || im.friendRequests != 1 {
|
||||
t.Fatalf("ensure p2p calls=%d friend requests=%d, want 0 and 1", im.ensureP2PCalls, im.friendRequests)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user