Skip to content

tests/test_client_mss.sh never validates the generated config — both config assertions are decided by an empty string #144

Description

@rvalitov

Summary

tests/test_client_mss.sh does not validate the generated Telemt config. Both
config-generation assertions are decided by an empty string rather than by the
config the product produces, so the file cannot detect a regression in client_msshandling — and one of its assertions reports PASS unconditionally.

Root cause

generate_telemt_config() takes a destination path and writes the TOML to that file; it does not print the TOML to stdout:

generate_telemt_config() {          # mtproxymax.sh:1248
    local dest="${1:-${CONFIG_DIR}/config.toml}"

The test captures stdout instead (tests/test_client_mss.sh:43-59):

cfg=$(generate_telemt_config)if echo "$cfg" | grep -q 'client_mss = "tspu"'; then ...

cfg is therefore always empty, and both branches below operate on that emptiness.

Consequences

  1. client_mss emitted when set to tspu can never pass, on any platform —
    grep never matches an empty string.
  2. client_mss omitted when off passes vacuously. It greps the same emptystring, finds nothing, and reports absent, which is the expected value. It
    therefore reports PASS regardless of what the product does — including when
    client_mss is emitted unconditionally
    .
    (2) is the more damaging of the two: it is a green assertion that validates nothing,
    so a genuine regression in client_mss emission would still show as passing.

How to reproduce

$ bash tests/test_client_mss.sh...
  FAIL  client_mss emitted when set to tspu (got=absent want=present)
8 tests, 1 failures```

Note that the assertion which *should* have caught this reports PASS in the same
run.
To demonstrate that the test has no signal at all, mutate the product so
`client_mss` is emitted unconditionally (`mtproxymax.sh:1350`) and re-run:

$ sed -i '1350s|.*|client_mss = "tspu"|' mtproxymax.sh$ bash tests/test_client_mss.sh
8 tests, 1 failures

$ git checkout mtproxymax.sh && bash tests/test_client_mss.sh
8 tests, 1 failures


Identical output for a mutated and an unmutated product.

## Suggested fix

Pass a destination path and grep that file, for example:

```bash
CLIENT_MSS="tspu"
dest="$TEST_TMPDIR/config-tspu.toml"
generate_telemt_config "$dest" >/dev/null 2>&1
grep -q 'client_mss = "tspu"' "$dest"

plus an explicit "config is written" assertion, so that if generation ever fails the test fails loudly rather than reverting to a vacuous pass.

Environment

Reproduces identically on Debian 12, Ubuntu 22.04, Ubuntu 24.04, Alpine 3.20 and Fedora 41 (bash 5.x). Found while running the existing suite across those distributions — this was the only failure common to all of them, which is what pointed at the test rather than at the product.

Found while I was creating a distro test matrix - this PR I will add soon.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions