Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LemonLDAP NG
lemonldap-ng
Commits
61e880f9
Commit
61e880f9
authored
Dec 01, 2018
by
Christophe Maudoux
🐛
Browse files
tidy (#1561)
parent
d17cfd53
Changes
1
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-manager/t/12-save-changed-conf.t
View file @
61e880f9
...
...
@@ -19,22 +19,30 @@ mkdir 't/sessions';
my
(
$res
,
$resBody
);
ok
(
$res
=
&client
->
_post
(
'
/confs/
',
'
cfgNum=1
',
&body
,
'
application/json
'
),
"
Request succeed
"
);
"
Request succeed
"
);
ok
(
$res
->
[
0
]
==
200
,
"
Result code is 200
"
);
ok
(
$resBody
=
from_json
(
$res
->
[
2
]
->
[
0
]
),
"
Result body contains JSON text
"
);
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__
'}
}
==
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
);
or
print
STDERR
Dumper
(
$resBody
);
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
);
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
;
...
...
@@ -48,13 +56,13 @@ while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) {
}
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
);
or
print
STDERR
'
Expect:
'
.
(
$cmp1
-
@changes
)
.
'
, got:
'
.
(
$cmp2
-
@cmsg
)
.
"
\n
Expect:
"
.
Dumper
(
\
@d1
)
.
"
Got:
"
.
Dumper
(
\
@d2
);
}
count
(
1
);
}
...
...
@@ -62,9 +70,9 @@ ok( !@changes, 'All changes detected' ) or $bug = 1;
if
(
$bug
)
{
print
STDERR
'
Expected not found:
'
.
Dumper
(
\
@changes
)
.
'
Changes announced and not found:
'
.
Dumper
(
\
@cmsg
);
.
Dumper
(
\
@changes
)
.
'
Changes announced and not found:
'
.
Dumper
(
\
@cmsg
);
}
#print STDERR Dumper(\@changes,\@cmsg);
...
...
@@ -77,13 +85,14 @@ 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
==
11
,
'
11 keys changed in conf 1
'
)
or
print
STDERR
"
Expect: 11 keys, get:
"
.
join
(
'
,
',
@c1
)
.
"
\n
";
or
print
STDERR
"
Expect: 11 keys, get:
"
.
join
(
'
,
',
@c1
)
.
"
\n
";
ok
(
@c2
==
14
,
'
14 keys changed or created in conf 2
'
)
or
print
STDERR
"
Expect: 14 keys, get:
"
.
join
(
'
,
',
@c2
)
.
"
\n
";
or
print
STDERR
"
Expect: 14 keys, get:
"
.
join
(
'
,
',
@c2
)
.
"
\n
";
count
(
5
);
unlink
$confFiles
->
[
1
];
#eval { rmdir 't/sessions'; };
done_testing
(
count
()
);
...
...
@@ -92,112 +101,89 @@ done_testing( count() );
sub
changes
{
return
[
{
'
key
'
=>
'
portal
',
{
'
key
'
=>
'
portal
',
'
new
'
=>
'
http://auth2.example.com/
',
'
old
'
=>
'
http://auth.example.com/
'
},
{
'
new
'
=>
0
,
{
'
new
'
=>
0
,
'
old
'
=>
1
,
'
key
'
=>
'
portalDisplayLogout
'
},
{
'
key
'
=>
'
applicationList, Sample applications, Application Test 1, uri
',
{
'
key
'
=>
'
applicationList, Sample applications, Application Test 1, uri
',
'
old
'
=>
'
http://test1.example.com/
',
'
new
'
=>
'
http://testex.example.com/
'
},
{
'
new
'
=>
'
Application Test 3
',
{
'
new
'
=>
'
Application Test 3
',
'
key
'
=>
'
applicationList, Sample applications
'
},
{
'
new
'
=>
'
Changes in cat(s)/app(s)
',
{
'
new
'
=>
'
Changes in cat(s)/app(s)
',
'
key
'
=>
'
applicationList
',
},
{
'
key
'
=>
'
applicationList
',
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Documentation
',
'
new
'
=>
'
Administration
',
},
{
'
key
'
=>
'
applicationList
',
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Administration
',
'
new
'
=>
'
Sample applications
',
},
{
'
key
'
=>
'
applicationList
',
{
'
key
'
=>
'
applicationList
',
'
old
'
=>
'
Sample applications
',
'
new
'
=>
'
Documentation
',
},
{
'
key
'
=>
'
userDB
',
{
'
key
'
=>
'
userDB
',
'
new
'
=>
'
LDAP
',
'
old
'
=>
'
Demo
'
},
{
'
key
'
=>
'
passwordDB
',
{
'
key
'
=>
'
passwordDB
',
'
new
'
=>
'
LDAP
',
'
old
'
=>
'
Demo
'
},
{
'
key
'
=>
'
openIdSPList
',
{
'
key
'
=>
'
openIdSPList
',
'
new
'
=>
'
1;bad.com
'
},
{
'
new
'
=>
'
Uid
',
{
'
new
'
=>
'
Uid
',
'
key
'
=>
'
exportedVars
'
},
{
'
key
'
=>
'
locationRules, test1.example.com, (?#Logout comment)^/logout
',
{
'
key
'
=>
'
locationRules, test1.example.com, (?#Logout comment)^/logout
',
'
new
'
=>
'
logout_sso
',
'
old
'
=>
undef
},
{
'
old
'
=>
'
^/logout
',
{
'
old
'
=>
'
^/logout
',
'
key
'
=>
'
locationRules, test1.example.com
'
},
{
'
key
'
=>
'
locationRules, test3.example.com, ^/logout
',
{
'
key
'
=>
'
locationRules, test3.example.com, ^/logout
',
'
new
'
=>
'
logout_sso
',
'
old
'
=>
undef
},
{
'
key
'
=>
'
locationRules, test3.example.com, default
',
{
'
key
'
=>
'
locationRules, test3.example.com, default
',
'
old
'
=>
undef
,
'
new
'
=>
'
accept
'
},
{
'
key
'
=>
'
locationRules
',
{
'
key
'
=>
'
locationRules
',
'
new
'
=>
'
test3.example.com
'
},
{
'
key
'
=>
'
exportedHeaders, test3.example.com, Auth-User
',
{
'
key
'
=>
'
exportedHeaders, test3.example.com, Auth-User
',
'
old
'
=>
undef
,
'
new
'
=>
'
$uid
'
},
{
'
new
'
=>
'
test3.example.com
',
{
'
new
'
=>
'
test3.example.com
',
'
key
'
=>
'
exportedHeaders
'
},
{
'
key
'
=>
'
locationRules, test.ex.com, default
',
{
'
key
'
=>
'
locationRules, test.ex.com, default
',
'
old
'
=>
undef
,
'
new
'
=>
'
deny
'
},
{
'
key
'
=>
'
locationRules
',
{
'
key
'
=>
'
locationRules
',
'
new
'
=>
'
test.ex.com
'
},
{
'
key
'
=>
'
virtualHosts
',
{
'
key
'
=>
'
virtualHosts
',
'
new
'
=>
'
test3.example.com
',
'
old
'
=>
'
test2.example.com
'
},
{
'
key
'
=>
'
virtualHosts
',
{
'
key
'
=>
'
virtualHosts
',
'
old
'
=>
'
test2.example.com
'
}
];
...
...
Write
Preview
Supports
Markdown
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