Skip to content

Commit 4bca979

Browse files
Web3NLclaude
andcommitted
fix: configure my-notepad II principal and controllers in validation pipeline
The setup script only configured my-hello-world after deploy, leaving my-notepad without an II principal or controller setup. This caused login to silently fail — the manage_ii_principal guard rejected the user's call since their II principal was never added as a controller. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ed1b3b9 commit 4bca979

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

scripts/constants.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@ export CANISTER_INITIAL_CYCLES="1000000000000"
1010

1111
# Canister names
1212
export HELLO_WORLD_CANISTER="my-hello-world"
13+
export NOTEPAD_CANISTER="my-notepad"
1314
export WASM_REGISTRY_CANISTER="wasm-registry"
1415
export DEMOS_CANISTER="demos"
1516

1617
# Test environment origins (canister origin is set dynamically after canister creation)
1718
export DAPP_ORIGIN_VITE="http://localhost:5173"
1819

19-
# Resolve DAPP_ORIGIN_CANISTER from test.env if it exists (set during setup)
20+
# Resolve canister origins from test.env if it exists (set during setup)
2021
if [ -f "$REPO_ROOT/tests/test.env" ]; then
2122
HELLO_WORLD_ID=$(grep VITE_MY_HELLO_WORLD_CANISTER_ID "$REPO_ROOT/tests/test.env" | cut -d '=' -f2 || true)
2223
if [ -n "$HELLO_WORLD_ID" ]; then
2324
export DAPP_ORIGIN_CANISTER="http://${HELLO_WORLD_ID}.localhost:8080"
2425
fi
26+
27+
NOTEPAD_ID=$(grep VITE_MY_NOTEPAD_CANISTER_ID "$REPO_ROOT/tests/test.env" | cut -d '=' -f2 || true)
28+
if [ -n "$NOTEPAD_ID" ]; then
29+
export DAPP_ORIGIN_NOTEPAD="http://${NOTEPAD_ID}.localhost:8080"
30+
fi
2531
fi

scripts/setup-dashboard-dev-env.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@ echo "Setting up dashboard development environment..."
1313
HELLO_WORLD_ID=$(icp canister status my-hello-world -e local --id-only)
1414
DAPP_ORIGIN_CANISTER="http://${HELLO_WORLD_ID}.localhost:8080"
1515

16+
NOTEPAD_ID=$(icp canister status my-notepad -e local --id-only)
17+
DAPP_ORIGIN_NOTEPAD="http://${NOTEPAD_ID}.localhost:8080"
18+
1619
APP_ID=$(icp canister status icp-dapp-launcher -e local --id-only)
1720
DAPP_ORIGIN_APP="http://${APP_ID}.localhost:8080"
1821

1922
echo "Running Internet Identity setup..."
2023
npx playwright install
2124
DAPP_ORIGIN_VITE="$DAPP_ORIGIN_VITE" \
2225
DAPP_ORIGIN_CANISTER="$DAPP_ORIGIN_CANISTER" \
26+
DAPP_ORIGIN_NOTEPAD="$DAPP_ORIGIN_NOTEPAD" \
2327
DAPP_ORIGIN_APP="$DAPP_ORIGIN_APP" \
2428
npm run test:setup-ii
2529

2630
echo "Reading principals..."
2731
PRINCIPAL_VITE=$(cat tests/output/derived-ii-principal-vite.txt)
2832
PRINCIPAL_CANISTER=$(cat tests/output/derived-ii-principal-canister.txt)
33+
PRINCIPAL_NOTEPAD=$(cat tests/output/derived-ii-principal-notepad.txt)
2934
PRINCIPAL_APP=$(cat tests/output/derived-ii-principal-app.txt)
3035
IDENT1=$(icp identity principal --identity ident-1)
3136

@@ -37,9 +42,20 @@ icp canister settings update "$HELLO_WORLD_CANISTER" -e local --identity ident-1
3742
--set-controller "$IDENT1" \
3843
-f
3944

40-
echo "Setting authorized Internet Identity principal (Vite origin for first E2E batch)..."
45+
echo "Setting authorized Internet Identity principal for $HELLO_WORLD_CANISTER (Vite origin for first E2E batch)..."
4146
icp canister call "$HELLO_WORLD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_VITE\" })" -e local --identity ident-1
4247

48+
echo "Setting controllers for $NOTEPAD_CANISTER canister..."
49+
icp canister settings update "$NOTEPAD_CANISTER" -e local --identity ident-1 \
50+
--set-controller "$NOTEPAD_ID" \
51+
--set-controller "$PRINCIPAL_VITE" \
52+
--set-controller "$PRINCIPAL_NOTEPAD" \
53+
--set-controller "$IDENT1" \
54+
-f
55+
56+
echo "Setting authorized Internet Identity principal for $NOTEPAD_CANISTER (Vite origin for first E2E batch)..."
57+
icp canister call "$NOTEPAD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_VITE\" })" -e local --identity ident-1
58+
4359
echo "Setting demos canister admins..."
4460
icp canister call demos set_admins "(vec { principal \"$PRINCIPAL_APP\" })" -e local --identity ident-1
4561

scripts/write-test-env.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cd "$REPO_ROOT"
1212

1313
II_CANISTER_ID="rdmx6-jaaaa-aaaaa-aaadq-cai"
1414
HELLO_WORLD_ID=$(icp canister status my-hello-world -e local --id-only 2>/dev/null || echo "")
15+
NOTEPAD_ID=$(icp canister status my-notepad -e local --id-only 2>/dev/null || echo "")
1516
APP_CANISTER_ID=$(icp canister status icp-dapp-launcher -e local --id-only 2>/dev/null || echo "")
1617

1718
# Write test.env with discovered canister IDs
@@ -25,6 +26,11 @@ if [ -n "$HELLO_WORLD_ID" ]; then
2526
echo "VITE_MY_HELLO_WORLD_CANISTER_ID=${HELLO_WORLD_ID}" >> tests/test.env
2627
fi
2728

29+
# Add notepad canister ID if it exists
30+
if [ -n "$NOTEPAD_ID" ]; then
31+
echo "VITE_MY_NOTEPAD_CANISTER_ID=${NOTEPAD_ID}" >> tests/test.env
32+
fi
33+
2834
# Add app canister ID if it exists
2935
if [ -n "$APP_CANISTER_ID" ]; then
3036
echo "VITE_ICP_DAPP_LAUNCHER_CANISTER_ID=${APP_CANISTER_ID}" >> tests/test.env

tests/ii-setup/setup-ii.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test.describe('setup II identity and derive principals', () => {
2323
const origins = [
2424
{ origin: process.env.DAPP_ORIGIN_VITE!, envSuffix: 'vite' },
2525
{ origin: process.env.DAPP_ORIGIN_CANISTER!, envSuffix: 'canister' },
26+
{ origin: process.env.DAPP_ORIGIN_NOTEPAD!, envSuffix: 'notepad' },
2627
{ origin: process.env.DAPP_ORIGIN_APP!, envSuffix: 'app' },
2728
];
2829

0 commit comments

Comments
 (0)