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
16 changes: 16 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,22 @@ calls and kind nodes must carry their own explicit bounds.
is moved aside. This is native candidate capsule recovery, not restore of the installer's
pre-upgrade claim copy or offboarding/meeting delivery qualification.

- With `KYQ_TEST_NOTES_BROWSER=1` and historical release manifests, the NPM joins test
uses explicit Node/Playwright module and Firefox executable paths to drive the old
bundled Notes client through everyday OIDC sign-in, action-bound confirmation, device
key enrollment, saved recovery copy and encrypted notebook/page creation. An isolated
private-CA browser profile retains client keys across the CLI upgrade; fresh sessions
must decrypt exact old content, save an edit and decrypt it after reloading. Content
request bodies and stored ciphertext must exclude the plaintext markers. Where BiDi
omits request bodies, observe bounded copies of native fetch arguments and compare sent
ciphertext hashes with the stored object. The observer preserves native arguments,
headers and responses and supplies no credentials or confirmation shortcuts. Before candidate
reads, explicitly save and prove pending queues empty; clear only the owned note cache,
preserving byte-identical client key records, so cached plaintext cannot satisfy the read. Browser launch
wrappers may enforce host bounds separately while the single campaign holds its lock;
preserve the Go task cap and approved browser-only cap. This does not qualify offboarding
or recovery from loss of the client's keys.

- With `KYQ_TEST_MESSAGE_UPGRADE_MANIFEST` naming an independently attested historical
KyMessages manifest and its sibling Compose template, `TestKubernetesKyMessage` starts
the complete old catalog entry with explicit fixture transport/CA plumbing, exchanges
Expand Down
440 changes: 96 additions & 344 deletions docs/RELEASE-ACCEPTANCE-2026-11-17-MAJOR.md

Large diffs are not rendered by default.

574 changes: 97 additions & 477 deletions docs/release-candidate-2026-11-17-major.json

Large diffs are not rendered by default.

388 changes: 388 additions & 0 deletions test/e2e/notes_browser.mjs

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions test/e2e/notes_browser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
//go:build e2e

package e2e

import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/json"
"encoding/pem"
"math/big"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

"github.com/Busnes-app/kyquickstart/internal/kube"
)

// browserEdgeCertificate keeps normal fixture behavior unless the real browser case is selected.
// Browsers need an actual issuing CA, rather than peer trust in a self-signed server leaf.
func browserEdgeCertificate(t *testing.T) ([]byte, []byte) {
t.Helper()
if os.Getenv("KYQ_TEST_NOTES_BROWSER") != "1" {
return testCertificate(t)
}
caKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
t.Fatal(err)
}
ca := &x509.Certificate{SerialNumber: big.NewInt(11), Subject: pkix.Name{CommonName: "owned Notes acceptance CA"}, NotBefore: time.Now().Add(-time.Hour), NotAfter: time.Now().Add(24 * time.Hour), IsCA: true, BasicConstraintsValid: true, KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageCRLSign}
caDER, err := x509.CreateCertificate(rand.Reader, ca, ca, &caKey.PublicKey, caKey)
if err != nil {
t.Fatal(err)
}
key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
t.Fatal(err)
}
leaf := &x509.Certificate{SerialNumber: big.NewInt(12), Subject: pkix.Name{CommonName: "*.example.test"}, DNSNames: []string{"*.example.test"}, NotBefore: ca.NotBefore, NotAfter: ca.NotAfter, BasicConstraintsValid: true, KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}}
der, err := x509.CreateCertificate(rand.Reader, leaf, ca, &key.PublicKey, caKey)
if err != nil {
t.Fatal(err)
}
chain := append(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}), pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER})...)
return chain, pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)})
}

// seedNotesBrowser uses only the published old client's UI and returns the candidate verification.
// Its private browser profile retains client keys; cookies are cleared for fresh native sign-in.
func seedNotesBrowser(t *testing.T, ctx context.Context, c *kube.Client, certPEM []byte, nodeIP string) func() {
t.Helper()
if os.Getenv("KYQ_TEST_NOTES_BROWSER") != "1" {
return nil
}
work := t.TempDir()
profile := filepath.Join(work, "profile")
if err := os.Mkdir(profile, 0o700); err != nil {
t.Fatal(err)
}
var caPEM []byte
for rest := certPEM; len(rest) > 0; {
block, next := pem.Decode(rest)
rest = next
if block == nil {
t.Fatal("invalid browser fixture chain")
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
t.Fatal(err)
}
if cert.IsCA {
caPEM = pem.EncodeToMemory(block)
}
}
if len(caPEM) == 0 {
t.Fatal("browser fixture has no issuing CA")
}
caFile := filepath.Join(work, "ca.pem")
if err := os.WriteFile(caFile, caPEM, 0o600); err != nil {
t.Fatal(err)
}
for _, args := range [][]string{{"-N", "-d", "sql:" + profile, "--empty-password"}, {"-A", "-d", "sql:" + profile, "-n", "owned Notes acceptance CA", "-t", "C,,", "-i", caFile}} {
if out, err := exec.CommandContext(ctx, "certutil", args...).CombinedOutput(); err != nil {
t.Fatalf("private browser CA: %v %s", err, out)
}
}
ns, pod, container, err := c.AppPod(ctx, "kyidentity")
if err != nil {
t.Fatal(err)
}
password, err := c.Exec(ctx, ns, pod, container, []string{"cat", "/data/installer/" + identityFixturePreparation().SetupID + "/everyday.password"})
if err != nil || len(password) == 0 {
t.Fatal("browser everyday credential unavailable")
}
defer clear(password)
config := map[string]string{"profile": profile, "expected": filepath.Join(work, "expected.json"), "notes": "https://" + catalogNotesURLHost, "identity": "https://" + catalogIdentityURLHost, "username": "prepared-user", "password": strings.TrimSpace(string(password)), "nodeIP": nodeIP, "module": os.Getenv("KYQ_TEST_BROWSER_MODULE"), "browser": os.Getenv("KYQ_TEST_BROWSER_EXECUTABLE")}
run := func(phase string) {
t.Helper()
config["phase"] = phase
input, err := json.Marshal(config)
if err != nil {
t.Fatal(err)
}
defer clear(input)
bounded, cancel := context.WithTimeout(ctx, 6*time.Minute)
defer cancel()
args := []string{"--max-old-space-size=256", "notes_browser.mjs"}
command := "node"
if wrapper := os.Getenv("KYQ_TEST_BROWSER_WRAPPER"); wrapper != "" {
command = wrapper
args = append([]string{"node"}, args...)
}
cmd := exec.CommandContext(bounded, command, args...)
cmd.Stdin = bytes.NewReader(input)
cmd.Env = append(os.Environ(), "DEBUG=", "PUSH_RELAY_URL=", "APNS_RELAY_URL=")
out, err := cmd.CombinedOutput()
t.Logf("Notes native browser %s: %s", phase, out)
if err != nil {
t.Fatalf("Notes native browser %s failed: %v", phase, err)
}
}
run("seed")
return func() { run("verify") }
}

func TestNotesBrowserCertificate(t *testing.T) {
t.Setenv("KYQ_TEST_NOTES_BROWSER", "1")
chain, key := browserEdgeCertificate(t)
pair, err := tls.X509KeyPair(chain, key)
if err != nil || len(pair.Certificate) != 2 {
t.Fatalf("browser certificate chain: %v", err)
}
leaf, err := x509.ParseCertificate(pair.Certificate[0])
if err != nil {
t.Fatal(err)
}
ca, err := x509.ParseCertificate(pair.Certificate[1])
if err != nil {
t.Fatal(err)
}
roots := x509.NewCertPool()
roots.AddCert(ca)
if _, err := leaf.Verify(x509.VerifyOptions{Roots: roots, DNSName: catalogNotesHost}); err != nil {
t.Fatal(err)
}
if _, err := leaf.Verify(x509.VerifyOptions{Roots: roots, DNSName: "wrong.invalid"}); err == nil {
t.Fatal("fixture certificate accepted wrong hostname")
}
}
29 changes: 29 additions & 0 deletions test/e2e/notes_input.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Keep ASCII keyboard actions; use the browser editing engine for unmapped Unicode.
export async function appendText(page, text) {
for (const character of text) {
if (character >= " " && character <= "~") await page.keyboard.type(character);
else if (!await page.evaluate(text => document.execCommand("insertText", false, text), character))
throw new Error("browser Unicode editing command refused");
}
}

export async function replaceContentText(page, control, text) {
await control.click();
await control.press("ControlOrMeta+A");
if (!await page.evaluate(text => document.execCommand("insertText", false, text), text))
throw new Error("browser content replacement command refused");
}

export async function focusParagraphEnd(page, paragraph) {
await paragraph.click();
await page.keyboard.press("End");
return paragraph.evaluate(element => {
const selection = window.getSelection();
const inside = Boolean(selection?.anchorNode && element.contains(selection.anchorNode));
if (!inside) return { inside: false, collapsed: Boolean(selection?.isCollapsed), atEnd: false };
const beforeCaret = document.createRange();
beforeCaret.selectNodeContents(element);
beforeCaret.setEnd(selection.anchorNode, selection.anchorOffset);
return { inside, collapsed: selection.isCollapsed, atEnd: beforeCaret.toString() === element.textContent };
});
}
17 changes: 17 additions & 0 deletions test/e2e/npm_joins_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func TestKubernetesNPMEdgeJoins(t *testing.T) { testKubernetesEdgeJoins(t, "npm"

// testKubernetesEdgeJoins is the joins suite behind proxy: the catalog npm, or nginx.
func testKubernetesEdgeJoins(t *testing.T, proxy string) {
if os.Getenv("KYQ_TEST_NOTES_BROWSER") == "1" {
if proxy != "npm" || os.Getenv("KYQ_TEST_RELEASE_UPGRADE_MANIFESTS") == "" || os.Getenv("KYQ_TEST_BROWSER_MODULE") == "" || os.Getenv("KYQ_TEST_BROWSER_EXECUTABLE") == "" {
t.Fatal("Notes browser case requires NPM, historical manifests and explicit browser/module paths")
}
}
ctx := context.Background()
work := t.TempDir()
state := filepath.Join(work, "state")
Expand Down Expand Up @@ -96,6 +101,7 @@ func testKubernetesEdgeJoins(t *testing.T, proxy string) {
os.WriteFile(plan, []byte("version: 1\ntargets:\n - name: k8s\n kubeconfig: "+kc+"\n storage_class: standard\napps:\n - name: "+proxy+"\n target: k8s\n - name: hello\n target: k8s\n"), 0o600)
var outputs, trust []string
var restoreCalendar func()
var verifyNotes func()
apply := func(want string) string {
t.Helper()
var out bytes.Buffer
Expand Down Expand Up @@ -225,6 +231,13 @@ func testKubernetesEdgeJoins(t *testing.T, proxy string) {
}
}

// Diagnose real browser/key enrollment as soon as old Notes is ready, before
// installing unrelated Calendar/Post fixtures. Later apply calls keep its data.
if os.Getenv("KYQ_TEST_NOTES_BROWSER") == "1" {
trustTestCA(t, ctx, cs, connected, "kynotes", certPEM)
verifyNotes = seedNotesBrowser(t, ctx, connected, certPEM, nodeIP)
}

// KyCalendar joins after KyIdentity's first setup too, by setup amendment. Its setup needs
// no issuer probe, so it runs before the edges as kyPulse's does; its everyday account's
// subject comes from KyIdentity's read-only check of its first setup.
Expand Down Expand Up @@ -285,6 +298,7 @@ func testKubernetesEdgeJoins(t *testing.T, proxy string) {
// must not append duplicate volumes, mounts or environment values.
trustTestCA(t, ctx, cs, connected, "kycalendar", certPEM)
trustTestCA(t, ctx, cs, connected, "kycalendar", certPEM)
trustTestCA(t, ctx, cs, connected, "kynotes", certPEM)
verifyCalendar, verifyRestoredCalendar := seedCalendarUpgrade(t, ctx, calendarSignOn(t, ctx, connected, certPEM, nodeIP))
fingerprints := func() map[string][32]byte {
t.Helper()
Expand Down Expand Up @@ -400,6 +414,9 @@ func testKubernetesEdgeJoins(t *testing.T, proxy string) {
t.Logf("preserved %d Kubernetes Secret payloads, Docker client/session keys, Identity JWKS and Recovery pairing; candidate Pulse deposited with its prior pairing", len(before))
driveSignOn(t, ctx, kc, certPEM, nodeIP, driveSecrets[1])
notesSignOn(t, ctx, connected, certPEM, nodeIP)
if verifyNotes != nil {
verifyNotes()
}
calendarEveryday := calendarSignOn(t, ctx, connected, certPEM, nodeIP)
verifyCalendar(calendarEveryday)
if os.Getenv("KYQ_TEST_CALENDAR_RESTORE") == "1" {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/npm_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func uploadCertificate(t *testing.T, ctx context.Context, tunnel edge.Dial, toke
json.NewDecoder(res.Body).Decode(result)
}
}
certPEM, keyPEM := testCertificate(t)
certPEM, keyPEM := browserEdgeCertificate(t)
var created struct {
ID int `json:"id"`
}
Expand Down
Loading