-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handling broadcast and private channel broadcast separately
- Loading branch information
Showing
9 changed files
with
137 additions
and
46 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
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,24 @@ | ||
Feature: Relaying Private Channel Broadcast messages | ||
|
||
Background: | ||
Given A newly instantiated FDC3 Server | ||
|
||
Scenario: Broadcast message to no-one | ||
When "App1/a1" broadcasts "fdc3.instrument" on private channel "channel1" | ||
Then messaging will have outgoing posts | ||
| msg.source.AppId | | ||
And messaging will have 0 posts | ||
|
||
Scenario: Broadcast message sent to one listener | ||
When "App2/a2" adds a context listener on private channel "channel1" with type "fdc3.instrument" | ||
And "App1/a1" broadcasts "fdc3.instrument" on private channel "channel1" | ||
Then messaging will have outgoing posts | ||
| msg.meta.source.appId | msg.meta.source.instanceId | msg.payload.context.type | msg.meta.destination.appId | msg.meta.destination.instanceId | | ||
| App1 | a1 | fdc3.instrument | App2 | a2 | | ||
|
||
Scenario: Broadcast message sent but listener has unsubscribed | ||
When "App2/a2" adds a context listener on private channel "channel1" with type "fdc3.instrument" | ||
And "App2/a2" removes context listener on private channel "channel1" with type "fdc3.instrument" | ||
And "App1/a1" broadcasts "fdc3.instrument" on private channel "channel1" | ||
Then messaging will have outgoing posts | ||
| msg.source.AppId | msg.source.instanceId | msg.payload.context.type | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { When } from '@cucumber/cucumber' | ||
import { CustomWorld } from '../world'; | ||
import { ConnectionStep2Hello } from "@finos/fdc3/dist/bridging/BridgingTypes"; | ||
import { createMeta } from './generic.steps'; | ||
|
||
When('{string} sends hello', function (this: CustomWorld, app: string) { | ||
const meta = createMeta(this, app) | ||
const message: ConnectionStep2Hello = { | ||
type: 'hello', | ||
meta: { | ||
timestamp: new Date() | ||
}, | ||
payload: { | ||
authRequired: false, | ||
desktopAgentBridgeVersion: "1.0", | ||
supportedFDC3Versions: ["2.0", "2.1"] | ||
} | ||
} | ||
|
||
this.server.receive(message, meta.source) | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/da-server/test/step-definitions/messaging.steps.ts
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,20 @@ | ||
import { DataTable, Then } from '@cucumber/cucumber' | ||
import { CustomWorld } from '../world'; | ||
import { matchData } from '../support/matching'; | ||
import expect from "expect"; | ||
|
||
|
||
|
||
Then('messaging will have outgoing posts', function (this: CustomWorld, dt: DataTable) { | ||
// just take the last few posts and match those | ||
const matching = dt.rows().length | ||
var toUse = this.sc?.postedMessages | ||
if (toUse.length > matching) { | ||
toUse = toUse.slice(toUse.length - matching, toUse.length) | ||
} | ||
matchData(this, toUse, dt) | ||
}) | ||
|
||
Then('messaging will have {int} posts', function (this: CustomWorld, count: number) { | ||
expect(this.sc.postedMessages.length).toEqual(count) | ||
}) |
47 changes: 47 additions & 0 deletions
47
packages/da-server/test/step-definitions/private-channel.steps.ts
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,47 @@ | ||
import { When } from '@cucumber/cucumber' | ||
import { CustomWorld } from '../world'; | ||
import { PrivateChannelOnAddContextListenerAgentRequest, PrivateChannelOnUnsubscribeAgentRequest, PrivateChannelBroadcastAgentRequest } from "@finos/fdc3/dist/bridging/BridgingTypes"; | ||
import { contextMap, createMeta } from './generic.steps'; | ||
|
||
|
||
When('{string} adds a context listener on private channel {string} with type {string}', function (this: CustomWorld, app: string, channelId: string, contextType: string) { | ||
const meta = createMeta(this, app) | ||
const message = { | ||
meta, | ||
payload: { | ||
channelId, | ||
contextType | ||
}, | ||
type: 'PrivateChannel.onAddContextListener' | ||
} as PrivateChannelOnAddContextListenerAgentRequest | ||
|
||
this.server.receive(message, meta.source) | ||
}) | ||
|
||
When('{string} removes context listener on private channel {string} with type {string}', function (this: CustomWorld, app: string, channelId: string, contextType: string) { | ||
const meta = createMeta(this, app) | ||
const message = { | ||
meta, | ||
payload: { | ||
channelId, | ||
contextType | ||
}, | ||
type: 'PrivateChannel.onUnsubscribe' | ||
} as PrivateChannelOnUnsubscribeAgentRequest | ||
|
||
this.server.receive(message, meta.source) | ||
}) | ||
|
||
When('{string} broadcasts {string} on private channel {string}', function (this: CustomWorld, app: string, contextType: string, channelId: string) { | ||
const meta = createMeta(this, app) | ||
const message = { | ||
meta, | ||
payload: { | ||
channelId, | ||
context: contextMap[contextType] | ||
}, | ||
type: 'PrivateChannel.broadcast' | ||
} as PrivateChannelBroadcastAgentRequest | ||
|
||
this.server.receive(message, meta.source) | ||
}) |
File renamed without changes.