diff --git a/internal/device/pool_esim_switch.go b/internal/device/pool_esim_switch.go index 337abe74..eeaa0309 100644 --- a/internal/device/pool_esim_switch.go +++ b/internal/device/pool_esim_switch.go @@ -1080,6 +1080,7 @@ func (p *Pool) handleESIMSwitchAfter(deviceID string, token uint64) { p.restorePostSwitchConnectivity(deviceID, worker, snapshot, identityRefreshErr, false) return } + p.resolveAndApplyPolicy(worker, "esim_switched") p.schedulePostSwitchIdentityRefreshes(deviceID, snapshot) var restoreGateErr error if worker.Config.VoWiFiEnabled { diff --git a/internal/device/pool_esim_switch_restore_test.go b/internal/device/pool_esim_switch_restore_test.go index f1a81fe6..9360e2c8 100644 --- a/internal/device/pool_esim_switch_restore_test.go +++ b/internal/device/pool_esim_switch_restore_test.go @@ -505,6 +505,9 @@ func TestHandleESIMSwitchAfterSubmitsSwitchEndThroughLifecycleController(t *test func TestHandleESIMSwitchAfterRadioCycleOnlineThenSnapshotRestore(t *testing.T) { p := NewPool(&config.Config{}) + p.SetPolicyResolver(&stubPolicyResolver{pol: cardpolicy.Policy{ + ICCID: "460001234567890", IPVersion: "v4v6", APN: "new-card-apn", + }}) be := &esimSwitchRestoreBackendStub{ mode: backend.BackendQMI, getMode: backend.ModeOnline, @@ -534,6 +537,15 @@ func TestHandleESIMSwitchAfterRadioCycleOnlineThenSnapshotRestore(t *testing.T) if !reflect.DeepEqual(be.setCalls, want) { t.Fatalf("setCalls=%v want %v", be.setCalls, want) } + if w.CurrentICCID() != "460001234567890" { + t.Fatalf("current ICCID=%q", w.CurrentICCID()) + } + if w.Config.IPVersion != "v4v6" || w.Config.APN != "new-card-apn" { + t.Fatalf("new card policy was not projected: %+v", w.Config) + } + if w.Config.NetworkEnabled || w.Config.VoWiFiEnabled || w.Config.AirplaneEnabled { + t.Fatalf("new card policy switches were not projected: %+v", w.Config) + } } func TestHandleESIMSwitchAfterRecoversSIMAuthBeforeVoWiFiRestore(t *testing.T) {