Maxime Besson 5 years ago
parent 9595a28d0e
commit a41be3511b
  1. 36
      lemonldap-ng-manager/t/04-providers-api.t

@ -243,7 +243,7 @@ sub checkFindByConfKey {
my ( $test, $type, $confKey, $expectedHits ) = splice @_;
my $res = findByConfKey( $test, $type, $confKey );
check200( $test, $res );
my $hits = from_json( $res->[2]->[0] );
my $hits = from_json( $res->[2]->[0] );
my $counter = @{$hits};
ok(
$counter eq $expectedHits,
@ -276,7 +276,7 @@ sub checkFindByProviderId {
($gotProviderId) = $result->{metadata} =~ m/entityID=['"](.+?)['"]/i;
}
elsif ( $providerIdName eq 'serviceUrl' ) {
$gotProviderId = $result->{options}->{service};
$gotProviderId = $result->{options}->{service};
}
else {
$gotProviderId = $result->{$providerIdName};
@ -638,9 +638,9 @@ checkDeleteNotFound( $test, 'saml/sp', 'mySamlSp1' );
my $casApp = {
confKey => 'myCasApp1',
exportedVars => {
"cn" => "cn",
"uid" => "uid",
"mail" => "mail"
"cn" => "cn",
"uid" => "uid",
"mail" => "mail"
},
macros => {
given_name => '$firstName',
@ -654,7 +654,8 @@ my $casApp = {
$test = "CasApp - Add should succeed";
checkAdd( $test, 'cas/app', $casApp );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/service', 'http://mycasapp.example.com' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/service',
'http://mycasapp.example.com' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/userAttribute', 'uid' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/rule', '$uid eq \'dwho\'' );
@ -663,18 +664,19 @@ checkAddFailsIfExists( $test, 'cas/app', $casApp );
$test = "CasApp - Update should succeed and keep existing values";
$casApp->{options}->{service} = 'http://mycasapp.acme.com';
$casApp->{options}->{userAttribute} = 'cn';
$casApp->{options}->{userAttribute} = 'cn';
delete $casApp->{options}->{rule};
delete $casApp->{macros};
delete $casApp->{exportedVars};
$casApp->{macros}->{given_name} = '$givenName';
$casApp->{exportedVars}->{cn} = 'uid';
checkUpdate( $test, 'cas/app', 'myCasApp1', $casApp );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/service', 'http://mycasapp.acme.com' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/service',
'http://mycasapp.acme.com' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/userAttribute', 'cn' );
checkGet( $test, 'cas/app', 'myCasApp1', 'options/rule', '$uid eq \'dwho\'' );
checkGet( $test, 'cas/app', 'myCasApp1', 'exportedVars/cn', 'uid' );
checkGet( $test, 'cas/app', 'myCasApp1', 'exportedVars/uid', 'uid' );
checkGet( $test, 'cas/app', 'myCasApp1', 'exportedVars/cn', 'uid' );
checkGet( $test, 'cas/app', 'myCasApp1', 'exportedVars/uid', 'uid' );
checkGet( $test, 'cas/app', 'myCasApp1', 'macros/given_name', '$givenName' );
$test = "CasApp - Update should fail on non existing options";
@ -682,14 +684,14 @@ $casApp->{options}->{playingPossum} = 'elephant';
checkUpdateWithUnknownAttributes( $test, 'cas/app', 'myCasApp1', $casApp );
delete $casApp->{options}->{playingPossum};
$test = "CasApp - Add should fail on non existing options";
$casApp->{confKey} = 'myCasApp2';
$casApp->{options}->{service} = 'http://mycasapp.skynet.com';
$test = "CasApp - Add should fail on non existing options";
$casApp->{confKey} = 'myCasApp2';
$casApp->{options}->{service} = 'http://mycasapp.skynet.com';
$casApp->{options}->{playingPossum} = 'ElephantInTheRoom';
checkAddWithUnknownAttributes( $test, 'cas/app', $casApp );
delete $casApp->{options}->{playingPossum};
$test = "CasApp - Add should fail because service host already exists";
$test = "CasApp - Add should fail because service host already exists";
$casApp->{options}->{service} = 'http://mycasapp.acme.com/ignoredbyissuer';
checkAddFailsIfExists( $test, 'cas/app', $casApp );
@ -701,10 +703,10 @@ $test = "CasApp - Update should fail if confKey not found";
$casApp->{confKey} = 'myCasApp3';
checkUpdateNotFound( $test, 'cas/app', 'myCasApp3', $casApp );
$test = "CasApp - Replace should succeed";
$casApp->{confKey} = 'myCasApp2';
$test = "CasApp - Replace should succeed";
$casApp->{confKey} = 'myCasApp2';
checkGet( $test, 'cas/app', 'myCasApp2', 'options/userAttribute', 'cn' );
$casApp->{options}->{userAttribute} = 'uid';
$casApp->{options}->{userAttribute} = 'uid';
checkReplace( $test, 'cas/app', 'myCasApp2', $casApp );
checkGet( $test, 'cas/app', 'myCasApp2', 'options/userAttribute', 'uid' );

Loading…
Cancel
Save