-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix widgets not working when bound to the same listener as webhooks. (#…
…872) * Bind listener in bridge. * Add a test to confirm behaviour * Fix test name * changelog
- Loading branch information
Showing
7 changed files
with
68 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix widgets not loading when bound to the same listener as "webhooks". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { E2ESetupTestTimeout, E2ETestEnv } from "./util/e2e-test"; | ||
import { describe, it, beforeEach, afterEach } from "@jest/globals"; | ||
import { BridgeAPI } from "../web/BridgeAPI"; | ||
import { WidgetApi } from "matrix-widget-api"; | ||
|
||
describe('Widgets', () => { | ||
let testEnv: E2ETestEnv; | ||
|
||
beforeEach(async () => { | ||
const webhooksPort = 9500 + E2ETestEnv.workerId; | ||
testEnv = await E2ETestEnv.createTestEnv({matrixLocalparts: ['user'], config: { | ||
widgets: { | ||
publicUrl: `http://localhost:${webhooksPort}` | ||
}, | ||
listeners: [{ | ||
port: webhooksPort, | ||
bindAddress: '0.0.0.0', | ||
// Bind to the SAME listener to ensure we don't have conflicts. | ||
resources: ['webhooks', 'widgets'], | ||
}], | ||
|
||
}}); | ||
await testEnv.setUp(); | ||
}, E2ESetupTestTimeout); | ||
|
||
afterEach(() => { | ||
return testEnv?.tearDown(); | ||
}); | ||
|
||
it('should be able to authenticate with the widget API', async () => { | ||
const user = testEnv.getUser('user'); | ||
const bridgeApi = await BridgeAPI.getBridgeAPI(testEnv.opts.config?.widgets?.publicUrl!, { | ||
requestOpenIDConnectToken: () => { | ||
return user.getOpenIDConnectToken() | ||
}, | ||
} as unknown as WidgetApi, { | ||
getItem() { return null}, | ||
setItem() { }, | ||
} as unknown as Storage); | ||
expect(await bridgeApi.verify()).toEqual({ | ||
"type": "widget", | ||
"userId": "@user:hookshot", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters