Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions tests/strategy_switch_worker_validation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assert.ok(indexHtml.includes('switchSurface.classList.toggle("summary-hidden", !
assert.equal(indexHtml.includes("publicSummary"), false);
assert.ok(indexHtml.includes("function hasPrivateConfig()"));
assert.ok(indexHtml.includes('el("quick-form").hidden = !showPrivateControls'));
assert.equal(indexHtml.includes("u15998061"), false);
assert.equal(indexHtml.includes("ibkr-primary"), false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep checking the original IBKR IDs are absent

Because the sanitization goal is to prevent the real-looking IBKR account identifiers from leaking into the public page, replacing this assertion with the new placeholder weakens the regression test: if index.html or the served HTML accidentally reintroduces u15998061 later, this check still passes as long as ibkr-primary is absent. Keep an assertion for the removed sensitive identifier(s) in addition to any placeholder check so the test continues to cover the leak this commit is meant to prevent.

Useful? React with 👍 / 👎.

assert.equal(indexHtml.includes("longbridge-quant-sg-service"), false);
assert.equal(indexHtml.includes('account_selector: "SG"'), false);
assert.match(indexHtml, /body\.app-loading \.shell\s*\{\s*display: none;/);
Expand All @@ -28,7 +28,7 @@ const servedPageResponse = await worker.fetch(new Request("https://switch.exampl
const servedHtml = await servedPageResponse.text();
assert.equal(servedPageResponse.status, 200);
assert.ok(servedHtml.includes("function hasPrivateConfig()"));
assert.equal(servedHtml.includes("u15998061"), false);
assert.equal(servedHtml.includes("ibkr-primary"), false);
assert.equal(servedHtml.includes("longbridge-quant-sg-service"), false);
assert.equal(servedHtml.includes('account_selector: "SG"'), false);

Expand Down Expand Up @@ -131,13 +131,13 @@ const accountOptions = __test.normalizeAccountOptionsPayload(
],
ibkr: [
{
key: "u15998061",
label: "u15998061",
target_name: "u15998061",
account_selector: "U15998061",
deployment_selector: "live-u1599-tqqq",
account_scope: "live-u1599-tqqq",
service_name: "interactive-brokers-live-u1599-tqqq-service",
key: "ibkr-primary",
label: "ibkr-primary",
target_name: "ibkr-primary",
account_selector: "DEMO_IBKR_PRIMARY",
deployment_selector: "demo-ibkr-tqqq",
account_scope: "demo-ibkr-tqqq",
service_name: "interactive-brokers-demo-ibkr-tqqq-service",
},
],
schwab: [
Expand Down Expand Up @@ -260,11 +260,11 @@ __test.assertStrategyAllowedForAccount(
const ibkrAccount = __test.assertConfiguredAccount(
{
platform: "ibkr",
target_name: "u15998061",
account_selector: "U15998061",
deployment_selector: "live-u1599-tqqq",
account_scope: "live-u1599-tqqq",
service_name: "interactive-brokers-live-u1599-tqqq-service",
target_name: "ibkr-primary",
account_selector: "DEMO_IBKR_PRIMARY",
deployment_selector: "demo-ibkr-tqqq",
account_scope: "demo-ibkr-tqqq",
service_name: "interactive-brokers-demo-ibkr-tqqq-service",
strategy_profile: "tqqq_growth_income",
},
accountOptions,
Expand Down
48 changes: 24 additions & 24 deletions tests/test_runtime_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,30 @@ def test_build_switch_target_patches_ibkr_service_targets_json(self):
"defaults": {"NOTIFY_LANG": "zh"},
"targets": [
{
"service": "interactive-brokers-live-u1599-tqqq-service",
"ACCOUNT_GROUP": "live-u1599-tqqq",
"service": "interactive-brokers-demo-ibkr-tqqq-service",
"ACCOUNT_GROUP": "demo-ibkr-tqqq",
"runtime_target": {
"platform_id": "ibkr",
"strategy_profile": "old_strategy",
"dry_run_only": False,
"deployment_selector": "live-u1599-tqqq",
"account_selector": ["U15998061"],
"account_scope": "live-u1599-tqqq",
"service_name": "interactive-brokers-live-u1599-tqqq-service",
"deployment_selector": "demo-ibkr-tqqq",
"account_selector": ["DEMO_IBKR_PRIMARY"],
"account_scope": "demo-ibkr-tqqq",
"service_name": "interactive-brokers-demo-ibkr-tqqq-service",
"execution_mode": "live",
},
},
{
"service": "interactive-brokers-live-u1660-soxl-service",
"ACCOUNT_GROUP": "live-u1660-soxl",
"service": "interactive-brokers-demo-ibkr-soxl-service",
"ACCOUNT_GROUP": "demo-ibkr-soxl",
"runtime_target": {
"platform_id": "ibkr",
"strategy_profile": "soxl_soxx_trend_income",
"dry_run_only": False,
"deployment_selector": "live-u1660-soxl",
"account_selector": ["U16608560"],
"account_scope": "live-u1660-soxl",
"service_name": "interactive-brokers-live-u1660-soxl-service",
"deployment_selector": "demo-ibkr-soxl",
"account_selector": ["DEMO_IBKR_SOXL"],
"account_scope": "demo-ibkr-soxl",
"service_name": "interactive-brokers-demo-ibkr-soxl-service",
"execution_mode": "live",
},
},
Expand All @@ -292,13 +292,13 @@ def test_build_switch_target_patches_ibkr_service_targets_json(self):
"--platform",
"ibkr",
"--target-name",
"live-u1599-tqqq",
"demo-ibkr-tqqq",
"--strategy-profile",
"tqqq_growth_income",
"--account-selector",
"U15998061",
"DEMO_IBKR_PRIMARY",
"--service-name",
"interactive-brokers-live-u1599-tqqq-service",
"interactive-brokers-demo-ibkr-tqqq-service",
"--existing-service-targets-json-file",
str(path),
]
Expand All @@ -324,16 +324,16 @@ def test_build_switch_target_patches_ibkr_service_targets_with_empty_plugin_moun
existing = {
"targets": [
{
"service": "interactive-brokers-live-u1599-tqqq-service",
"ACCOUNT_GROUP": "live-u1599-tqqq",
"service": "interactive-brokers-demo-ibkr-tqqq-service",
"ACCOUNT_GROUP": "demo-ibkr-tqqq",
"runtime_target": {
"platform_id": "ibkr",
"strategy_profile": "tqqq_growth_income",
"dry_run_only": False,
"deployment_selector": "live-u1599-tqqq",
"account_selector": ["U15998061"],
"account_scope": "live-u1599-tqqq",
"service_name": "interactive-brokers-live-u1599-tqqq-service",
"deployment_selector": "demo-ibkr-tqqq",
"account_selector": ["DEMO_IBKR_PRIMARY"],
"account_scope": "demo-ibkr-tqqq",
"service_name": "interactive-brokers-demo-ibkr-tqqq-service",
"execution_mode": "live",
},
"IBKR_STRATEGY_PLUGIN_MOUNTS_JSON": {
Expand All @@ -359,13 +359,13 @@ def test_build_switch_target_patches_ibkr_service_targets_with_empty_plugin_moun
"--platform",
"ibkr",
"--target-name",
"live-u1599-tqqq",
"demo-ibkr-tqqq",
"--strategy-profile",
"soxl_soxx_trend_income",
"--account-selector",
"U15998061",
"DEMO_IBKR_PRIMARY",
"--service-name",
"interactive-brokers-live-u1599-tqqq-service",
"interactive-brokers-demo-ibkr-tqqq-service",
"--existing-service-targets-json-file",
str(path),
]
Expand Down
14 changes: 7 additions & 7 deletions web/strategy-switch-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ Each account item supports:

```json
{
"key": "u15998061",
"label": "u15998061",
"target_name": "u15998061",
"account_selector": "U15998061",
"deployment_selector": "live-u1599-tqqq",
"account_scope": "live-u1599-tqqq",
"service_name": "interactive-brokers-live-u1599-tqqq-service",
"key": "ibkr-primary",
"label": "ibkr-primary",
"target_name": "ibkr-primary",
"account_selector": "DEMO_IBKR_PRIMARY",
"deployment_selector": "demo-ibkr-tqqq",
"account_scope": "demo-ibkr-tqqq",
"service_name": "interactive-brokers-demo-ibkr-tqqq-service",
"default_strategy_profile": "tqqq_growth_income",
"supported_domains": ["us_equity", "hk_equity"]
}
Expand Down
14 changes: 7 additions & 7 deletions web/strategy-switch-console/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ wrangler secret put STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON < /tmp/strategy-switch-

```json
{
"key": "u15998061",
"label": "u15998061",
"target_name": "u15998061",
"account_selector": "U15998061",
"deployment_selector": "live-u1599-tqqq",
"account_scope": "live-u1599-tqqq",
"service_name": "interactive-brokers-live-u1599-tqqq-service",
"key": "ibkr-primary",
"label": "ibkr-primary",
"target_name": "ibkr-primary",
"account_selector": "DEMO_IBKR_PRIMARY",
"deployment_selector": "demo-ibkr-tqqq",
"account_scope": "demo-ibkr-tqqq",
"service_name": "interactive-brokers-demo-ibkr-tqqq-service",
"default_strategy_profile": "tqqq_growth_income",
"supported_domains": ["us_equity", "hk_equity"]
}
Expand Down
42 changes: 21 additions & 21 deletions web/strategy-switch-console/account-options.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@
],
"ibkr": [
{
"key": "u15998061",
"label": "u15998061",
"target_name": "u15998061",
"account_selector": "U15998061",
"deployment_selector": "live-u1599-tqqq",
"account_scope": "live-u1599-tqqq",
"service_name": "interactive-brokers-live-u1599-tqqq-service",
"key": "ibkr-primary",
"label": "ibkr-primary",
"target_name": "ibkr-primary",
"account_selector": "DEMO_IBKR_PRIMARY",
"deployment_selector": "demo-ibkr-tqqq",
"account_scope": "demo-ibkr-tqqq",
"service_name": "interactive-brokers-demo-ibkr-tqqq-service",
"default_strategy_profile": "tqqq_growth_income",
"supported_domains": ["us_equity", "hk_equity"]
},
{
"key": "u16608560",
"label": "u16608560",
"target_name": "u16608560",
"account_selector": "U16608560",
"deployment_selector": "live-u1660-soxl",
"account_scope": "live-u1660-soxl",
"service_name": "interactive-brokers-live-u1660-soxl-service",
"key": "ibkr-soxl",
"label": "ibkr-soxl",
"target_name": "ibkr-soxl",
"account_selector": "DEMO_IBKR_SOXL",
"deployment_selector": "demo-ibkr-soxl",
"account_scope": "demo-ibkr-soxl",
"service_name": "interactive-brokers-demo-ibkr-soxl-service",
"default_strategy_profile": "soxl_soxx_trend_income",
"supported_domains": ["us_equity", "hk_equity"]
},
{
"key": "u18336562",
"label": "u18336562",
"target_name": "u18336562",
"account_selector": "U18336562",
"deployment_selector": "live-u1833-smart-dca",
"account_scope": "live-u1833-smart-dca",
"service_name": "interactive-brokers-live-u1833-smart-dca-service",
"key": "ibkr-dca",
"label": "ibkr-dca",
"target_name": "ibkr-dca",
"account_selector": "DEMO_IBKR_DCA",
"deployment_selector": "demo-ibkr-dca",
"account_scope": "demo-ibkr-dca",
"service_name": "interactive-brokers-demo-ibkr-dca-service",
"default_strategy_profile": "nasdaq_sp500_smart_dca",
"supported_domains": ["us_equity", "hk_equity"]
}
Expand Down