winrm 1.3.0.dev.2 → 1.3.0.dev.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +14 -6
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/Vagrantfile +8 -0
- data/bin/rwinrm +34 -70
- data/lib/winrm/exceptions/exceptions.rb +17 -1
- data/lib/winrm/helpers/powershell_script.rb +22 -0
- data/lib/winrm/http/response_handler.rb +15 -3
- data/lib/winrm/http/transport.rb +14 -1
- data/lib/winrm/output.rb +27 -0
- data/lib/winrm/winrm_service.rb +21 -11
- data/lib/winrm.rb +1 -1
- data/spec/cmd_spec.rb +32 -0
- data/spec/config-example.yml +1 -1
- data/spec/exception_spec.rb +17 -0
- data/spec/output_spec.rb +106 -0
- data/spec/powershell_spec.rb +34 -0
- data/spec/response_handler_spec.rb +14 -0
- data/spec/stubs/responses/wmi_error_v2.xml +41 -0
- data/spec/winrm_options_spec.rb +75 -0
- data/spec/winrm_primitives_spec.rb +0 -18
- data/winrm.gemspec +1 -3
- metadata +10 -38
- data/lib/winrm/file_transfer/remote_file.rb +0 -184
- data/lib/winrm/file_transfer/remote_zip_file.rb +0 -60
- data/lib/winrm/file_transfer.rb +0 -39
- data/spec/file_transfer/remote_file_spec.rb +0 -71
- data/spec/file_transfer/remote_zip_file_spec.rb +0 -51
- data/spec/file_transfer_spec.rb +0 -39
@@ -1,51 +0,0 @@
|
|
1
|
-
describe WinRM::RemoteZipFile, :integration => true do
|
2
|
-
|
3
|
-
let(:this_dir) { File.dirname(__FILE__) }
|
4
|
-
let(:service) { winrm_connection }
|
5
|
-
let(:destination) {"#{ENV['temp']}/WinRM_tests"}
|
6
|
-
before { FileUtils.rm_rf(Dir.glob("#{ENV['temp'].gsub("\\","/")}/WinRM_*")) }
|
7
|
-
after { subject.close }
|
8
|
-
subject {WinRM::RemoteZipFile.new(service, destination, :quiet => true)}
|
9
|
-
|
10
|
-
context 'Upload a new directory' do
|
11
|
-
it 'copies the directory' do
|
12
|
-
subject.add_file(this_dir)
|
13
|
-
expect(subject.upload).to be > 0
|
14
|
-
expect(File.read(File.join(destination, "file_transfer", "remote_file_spec.rb"))).to eq(File.read(File.join(this_dir, 'remote_file_spec.rb')))
|
15
|
-
expect(File.read(File.join(destination, "file_transfer", "remote_zip_file_spec.rb"))).to eq(File.read(File.join(this_dir, 'remote_zip_file_spec.rb')))
|
16
|
-
expect(File.exist?(File.join(this_dir, "file_transfer.zip"))).to be_falsey
|
17
|
-
expect(File.exist?(File.join(destination, "file_transfer.zip"))).to be_falsey
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'Upload an identical directory' do
|
22
|
-
let (:next_transfer) {WinRM::RemoteZipFile.new(service, destination, :quiet => true)}
|
23
|
-
|
24
|
-
it 'does not copy the directory' do
|
25
|
-
subject.add_file(this_dir)
|
26
|
-
expect(subject.upload).to be > 0
|
27
|
-
next_transfer.add_file(this_dir)
|
28
|
-
expect(next_transfer.upload).to be == 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'Upload multiple entries' do
|
33
|
-
it 'copies each entry' do
|
34
|
-
subject.add_file(this_dir)
|
35
|
-
spec_helper = File.join(File.dirname(this_dir), 'spec_helper.rb')
|
36
|
-
subject.add_file(spec_helper)
|
37
|
-
expect(subject.upload).to be > 0
|
38
|
-
expect(File.read(File.join(destination, "file_transfer", "remote_file_spec.rb"))).to eq(File.read(File.join(this_dir, 'remote_file_spec.rb')))
|
39
|
-
expect(File.read(File.join(destination, "file_transfer", "remote_zip_file_spec.rb"))).to eq(File.read(File.join(this_dir, 'remote_zip_file_spec.rb')))
|
40
|
-
expect(File.read(File.join(destination, "spec_helper.rb"))).to eq(File.read(spec_helper))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'Upload a bad path' do
|
45
|
-
it 'raises WinRMUploadFailed' do
|
46
|
-
expect {
|
47
|
-
subject.add_file('c:/some/bad/path')
|
48
|
-
}.to raise_error(WinRM::WinRMUploadFailed)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/spec/file_transfer_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
describe WinRM::FileTransfer, :unit => true do
|
2
|
-
|
3
|
-
let(:this_file) { __FILE__ }
|
4
|
-
let(:remote_file) {double('RemoteFile')}
|
5
|
-
let(:remote_zip_file) {double('RemoteZipFile')}
|
6
|
-
|
7
|
-
before {
|
8
|
-
allow(WinRM::RemoteFile).to receive(:new).and_return(remote_file)
|
9
|
-
allow(WinRM::RemoteZipFile).to receive(:new).and_return(remote_zip_file)
|
10
|
-
}
|
11
|
-
subject {WinRM::FileTransfer}
|
12
|
-
|
13
|
-
context 'copying a single file' do
|
14
|
-
it 'uploads a remote_file' do
|
15
|
-
expect(remote_file).to receive(:upload)
|
16
|
-
expect(remote_file).to receive(:close)
|
17
|
-
subject.upload("service", this_file, "c:/directory")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'copying a single directory' do
|
22
|
-
it 'uploads a remote_zip_file' do
|
23
|
-
expect(remote_zip_file).to receive(:add_file).with(File.dirname(this_file))
|
24
|
-
expect(remote_zip_file).to receive(:upload)
|
25
|
-
expect(remote_zip_file).to receive(:close)
|
26
|
-
subject.upload("service", File.dirname(this_file), "c:/directory")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'copying both a file and a directory' do
|
31
|
-
it 'adds both to a remote_zip_file' do
|
32
|
-
expect(remote_zip_file).to receive(:upload)
|
33
|
-
expect(remote_zip_file).to receive(:add_file).with(this_file)
|
34
|
-
expect(remote_zip_file).to receive(:add_file).with(File.dirname(this_file))
|
35
|
-
expect(remote_zip_file).to receive(:close)
|
36
|
-
subject.upload("service", [File.dirname(this_file), this_file], "c:/directory")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|