|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'spec_helper' |
| 4 | + |
| 5 | +describe 'Stdlib::File::Source' do |
| 6 | + describe 'valid handling' do |
| 7 | + [ |
| 8 | + 'https://hello.com', |
| 9 | + 'https://notcreative.org', |
| 10 | + 'https://canstillaccepthttps.co.uk', |
| 11 | + 'http://anhttp.com', |
| 12 | + 'http://runningoutofideas.gov', |
| 13 | + 'file:///hello/bla', |
| 14 | + 'file:///foo/bar.log', |
| 15 | + 'puppet:///modules/foo/bar.log', |
| 16 | + 'puppet://pm.example.com/modules/foo/bar.log', |
| 17 | + 'puppet://192.0.2.1/modules/foo/bar.log', |
| 18 | + '/usr2/username/bin:/usr/local/bin:/usr/bin:.', |
| 19 | + 'C:/', |
| 20 | + 'C:\\', |
| 21 | + 'C:\\WINDOWS\\System32', |
| 22 | + 'C:/windows/system32', |
| 23 | + 'X:/foo/bar', |
| 24 | + 'X:\\foo\\bar', |
| 25 | + '\\\\host\\windows', |
| 26 | + '//host/windows', |
| 27 | + '/var/tmp', |
| 28 | + '/var/opt/../lib/puppet', |
| 29 | + 'puppet:///a_custom_mount_point/foo/bar/foobar.conf', |
| 30 | + ].each do |value| |
| 31 | + describe value.inspect do |
| 32 | + it { is_expected.to allow_value(value) } |
| 33 | + end |
| 34 | + end |
| 35 | + end |
| 36 | + |
| 37 | + describe 'invalid path handling' do |
| 38 | + context 'garbage inputs' do |
| 39 | + [ |
| 40 | + nil, |
| 41 | + [nil], |
| 42 | + [nil, nil], |
| 43 | + { 'foo' => 'bar' }, |
| 44 | + {}, |
| 45 | + '', |
| 46 | + "\nfile:///foo/bar.log", |
| 47 | + "\nfile:///foo/bar.log\n", |
| 48 | + "file:///foo/bar.log\n", |
| 49 | + "\npuppet:///modules/foo/bar.log", |
| 50 | + "\npuppet:///modules/foo/bar.log\n", |
| 51 | + "puppet:///modules/foo/bar.log\n", |
| 52 | + '*/Users//nope', |
| 53 | + '\\Users/hc/wksp/stdlib', |
| 54 | + 'C:noslashes', |
| 55 | + '\\var\\tmp', |
| 56 | + 'puppet://[email protected]/modules/foo/bar.log', |
| 57 | + ].each do |value| |
| 58 | + describe value.inspect do |
| 59 | + it { is_expected.not_to allow_value(value) } |
| 60 | + end |
| 61 | + end |
| 62 | + end |
| 63 | + end |
| 64 | +end |
0 commit comments