Skip to content

Commit

Permalink
runfix: mls calls on non-fed env [WPB-9710] (#6290)
Browse files Browse the repository at this point in the history
* runfix: don't use domain in non-fed env mls calls

* test: generate subconversation info for non fed env
  • Loading branch information
PatrykBuniX committed Jun 13, 2024
1 parent 7106e50 commit 4fd1196
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const getSubconversationResponse = ({
};
};

const buildSubconversationService = async () => {
const buildSubconversationService = async (isFederated = false) => {
const apiClient = new APIClient({urls: APIClient.BACKEND.STAGING});
apiClient.backendFeatures.isFederated = isFederated;

const mlsService = {
conversationExists: jest.fn(),
wipeConversation: jest.fn(),
Expand Down Expand Up @@ -383,8 +385,8 @@ describe('SubconversationService', () => {
expect(response).toEqual(null);
});

it('returns epoch info and advances epoch number', async () => {
const [subconversationService, {mlsService}] = await buildSubconversationService();
it.each([true, false])('returns epoch info and advances epoch number', async (isFederated: boolean) => {
const [subconversationService, {mlsService}] = await buildSubconversationService(isFederated);

const parentConversationId = {id: 'parentConversationId', domain: 'domain'};
const parentConversationGroupId = 'parentConversationGroupId';
Expand Down Expand Up @@ -437,8 +439,8 @@ describe('SubconversationService', () => {
epoch: mockedEpoch,
keyLength: 32,
members: [
{clientid: 'clientId1', in_subconv: true, userid: 'userId1@domain'},
{clientid: 'clientId2', in_subconv: false, userid: 'userId2@domain'},
{clientid: 'clientId1', in_subconv: true, userid: isFederated ? 'userId1@domain' : 'userId1'},
{clientid: 'clientId2', in_subconv: false, userid: isFederated ? 'userId2@domain' : 'userId2'},
],
secretKey: mockedSecretKey,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Events = {
};

export interface SubconversationEpochInfoMember {
userid: `${string}@${string}`;
userid: string;
clientid: string;
in_subconv: boolean;
}
Expand Down Expand Up @@ -330,7 +330,9 @@ export class SubconversationService extends TypedEventEmitter<Events> {
);

return {
userid: `${parentMember.userId}@${parentMember.domain}`,
userid: this.apiClient.backendFeatures.isFederated
? `${parentMember.userId}@${parentMember.domain}`
: parentMember.userId,
clientid: parentMember.clientId,
in_subconv: isSubconversationMember,
};
Expand Down

0 comments on commit 4fd1196

Please sign in to comment.