#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 Bryan Joshua Pedini

# fake getent (unit tests): "getent passwd NAME" for alice (uid 1000, home $FAKE_DIR/home/alice),
# root and toor (uid 0); exit 2 (no such key) for anyone else
[[ ${1:-} == passwd ]] || exit 1
case ${2:-} in
alice) echo "alice:x:1000:1000:Alice:${FAKE_DIR:?}/home/alice:/bin/bash" ;;
root) echo "root:x:0:0::/root:/bin/bash" ;;
toor) echo "toor:x:0:0:root by another name:/root:/bin/bash" ;;
*) exit 2 ;;
esac
