Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
lemonldap-ng
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
207
Issues
207
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LemonLDAP NG
lemonldap-ng
Commits
1a3e8032
Commit
1a3e8032
authored
Dec 29, 2018
by
Christophe Maudoux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix & improve units test (
#1603
)
parent
0abea4f1
Pipeline
#3820
failed with stages
in 9 minutes
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2575 additions
and
13 deletions
+2575
-13
lemonldap-ng-manager/MANIFEST
lemonldap-ng-manager/MANIFEST
+2
-0
lemonldap-ng-manager/t/11-save-changed-conf-with-confirmation.t
...dap-ng-manager/t/11-save-changed-conf-with-confirmation.t
+222
-0
lemonldap-ng-manager/t/12-save-changed-conf.t
lemonldap-ng-manager/t/12-save-changed-conf.t
+21
-10
lemonldap-ng-manager/t/15-combination.t
lemonldap-ng-manager/t/15-combination.t
+2
-3
lemonldap-ng-manager/t/jsonfiles/13-modified-with-confirmation.json
...ng-manager/t/jsonfiles/13-modified-with-confirmation.json
+2328
-0
No files found.
lemonldap-ng-manager/MANIFEST
View file @
1a3e8032
...
...
@@ -193,6 +193,7 @@ t/05-rest-api.t
t/06-rest-api.t
t/07-utf8.t
t/10-save-unchanged-conf.t
t/11-save-changed-conf-with-confirmation.t
t/12-save-changed-conf.t
t/14-bad-changes-in-conf.t
t/15-combination.t
...
...
@@ -207,6 +208,7 @@ t/conf/lmConf-1.json
t/jsonfiles/01-base-tree.json
t/jsonfiles/02-base-tree-all-nodes-opened.json
t/jsonfiles/12-modified.json
t/jsonfiles/13-modified-with-confirmation.json
t/jsonfiles/14-bad.json
t/jsonfiles/15-combination.json
t/lemonldap-ng.ini
...
...
lemonldap-ng-manager/t/11-save-changed-conf-with-confirmation.t
0 → 100644
View file @
1a3e8032
# Verify that a modified configuration can be saved and that all changes are
# detected
use
Test::
More
;
use
strict
;
use
JSON
;
require
'
t/test-lib.pm
';
my
$struct
=
'
t/jsonfiles/13-modified-with-confirmation.json
';
my
$confFiles
=
[
'
t/conf/lmConf-1.json
',
'
t/conf/lmConf-2.json
'
];
sub
body
{
return
IO::
File
->
new
(
$struct
,
'
r
'
);
}
# Delete lmConf-2.json if exists
eval
{
unlink
$confFiles
->
[
1
];
};
mkdir
'
t/sessions
';
my
(
$res
,
$resBody
);
ok
(
$res
=
&
client
->
_post
(
'
/confs/
',
'
cfgNum=1
',
&
body
,
'
application/json
'
),
"
Request succeed
"
);
ok
(
$res
->
[
0
]
==
200
,
"
Result code is 200
"
);
ok
(
$resBody
=
from_json
(
$res
->
[
2
]
->
[
0
]
),
"
Result body contains JSON text
"
);
ok
(
$resBody
->
{
result
}
==
0
,
"
JSON response contains
\"
result:0
\"
"
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$resBody
->
{
needConfirm
}
==
1
,
"
JSON response contains
\"
needConfirm:1
\"
"
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
@
{
$resBody
->
{
details
}
->
{
__warnings__
}
}
==
3
,
'
JSON response contains 3 warnings
'
)
or
print
STDERR
Dumper
(
$resBody
);
foreach
my
$i
(
0
..
2
)
{
ok
(
$resBody
->
{
details
}
->
{
__warnings__
}
->
[
$i
]
->
{
message
}
=~
/\b(unprotected|cross-domain-authentication|retries)\b/
,
"
Warning with 'unprotect', 'CDA' or 'retries' found
"
)
or
print
STDERR
Dumper
(
$resBody
);
}
ok
(
@
{
$resBody
->
{
details
}
->
{
__needConfirmation__
}
}
==
1
,
'
JSON response contains 1 needConfirmation
'
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$resBody
->
{
details
}
->
{
__needConfirmation__
}
->
[
0
]
->
{
message
}
=~
/\bplugin is enabled without CSRF Token or Captcha required\b/
,
"
Warning with confirmation needed found
"
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
@
{
$resBody
->
{
details
}
->
{
__changes__
}
}
==
24
,
'
JSON response contains 24 changes
'
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$res
=
&
client
->
_post
(
'
/confs/
',
'
cfgNum=1&force=1
',
&
body
,
'
application/json
'
),
"
Request succeed
"
);
ok
(
-
f
$confFiles
->
[
1
],
'
File is created
'
);
count
(
3
);
my
@changes
=
@
{
&
changes
};
my
@cmsg
=
@
{
$resBody
->
{
details
}
->
{
__changes__
}
};
my
$bug
;
while
(
my
$c
=
shift
@
{
$resBody
->
{
details
}
->
{
__changes__
}
}
)
{
my
$cmp1
=
@changes
;
my
$cmp2
=
@cmsg
;
my
@d1
=
grep
{
$_
->
{
key
}
eq
$c
->
{
key
}
}
@changes
;
my
@d2
=
grep
{
$_
->
{
key
}
eq
$c
->
{
key
}
}
@cmsg
;
@changes
=
grep
{
$_
->
{
key
}
ne
$c
->
{
key
}
}
@changes
;
@cmsg
=
grep
{
$_
->
{
key
}
ne
$c
->
{
key
}
}
@cmsg
;
if
(
$c
->
{
key
}
eq
'
applicationList
'
)
{
pass
qq("$c->{key}" found)
;
}
else
{
ok
(
(
$cmp1
-
@changes
)
==
(
$cmp2
-
@cmsg
),
qq("$c->{key}" found)
)
or
print
STDERR
'
Expect:
'
.
(
$cmp1
-
@changes
)
.
'
, got:
'
.
(
$cmp2
-
@cmsg
)
.
"
\n
Expect:
"
.
Dumper
(
\
@d1
)
.
"
Got:
"
.
Dumper
(
\
@d2
);
}
count
(
1
);
}
ok
(
!
@changes
,
'
All changes detected
'
)
or
$bug
=
1
;
if
(
$bug
)
{
print
STDERR
'
Expected not found:
'
.
Dumper
(
\
@changes
)
.
'
Changes announced and not found:
'
.
Dumper
(
\
@cmsg
);
}
#print STDERR Dumper(\@changes,\@cmsg);
count
(
6
);
# TODO: check result of this
ok
(
$res
=
&
client
->
jsonResponse
('
/diff/1/2
'),
'
Diff called
'
);
my
(
@c1
,
@c2
);
ok
(
(
@c1
=
sort
keys
%
{
$res
->
[
0
]
}
),
'
diff() detects changes in conf 1
'
);
ok
(
(
@c2
=
sort
keys
%
{
$res
->
[
1
]
}
),
'
diff() detects changes in conf 2
'
);
ok
(
@c1
==
12
,
'
11 keys changed in conf 1
'
)
or
print
STDERR
"
Expect: 12 keys, get:
"
.
join
(
'
,
',
@c1
)
.
"
\n
";
ok
(
@c2
==
16
,
'
14 keys changed or created in conf 2
'
)
or
print
STDERR
"
Expect: 16 keys, get:
"
.
join
(
'
,
',
@c2
)
.
"
\n
";
count
(
5
);
unlink
$confFiles
->
[
1
];
#eval { rmdir 't/sessions'; };
done_testing
(
count
()
);
# Remove sessions directory
`
rm -rf t/sessions
`;
sub
changes
{
return
[
{
'
key
'
=>
'
portal
',
'
new
'
=>
'
http://auth2.example.com/
',
'
old
'
=>
'
http://auth.example.com/
'
},
{
'
new
'
=>
0
,
'
old
'
=>
1
,
'
key
'
=>
'
portalDisplayLogout
'
},
{
'
key
'
=>
'
applicationList, Sample applications, Application Test 1, uri
',
'
old
'
=>
'
http://test1.example.com/
',
'
new
'
=>
'
http://testex.example.com/
'
},
{
'
new
'
=>
'
Application Test 3
',
'
key
'
=>
'
applicationList, Sample applications
'
},
{
'
new
'
=>
'
Changes in cat(s)/app(s)
',
'
key
'
=>
'
applicationList
',
},
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Documentation
',
'
new
'
=>
'
Administration
',
},
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Administration
',
'
new
'
=>
'
Sample applications
',
},
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Sample applications
',
'
new
'
=>
'
Documentation
',
},
{
'
key
'
=>
'
userDB
',
'
new
'
=>
'
LDAP
',
'
old
'
=>
'
Demo
'
},
{
'
key
'
=>
'
passwordDB
',
'
new
'
=>
'
LDAP
',
'
old
'
=>
'
Demo
'
},
{
'
key
'
=>
'
openIdSPList
',
'
new
'
=>
'
1;bad.com
'
},
{
'
new
'
=>
'
Uid
',
'
key
'
=>
'
exportedVars
'
},
{
'
key
'
=>
'
locationRules, test1.example.com, (?#Logout comment)^/logout
',
'
new
'
=>
'
logout_sso
',
'
old
'
=>
undef
},
{
'
old
'
=>
'
^/logout
',
'
key
'
=>
'
locationRules, test1.example.com
'
},
{
'
key
'
=>
'
locationRules, test3.example.com, ^/logout
',
'
new
'
=>
'
logout_sso
',
'
old
'
=>
undef
},
{
'
key
'
=>
'
locationRules, test3.example.com, default
',
'
old
'
=>
undef
,
'
new
'
=>
'
accept
'
},
{
'
key
'
=>
'
locationRules
',
'
new
'
=>
'
test3.example.com
'
},
{
'
key
'
=>
'
exportedHeaders, test3.example.com, Auth-User
',
'
old
'
=>
undef
,
'
new
'
=>
'
$uid
'
},
{
'
new
'
=>
'
test3.example.com
',
'
key
'
=>
'
exportedHeaders
'
},
{
'
key
'
=>
'
locationRules, test.ex.com, default
',
'
old
'
=>
undef
,
'
new
'
=>
'
deny
'
},
{
'
key
'
=>
'
locationRules
',
'
new
'
=>
'
test.ex.com
'
},
{
'
key
'
=>
'
virtualHosts
',
'
new
'
=>
'
test3.example.com
',
'
old
'
=>
'
test2.example.com
'
},
{
'
key
'
=>
'
virtualHosts
',
'
old
'
=>
'
test2.example.com
'
},
{
'
new
'
=>
1
,
'
key
'
=>
'
portalDisplayResetPassword
',
'
old
'
=>
0
},
{
'
new
'
=>
0
,
'
key
'
=>
'
captcha_mail_enabled
',
'
old
'
=>
'
1
'
}
];
}
lemonldap-ng-manager/t/12-save-changed-conf.t
View file @
1a3e8032
...
...
@@ -26,18 +26,29 @@ ok( $resBody = from_json( $res->[2]->[0] ),
"
Result body contains JSON text
"
);
ok
(
$resBody
->
{
result
}
==
1
,
"
JSON response contains
\"
result:1
\"
"
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$resBody
->
{
details
}
->
{
__warnings__
}
and
@
{
$resBody
->
{
details
}
->
{
__warnings__
}
}
==
2
,
ok
(
@
{
$resBody
->
{
details
}
->
{
__warnings__
}
}
==
2
,
'
JSON response contains 2 warnings
'
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$resBody
->
{
details
}
->
{
__warnings__
}
->
[
0
]
->
{
message
}
=~
/\b(unprotected|cross-domain-authentication)\b/
,
"
Warning with 'unprotect' or 'CDA' found
"
)
or
print
STDERR
Dumper
(
$resBody
);
ok
(
$resBody
->
{
details
}
->
{
__warnings__
}
->
[
1
]
->
{
message
}
=~
/\b(unprotected|cross-domain-authentication)\b/
,
"
Warning with 'unprotect' or 'CDA' found
"
)
or
print
STDERR
Dumper
(
$resBody
);
foreach
my
$i
(
0
..
1
)
{
ok
(
$resBody
->
{
details
}
->
{
__warnings__
}
->
[
$i
]
->
{
message
}
=~
/\b(unprotected|cross-domain-authentication)\b/
,
"
Warning with 'unprotect', 'CDA' or 'retries' found
"
)
or
print
STDERR
Dumper
(
$resBody
);
}
# ok( $resBody->{details}->{__warnings__}->[0]->{message}
# =~ /\b(unprotected|cross-domain-authentication)\b/,
# "Warning with 'unprotect' or 'CDA' found"
# ) or print STDERR Dumper($resBody);
# ok( $resBody->{details}->{__warnings__}->[1]->{message}
# =~ /\b(unprotected|cross-domain-authentication)\b/,
# "Warning with 'unprotect' or 'CDA' found"
# ) or print STDERR Dumper($resBody);
ok
(
-
f
$confFiles
->
[
1
],
'
File is created
'
);
count
(
3
);
my
@changes
=
@
{
&
changes
};
...
...
lemonldap-ng-manager/t/15-combination.t
View file @
1a3e8032
...
...
@@ -12,6 +12,7 @@ sub body {
}
unlink
'
t/conf/lmConf-2.json
';
mkdir
'
t/sessions
';
my
(
$res
,
$resBody
);
ok
(
$res
=
&
client
->
_post
(
'
/confs/
',
'
cfgNum=1
',
&
body
,
'
application/json
'
),
...
...
@@ -37,8 +38,6 @@ count(9);
done_testing
(
count
()
);
unlink
'
t/conf/lmConf-2.json
';
`
rm t/sessions/*
`;
\ No newline at end of file
`
rm -rf t/sessions
`;
\ No newline at end of file
lemonldap-ng-manager/t/jsonfiles/13-modified-with-confirmation.json
0 → 100644
View file @
1a3e8032
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment