X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0eb72b526bf8bbb011551ecf019f604e17a534f1..752674a547864012b7f73e58c7d41a9c3ce5fe72:/services/login-sync/test/test_add_user.rb diff --git a/services/login-sync/test/test_add_user.rb b/services/login-sync/test/test_add_user.rb index f51509cb5b..e90c16d64f 100644 --- a/services/login-sync/test/test_add_user.rb +++ b/services/login-sync/test/test_add_user.rb @@ -10,26 +10,26 @@ class TestAddUser < Minitest::Test include Stubs def test_useradd_error + valid_groups = %w(docker admin fuse).select { |g| Etc.getgrnam(g) rescue false } # binstub_new_user/useradd will exit non-zero because its args # won't match any line in this empty file: File.open(@tmpdir+'/succeed', 'w') do |f| end invoke_sync binstubs: ['new_user'] spied = File.read(@tmpdir+'/spy') - assert_match %r{useradd -m -c active -s /bin/bash -G fuse active}, spied - # BUG(TC): This assertion succeeds only if docker and fuse groups - # exist on the host, but is insensitive to the admin group (groups - # are quietly ignored by login-sync if they don't exist on the - # current host). - assert_match %r{useradd -m -c adminroot -s /bin/bash -G docker(,admin)?,fuse adminroot}, spied + assert_match %r{useradd -m -c active -s /bin/bash -G (fuse)? active}, spied + assert_match %r{useradd -m -c adminroot -s /bin/bash -G #{valid_groups.join(',')} adminroot}, spied end def test_useradd_success # binstub_new_user/useradd will succeed. File.open(@tmpdir+'/succeed', 'w') do |f| f.puts 'useradd -m -c active -s /bin/bash -G fuse active' + f.puts 'useradd -m -c active -s /bin/bash -G active' # Accept either form; see note about groups in test_useradd_error. f.puts 'useradd -m -c adminroot -s /bin/bash -G docker,fuse adminroot' f.puts 'useradd -m -c adminroot -s /bin/bash -G docker,admin,fuse adminroot' + f.puts 'useradd -m -c adminroot -s /bin/bash -G docker adminroot' + f.puts 'useradd -m -c adminroot -s /bin/bash -G docker,admin adminroot' end $stderr.puts "*** Expect crash after getpwnam() fails:" invoke_sync binstubs: ['new_user']