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