<commit_before>use strict;
use warnings;
use English;
use Test::More;
use t::Util;

plan skip_all => "not running as root"
    if $UID != 0;
plan skip_all => "user 'nobody' does not exist"
    unless defined getpwnam("nobody");


subtest "set-user" => sub {
    doit(<< 'EOT');
user: nobody
EOT
};

subtest "automatic fallback to nobody" => sub {
    doit('');
};

done_testing;

sub doit {
    my $conf = shift;
    my $server = spawn_h2o(<< "EOT");
$conf
hosts:
  default:
    paths:<commit_msg>this test also needs to be run as root<commit_after>use strict;
use warnings;
use Test::More;
use t::Util;

run_as_root();

plan skip_all => "user 'nobody' does not exist"
    unless defined getpwnam("nobody");

subtest "set-user" => sub {
    doit(<< 'EOT');
user: nobody
EOT
};

subtest "automatic fallback to nobody" => sub {
    doit('');
};

done_testing;

sub doit {
    my $conf = shift;
    my $server = spawn_h2o(<< "EOT");
$conf
hosts:
  default:
    paths:
{'fraction_non_alphanumeric': 0.15352697095435686, 'fraction_numerical': 0.0031120331950207467, 'mean_word_length': 3.707317073170732, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5960097', 'n_tokens_mistral': 361, 'n_tokens_neox': 358, 'n_words': 113}