diff --git a/harness/fixtures/AppxManifest_Sparse.xml b/harness/fixtures/AppxManifest_Sparse.xml index 0f21d2d..4690328 100644 --- a/harness/fixtures/AppxManifest_Sparse.xml +++ b/harness/fixtures/AppxManifest_Sparse.xml @@ -8,7 +8,7 @@ xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10" IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10"> diff --git a/harness/fixtures/AppxManifest_arm64.xml b/harness/fixtures/AppxManifest_arm64.xml index 7c0d277..87f1643 100644 --- a/harness/fixtures/AppxManifest_arm64.xml +++ b/harness/fixtures/AppxManifest_arm64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron""/> HelloMSIX App Electron diff --git a/harness/fixtures/AppxManifest_x64.xml b/harness/fixtures/AppxManifest_x64.xml index 5e8e0c9..fbee1b8 100644 --- a/harness/fixtures/AppxManifest_x64.xml +++ b/harness/fixtures/AppxManifest_x64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron""/> HelloMSIX App Electron diff --git a/static/templates/create_dev_cert.ps1.in b/static/templates/create_dev_cert.ps1.in index 1d999d9..8853acf 100644 --- a/static/templates/create_dev_cert.ps1.in +++ b/static/templates/create_dev_cert.ps1.in @@ -1,5 +1,5 @@ # Customize these values -$subjectName = 'CN={{SubjectName}}' +$subjectName = 'CN="{{SubjectName}}"' $friendlyName = 'ELECTRON WINDOWS MSIX Dev Cert ($subjectName)' $yearsValid = 99 $pfxPasswordPlain = '{{Password}}' # Use a strong password diff --git a/test/e2e/fixtures/AppxManifest_Sparse.xml b/test/e2e/fixtures/AppxManifest_Sparse.xml index 3fea91a..d8eb955 100644 --- a/test/e2e/fixtures/AppxManifest_Sparse.xml +++ b/test/e2e/fixtures/AppxManifest_Sparse.xml @@ -8,7 +8,7 @@ xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10" IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10"> diff --git a/test/e2e/fixtures/AppxManifest_arm64.xml b/test/e2e/fixtures/AppxManifest_arm64.xml index e3c3fb5..2424c92 100644 --- a/test/e2e/fixtures/AppxManifest_arm64.xml +++ b/test/e2e/fixtures/AppxManifest_arm64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron MSIX""/> HelloMSIX App Electron diff --git a/test/e2e/fixtures/AppxManifest_x64.xml b/test/e2e/fixtures/AppxManifest_x64.xml index 963ee8d..8965bb4 100644 --- a/test/e2e/fixtures/AppxManifest_x64.xml +++ b/test/e2e/fixtures/AppxManifest_x64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron MSIX""/> HelloMSIX App Electron diff --git a/test/e2e/scripts/README.md b/test/e2e/scripts/README.md new file mode 100644 index 0000000..33cbd0d --- /dev/null +++ b/test/e2e/scripts/README.md @@ -0,0 +1,27 @@ +# E2E Test Scripts + +## Regenerating Test Certificate + +If you need to regenerate the test certificate (e.g., after changing the publisher name format): + +1. Run the generation script on Windows: + ```powershell + .\generate_test_cert.ps1 + ``` + +2. This will create/update: + - `test/e2e/fixtures/MSIXDevCert.pfx` (password: `Password123`) + - `test/e2e/fixtures/MSIXDevCert.cer` + +3. Commit the updated certificate files + +## Installing Test Certificate + +The test certificate is automatically installed when running e2e tests via the `installDevCert()` function. + +To manually install: +```powershell +.\install_test_cert.ps1 +``` + +This requires administrator privileges. diff --git a/test/e2e/scripts/generate_test_cert.ps1 b/test/e2e/scripts/generate_test_cert.ps1 new file mode 100644 index 0000000..8140ea2 --- /dev/null +++ b/test/e2e/scripts/generate_test_cert.ps1 @@ -0,0 +1,48 @@ +# Script to generate test certificate with quoted subject +# Run this script to regenerate MSIXDevCert.pfx and MSIXDevCert.cer + +$scriptDir = Split-Path -Parent $PSCommandPath +$certDir = Join-Path $scriptDir "..\fixtures" +$pfxPath = Join-Path $certDir "MSIXDevCert.pfx" +$cerPath = Join-Path $certDir "MSIXDevCert.cer" + +# Certificate parameters +$subjectName = 'CN="Electron MSIX"' +$friendlyName = 'MSIX Test Certificate' +$yearsValid = 99 +$password = 'Password123' +$pfxPassword = ConvertTo-SecureString -String $password -Force -AsPlainText + +Write-Host "Generating test certificate with subject: $subjectName" + +# Generate self-signed cert with private key (exportable) +$cert = New-SelfSignedCertificate ` + -FriendlyName $friendlyName ` + -DnsName "msix.test.electron" ` + -Subject $subjectName ` + -KeyExportPolicy Exportable ` + -KeyLength 2048 ` + -KeyUsage DigitalSignature ` + -Type CodeSigning ` + -KeySpec Signature ` + -NotAfter (Get-Date).AddYears($yearsValid) ` + -CertStoreLocation "cert:\CurrentUser\My" + +Write-Host "Certificate generated successfully" +Write-Host "Subject: $($cert.Subject)" +Write-Host "Thumbprint: $($cert.Thumbprint)" + +# Export public certificate (.cer) +Export-Certificate -Cert $cert -FilePath $cerPath -Force | Out-Null +Write-Host "Exported .cer to: $cerPath" + +# Export private certificate with password (.pfx) +Export-PfxCertificate -Cert $cert -FilePath $pfxPath -Password $pfxPassword -Force | Out-Null +Write-Host "Exported .pfx to: $pfxPath" + +# Remove the certificate from the personal store +Remove-Item -Path "cert:\CurrentUser\My\$($cert.Thumbprint)" -Force +Write-Host "Removed certificate from personal store" + +Write-Host "`nTest certificate generated successfully!" +Write-Host "Password: $password" diff --git a/test/e2e/signing.spec.ts b/test/e2e/signing.spec.ts index 9d53aee..eb8b67b 100644 --- a/test/e2e/signing.spec.ts +++ b/test/e2e/signing.spec.ts @@ -36,7 +36,7 @@ describe('signing', () => { it('should the cert should have the correct subject', async () => { const certSubject = await getCertSubject(path.join(__dirname, '..', '..', 'out', 'hellomsix_x64.msix')); - expect(certSubject).toBe('CN=Electron MSIX') + expect(certSubject).toBe('CN="Electron MSIX"') }); it('should not sign the app if sign is set to false', async () => { @@ -141,7 +141,7 @@ describe('signing', () => { it('should have the correct subject', async () => { const certSubject = await getCertSubject(path.join(__dirname, '..', '..', 'out', 'hellomsix_x64.msix')); - expect(certSubject).toBe('CN=Dev Publisher') + expect(certSubject).toBe('CN="Dev Publisher"') }); it('should use the generated dev cert with the provided password via environment variables', async () => { diff --git a/test/unit/fixtures/AppxManifest_Sparse.xml b/test/unit/fixtures/AppxManifest_Sparse.xml index 0f21d2d..4690328 100644 --- a/test/unit/fixtures/AppxManifest_Sparse.xml +++ b/test/unit/fixtures/AppxManifest_Sparse.xml @@ -8,7 +8,7 @@ xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10" IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10"> diff --git a/test/unit/fixtures/AppxManifest_arm64.xml b/test/unit/fixtures/AppxManifest_arm64.xml index 7c0d277..87f1643 100644 --- a/test/unit/fixtures/AppxManifest_arm64.xml +++ b/test/unit/fixtures/AppxManifest_arm64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron""/> HelloMSIX App Electron diff --git a/test/unit/fixtures/AppxManifest_x64.xml b/test/unit/fixtures/AppxManifest_x64.xml index 5e8e0c9..fbee1b8 100644 --- a/test/unit/fixtures/AppxManifest_x64.xml +++ b/test/unit/fixtures/AppxManifest_x64.xml @@ -10,7 +10,7 @@ + Publisher="CN="Electron""/> HelloMSIX App Electron diff --git a/test/unit/manifestation.spec.ts b/test/unit/manifestation.spec.ts index 0a6daab..2ddf998 100644 --- a/test/unit/manifestation.spec.ts +++ b/test/unit/manifestation.spec.ts @@ -48,7 +48,7 @@ describe('manifestation', () => { expect(manifestVars.manifestAppName).toBe('hellomsix'); expect(manifestVars.manifestPackageArch).toBe('x64'); expect(manifestVars.manifestIsSparsePackage).toBe(false); - expect(manifestVars.manifestPublisher).toBe('CN=Electron'); + expect(manifestVars.manifestPublisher).toBe('CN="Electron"'); expect(manifestVars.manifestOsMinVersion).toBe('10.0.17763.0'); }); @@ -95,7 +95,7 @@ describe('manifestation', () => { expect(appManifestIn).toMatch(//); + expect(appManifestIn).toMatch(/Publisher="CN="Electron""\/>/); expect(appManifestIn).toMatch(/HelloMSIX App<\/DisplayName>/); expect(appManifestIn).toMatch(/Electron<\/PublisherDisplayName>/); expect(appManifestIn).toMatch(/assets\\icon.png<\/Logo>/);