2 require 'mocha/mini_test'
6 # These Etc mocks help only when we run arvados-login-sync in-process.
10 ENV['ARVADOS_VIRTUAL_MACHINE_UUID'] = 'testvm2.shell'
11 Etc.stubs(:to_enum).with(:passwd).returns stubpasswd.map { |x| OpenStruct.new x }
12 Etc.stubs(:to_enum).with(:group).returns stubgroup.map { |x| OpenStruct.new x }
16 [{name: 'root', uid: 0}]
20 [{name: 'root', gid: 0}]
23 # These child-ENV tricks help only when we run arvados-login-sync as a subprocess.
28 @tmpdir = Dir.mktmpdir
32 FileUtils.remove_dir(@tmpdir)
33 ENV.select! { |k| @env_was.has_key? k }
34 @env_was.each do |k,v| ENV[k]=v end
39 # Use UUID of testvm2.shell fixture, unless otherwise specified by test case.
40 Hash[ENV].merge('ARVADOS_VIRTUAL_MACHINE_UUID' => 'zzzzz-2x53u-382brsig8rp3065',
41 'ARVADOS_LOGIN_SYNC_TMPDIR' => @tmpdir)
44 def invoke_sync opts={}
45 env = stubenv.merge(opts[:env] || {})
46 (opts[:binstubs] || []).each do |binstub|
47 env['PATH'] = File.absolute_path('../binstub_'+binstub, __FILE__) + ':' + env['PATH']
49 login_sync_path = File.absolute_path '../../bin/arvados-login-sync', __FILE__
50 system env, login_sync_path