From fbbe467da072b8be0513c887bbf81471772e57d5 Mon Sep 17 00:00:00 2001 From: Ebbe Date: Wed, 18 Nov 2026 08:09:57 +0100 Subject: [PATCH] docs: picture share test environment runbook and sync stand-in Co-Authored-By: Claude Sonnet 5.5 --- docs/test-environment/picture-share.md | 80 +++++++++++++++++++ docs/test-environment/picture-sync-standin.sh | 41 ++++++++++ 2 files changed, 121 insertions(+) create mode 100644 docs/test-environment/picture-share.md create mode 100755 docs/test-environment/picture-sync-standin.sh diff --git a/docs/test-environment/picture-share.md b/docs/test-environment/picture-share.md new file mode 100644 index 0000000..541781a --- /dev/null +++ b/docs/test-environment/picture-share.md @@ -0,0 +1,80 @@ +# Picture share test environment + +Ticket 4 of the account self-service epic. The picture feature needs two folders and something that plays the part of the sync task. Nothing here touches production: the folders are new, and the stand-in never writes to AD. + +Time needed: about 15 minutes. + +## How the portal uses the share + +| Folder | Portal access | Content | +| --- | --- | --- | +| Source folder | writes | `.jpg`, the 512 by 512 picture the portal produced | +| Processed folder | reads only | `.md5`, written by the sync task: the MD5 of the source file it processed | + +The portal shows "Pending" until `processed/.md5` equals the MD5 of the file it wrote. The real task (`AD-ProfilePicture-Sync.ps1`) runs on a domain controller, writes the MD5 file for every user on each run, and sets the AD picture attributes. Its hash is upper case hex with a trailing newline; the portal compares it case-insensitively and trimmed. + +## Step A: Create the two folders + +On the Linux host: + +```sh +sudo mkdir -p /srv/picture-test/source /srv/picture-test/processed +sudo chown -R "$USER": /srv/picture-test +``` + +Use paths that are clearly test paths. **Never point the test at the production source folder.** + +When the share becomes an SMB share, the host mounts it (CIFS) and the container still only sees a folder path. Nothing in the portal or in this runbook changes except where the paths point. The mount shape is: + +```sh +sudo mount -t cifs //fileserver/picture-test /srv/picture-test \ + -o credentials=/root/.picture-test.cred,uid=$(id -u),gid=$(id -g),vers=3.0 +``` + +Keep the credentials file out of this repository. The portal's account needs write on the source folder and read on the processed folder; the stand-in's account needs the opposite. + +## Step B: Provide a default image + +The real task falls back to a default image for users without a picture. Put any JPEG into the processed folder as `default.jpg`: + +```sh +cp some-picture.jpg /srv/picture-test/processed/default.jpg +``` + +## Step C: Run the stand-in + +`picture-sync-standin.sh` writes the MD5 files the way the real task does and leaves AD alone. Copy it to the host, then: + +```sh +chmod +x picture-sync-standin.sh +export SOURCE=/srv/picture-test/source PROCESSED=/srv/picture-test/processed +export USERS="ptest-user1 ptest-user2 ptest-publisher ptest-admin" +./picture-sync-standin.sh # once +./picture-sync-standin.sh 300 # every 5 minutes, until you stop it +``` + +For the Pending state to be visible in manual tests, run it with a long pause or by hand: the real task runs on a schedule, so a short pause hides the state you want to see. The portal's "taking longer than expected" message appears after a configured time, which you can test by not running the stand-in at all. + +## Step D: Prove it works + +1. Write a file into the source folder: `cp some-picture.jpg /srv/picture-test/source/ptest-user1.jpg` +2. Run the stand-in once. +3. `cat /srv/picture-test/processed/ptest-user1.md5` shows a 32 character upper case hex string. +4. `md5sum /srv/picture-test/source/ptest-user1.jpg` shows the same value in lower case. +5. Delete `source/ptest-user1.jpg`, run the stand-in again: the MD5 changes to the value of the default image. This is the removal case: the portal treats a changed MD5 as "removal processed". + +## Values sheet (write down for the build; no secrets) + +| Value | Your entry | +| --- | --- | +| Source folder path on the host | | +| Processed folder path on the host | | +| Local folder or SMB mount | | +| How the MD5 files are produced | stand-in script, run by hand or by cron every ___ minutes | +| Users the stand-in covers | | + +Tell the assistant the values. Ticket 5 then adds the two bind mounts to `compose.yaml` (source read-write, processed read-only) and the two path variables to `.env.example`. + +## Clean up + +Delete the two folders (and unmount the share, if any). The stand-in leaves nothing else behind. diff --git a/docs/test-environment/picture-sync-standin.sh b/docs/test-environment/picture-sync-standin.sh new file mode 100755 index 0000000..77dacd6 --- /dev/null +++ b/docs/test-environment/picture-sync-standin.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Stand-in for the AD-ProfilePicture-Sync.ps1 scheduled task, for testing the portal's picture +# feature. It does what the portal can see of the real script and nothing else: for every user +# it writes processed/.md5 holding the MD5 of the user's source file (or of the default +# image when there is none) in upper case hex with a trailing newline. It never touches AD. +# +# Usage: SOURCE=/srv/picture-test/source PROCESSED=/srv/picture-test/processed \ +# USERS="ptest-user1 ptest-user2" ./picture-sync-standin.sh [seconds] +# +# Without a number of seconds it runs once. With one it repeats until stopped (Ctrl+C). +# The real task never compares MD5 values and rewrites every file on every run; so does this. + +set -eu + +: "${SOURCE:?set SOURCE to the test source folder}" +: "${PROCESSED:?set PROCESSED to the test processed folder}" +: "${USERS:?set USERS to the sAMAccountNames, separated by spaces}" +DEFAULT_IMAGE="${DEFAULT_IMAGE:-$PROCESSED/default.jpg}" + +run_once() { + for sam in $USERS; do + file="$SOURCE/$sam.jpg" + [ -f "$file" ] || file="$DEFAULT_IMAGE" + if [ ! -f "$file" ]; then + echo "skip $sam: no $sam.jpg in the source folder and no default image" >&2 + continue + fi + sum=$(md5sum "$file" | cut -d' ' -f1 | tr 'a-f' 'A-F') + printf '%s\n' "$sum" > "$PROCESSED/$sam.md5" + echo "$(date '+%H:%M:%S') $sam $sum" + done +} + +if [ $# -eq 0 ]; then + run_once +else + while true; do + run_once + sleep "$1" + done +fi