Skip to content

Commit

Permalink
Local transport on Windows should use WindowsFile (inspec#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Wang committed Aug 23, 2017
1 parent a5c5fc8 commit 35cf00e
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ install:
- ps: winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"localhost`";CertificateThumbprint=`"$($env:winrm_cert)`"}"
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
- ps: Write-Host $env:PATH
- ps: echo hello world > "C:\train_test_file"
- ruby --version
- gem --version
- appveyor DownloadFile -Url %bundler_url% -FileName bundler.gem
Expand Down
71 changes: 71 additions & 0 deletions test/windows/local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,77 @@
cmd.stderr.must_equal ''
end

describe 'verify file' do
let(:file) { backend.file('C:\\train_test_file') }

it 'is an instance of WindowsFile' do
file.must_be_instance_of(Train::Extras::WindowsFile)
end

it 'exists' do
file.exist?.must_equal(true)
end

it 'is a file' do
file.file?.must_equal(true)
end

it 'has type :file' do
file.type.must_equal(:file)
end

it 'has content' do
file.content.must_equal('hello world')
end

it 'has no owner name' do
file.owner.must_be_nil
end

it 'has no group name' do
file.group.must_be_nil
end

it 'has no mode' do
file.mode.must_be_nil
end

it 'has an md5sum' do
file.md5sum.wont_be_nil
end

it 'has an sha256sum' do
file.sha256sum.wont_be_nil
end

it 'has no modified time' do
file.mtime.must_be_nil
end

it 'has no size' do
# TODO: this really ought to be implemented
file.size.must_be_nil
end

it 'has no selinux label handling' do
file.selinux_label.must_be_nil
end

it 'has product_version' do
file.product_version.wont_be_nil
end

it 'has file_version' do
file.file_version.wont_be_nil
end

it 'provides a json representation' do
j = file.to_json
j.must_be_kind_of Hash
j['type'].must_equal :file
end
end

after do
# close the connection
conn.close
Expand Down
71 changes: 71 additions & 0 deletions test/windows/winrm_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,77 @@
cmd.stderr.must_equal ''
end

describe 'verify file' do
let(:file) { backend.file('C:\\train_test_file') }

it 'is an instance of WindowsFile' do
file.must_be_instance_of(Train::Extras::WindowsFile)
end

it 'exists' do
file.exist?.must_equal(true)
end

it 'is a file' do
file.file?.must_equal(true)
end

it 'has type :file' do
file.type.must_equal(:file)
end

it 'has content' do
file.content.must_equal('hello world')
end

it 'has no owner name' do
file.owner.must_be_nil
end

it 'has no group name' do
file.group.must_be_nil
end

it 'has no mode' do
file.mode.must_be_nil
end

it 'has an md5sum' do
file.md5sum.wont_be_nil
end

it 'has an sha256sum' do
file.sha256sum.wont_be_nil
end

it 'has no modified time' do
file.mtime.must_be_nil
end

it 'has no size' do
# TODO: this really ought to be implemented
file.size.must_be_nil
end

it 'has no selinux label handling' do
file.selinux_label.must_be_nil
end

it 'has product_version' do
file.product_version.wont_be_nil
end

it 'has file_version' do
file.file_version.wont_be_nil
end

it 'provides a json representation' do
j = file.to_json
j.must_be_kind_of Hash
j['type'].must_equal :file
end
end

after do
# close the connection
conn.close
Expand Down

0 comments on commit 35cf00e

Please sign in to comment.