1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'mocha/minitest'
11 [{name: 'root', uid: 0}]
15 [{name: 'root', gid: 0}]
22 # These Etc mocks help only when we run arvados-login-sync in-process.
23 ENV['ARVADOS_VIRTUAL_MACHINE_UUID'] = 'testvm2.shell'
24 Etc.stubs(:to_enum).with(:passwd).returns stubpasswd.map { |x| OpenStruct.new x }
25 Etc.stubs(:to_enum).with(:group).returns stubgroup.map { |x| OpenStruct.new x }
27 # These child-ENV tricks help only when we run arvados-login-sync as a subprocess.
29 @tmpdir = Dir.mktmpdir
33 FileUtils.remove_dir(@tmpdir)
34 ENV.select! { |k| @env_was.has_key? k }
35 @env_was.each do |k,v| ENV[k]=v end
40 # Use UUID of testvm2.shell fixture, unless otherwise specified by test case.
41 Hash[ENV].merge('ARVADOS_VIRTUAL_MACHINE_UUID' => 'zzzzz-2x53u-382brsig8rp3065',
42 'ARVADOS_LOGIN_SYNC_TMPDIR' => @tmpdir)
45 def invoke_sync opts={}
46 env = stubenv.merge(opts[:env] || {})
47 (opts[:binstubs] || []).each do |binstub|
48 env['PATH'] = File.absolute_path('../binstub_'+binstub, __FILE__) + ':' + env['PATH']
50 login_sync_path = File.absolute_path '../../bin/arvados-login-sync', __FILE__
51 system env, login_sync_path