2013-03-15 04:50:12 -07:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2013-03-15 04:50:12 -07:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'unix_permissions';
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
2015-07-07 07:49:30 -07:00
|
|
|
sub _expected_result {
|
|
|
|
return {
|
2015-06-20 06:00:03 -07:00
|
|
|
description => 'Unix file permission',
|
|
|
|
meta => {
|
|
|
|
sourceName => 'wikipedia',
|
|
|
|
sourceUrl => 'https://en.wikipedia.org/wiki/Permissions#Notation_of_traditional_Unix_permissions'
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
content => 'record',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data => {
|
|
|
|
title => 'Unix file permissions',
|
|
|
|
record_keys => ["symbolic", "user", "group", "others", "attributes",],
|
2015-07-07 07:49:30 -07:00
|
|
|
record_data => (@_),
|
2015-06-20 06:00:03 -07:00
|
|
|
},
|
2015-07-07 07:49:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[qw(
|
|
|
|
DDG::Goodie::UnixPermissions
|
|
|
|
)],
|
|
|
|
'chmod 755' => test_zci(
|
|
|
|
'755 (octal)
|
|
|
|
rwxr-xr-x (symbolic)
|
|
|
|
User: read, write and execute
|
|
|
|
Group: read and execute
|
|
|
|
Others: read and execute
|
|
|
|
',
|
|
|
|
structured_answer => _expected_result({
|
|
|
|
symbolic => 'rwxr-xr-x',
|
|
|
|
user => 'read, write and execute',
|
|
|
|
group => 'read and execute',
|
|
|
|
others => 'read and execute',
|
|
|
|
attributes => undef,
|
|
|
|
}),
|
2013-03-22 13:48:41 -07:00
|
|
|
),
|
2013-03-21 12:43:42 -07:00
|
|
|
|
2013-03-15 04:50:12 -07:00
|
|
|
'permission 0644' => test_zci(
|
2013-03-21 12:43:42 -07:00
|
|
|
'644 (octal)
|
|
|
|
rw-r--r-- (symbolic)
|
2013-03-21 19:38:12 -07:00
|
|
|
User: read and write
|
|
|
|
Group: read
|
|
|
|
Others: read
|
2015-06-20 06:00:03 -07:00
|
|
|
',
|
2015-07-07 07:49:30 -07:00
|
|
|
structured_answer => _expected_result({
|
|
|
|
symbolic => 'rw-r--r--',
|
|
|
|
user => 'read and write',
|
|
|
|
group => 'read',
|
|
|
|
others => 'read',
|
|
|
|
attributes => undef,
|
|
|
|
})
|
2013-03-22 13:48:41 -07:00
|
|
|
),
|
2013-03-15 04:50:12 -07:00
|
|
|
|
2013-03-22 13:48:41 -07:00
|
|
|
'permission 7644' => test_zci(
|
|
|
|
'7644 (octal)
|
|
|
|
rwSr-Sr-T (symbolic)
|
|
|
|
User: read and write
|
|
|
|
Group: read
|
|
|
|
Others: read
|
|
|
|
Attributes: sticky, setuid and setgid
|
2015-06-20 06:00:03 -07:00
|
|
|
',
|
2015-07-07 07:49:30 -07:00
|
|
|
structured_answer => _expected_result({
|
|
|
|
symbolic => 'rwSr-Sr-T',
|
|
|
|
user => 'read and write',
|
|
|
|
group => 'read',
|
|
|
|
others => 'read',
|
|
|
|
attributes => 'sticky, setuid and setgid',
|
|
|
|
})
|
2013-03-22 13:48:41 -07:00
|
|
|
),
|
2015-07-07 07:52:25 -07:00
|
|
|
'unix file permissions chmod 777' => test_zci(
|
|
|
|
'777 (octal)
|
|
|
|
rwxrwxrwx (symbolic)
|
|
|
|
User: read, write and execute
|
|
|
|
Group: read, write and execute
|
|
|
|
Others: read, write and execute
|
|
|
|
',
|
|
|
|
structured_answer => _expected_result({
|
|
|
|
symbolic => 'rwxrwxrwx',
|
|
|
|
user => 'read, write and execute',
|
|
|
|
group => 'read, write and execute',
|
|
|
|
others => 'read, write and execute',
|
|
|
|
attributes => undef,
|
|
|
|
}),
|
|
|
|
),
|
2013-03-22 13:48:41 -07:00
|
|
|
|
|
|
|
'permission 9644' => undef,
|
|
|
|
);
|
2016-05-16 06:18:04 -07:00
|
|
|
done_testing;
|