Skip to content
Closed
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
2 changes: 1 addition & 1 deletion harness/fixtures/AppxManifest_Sparse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10">
<Identity Name="Electron.20.0.Sparse"
Publisher="CN=Electron"
Publisher="CN=&quot;Electron&quot;"
ProcessorArchitecture="x64"
Version="1.0.0.0" />
<Properties>
Expand Down
2 changes: 1 addition & 1 deletion harness/fixtures/AppxManifest_arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="arm64"
Version="1.0.0.0"
Publisher="CN=Electron"/>
Publisher="CN=&quot;Electron&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion harness/fixtures/AppxManifest_x64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="x64"
Version="1.0.0.0"
Publisher="CN=Electron"/>
Publisher="CN=&quot;Electron&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion static/templates/create_dev_cert.ps1.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fixtures/AppxManifest_Sparse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10">
<Identity Name="hellomsix.Sparse"
Publisher="CN=Electron MSIX"
Publisher="CN=&quot;Electron MSIX&quot;"
ProcessorArchitecture="x64"
Version="1.2.3.4" />
<Properties>
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fixtures/AppxManifest_arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="arm64"
Version="1.2.3.4"
Publisher="CN=Electron MSIX"/>
Publisher="CN=&quot;Electron MSIX&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fixtures/AppxManifest_x64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="x64"
Version="1.2.3.4"
Publisher="CN=Electron MSIX"/>
Publisher="CN=&quot;Electron MSIX&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/scripts/README.md
Original file line number Diff line number Diff line change
@@ -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.
48 changes: 48 additions & 0 deletions test/e2e/scripts/generate_test_cert.ps1
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions test/e2e/signing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

it('should sign the msix', async () => {
const certStatus = await getCertStatus(path.join(__dirname, '..', '..', 'out', 'hellomsix_x64.msix'));
expect(certStatus).toBe('Valid')

Check failure on line 34 in test/e2e/signing.spec.ts

View workflow job for this annotation

GitHub Actions / e2e

test/e2e/signing.spec.ts > signing > signing with an existing cert > should sign the msix

AssertionError: expected '' to be 'Valid' // Object.is equality - Expected + Received - Valid ❯ test/e2e/signing.spec.ts:34:26
});

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"')

Check failure on line 39 in test/e2e/signing.spec.ts

View workflow job for this annotation

GitHub Actions / e2e

test/e2e/signing.spec.ts > signing > signing with an existing cert > should the cert should have the correct subject

AssertionError: expected '' to be 'CN="Electron MSIX"' // Object.is equality - Expected + Received - CN="Electron MSIX" ❯ test/e2e/signing.spec.ts:39:27
});

it('should not sign the app if sign is set to false', async () => {
Expand Down Expand Up @@ -141,7 +141,7 @@

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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/fixtures/AppxManifest_Sparse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
IgnorableNamespaces="uap uap2 uap3 rescap desktop uap10">
<Identity Name="Electron.20.0.Sparse"
Publisher="CN=Electron"
Publisher="CN=&quot;Electron&quot;"
ProcessorArchitecture="x64"
Version="1.0.0.0" />
<Properties>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/fixtures/AppxManifest_arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="arm64"
Version="1.0.0.0"
Publisher="CN=Electron"/>
Publisher="CN=&quot;Electron&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/fixtures/AppxManifest_x64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="Electron.MySuite.HelloMSIX"
ProcessorArchitecture="x64"
Version="1.0.0.0"
Publisher="CN=Electron"/>
Publisher="CN=&quot;Electron&quot;"/>
<Properties>
<DisplayName>HelloMSIX App</DisplayName>
<PublisherDisplayName>Electron</PublisherDisplayName>
Expand Down
4 changes: 2 additions & 2 deletions test/unit/manifestation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
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"');

Check failure on line 51 in test/unit/manifestation.spec.ts

View workflow job for this annotation

GitHub Actions / unit

test/unit/manifestation.spec.ts > manifestation > getManifestVariables > should read manifest variables from AppxManifest.xml correctly

AssertionError: expected 'CN=&quot;Electron&quot;' to be 'CN="Electron"' // Object.is equality Expected: "CN="Electron"" Received: "CN=&quot;Electron&quot;" ❯ test/unit/manifestation.spec.ts:51:46
expect(manifestVars.manifestOsMinVersion).toBe('10.0.17763.0');
});

Expand Down Expand Up @@ -95,7 +95,7 @@
expect(appManifestIn).toMatch(/<Identity Name="Electron.MySuite.HelloMSIX"/);
expect(appManifestIn).toMatch(/ProcessorArchitecture="x64"/);
expect(appManifestIn).toMatch(/Version="1.0.0.0"/);
expect(appManifestIn).toMatch(/Publisher="CN=Electron"\/>/);
expect(appManifestIn).toMatch(/Publisher="CN=&quot;Electron&quot;"\/>/);
expect(appManifestIn).toMatch(/<DisplayName>HelloMSIX App<\/DisplayName>/);
expect(appManifestIn).toMatch(/<PublisherDisplayName>Electron<\/PublisherDisplayName>/);
expect(appManifestIn).toMatch(/<Logo>assets\\icon.png<\/Logo>/);
Expand Down
Loading