mirror of
https://github.com/nicolabs/ldap-plugin.git
synced 2026-05-21 11:58:41 +02:00
Establish test baseline for settings storage and UI configuration.
This commit is contained in:
parent
64fcf64850
commit
9f7037d383
65
src/test/java/hudson/security/LDAPSecurityRealm_Test.java
Normal file
65
src/test/java/hudson/security/LDAPSecurityRealm_Test.java
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright 2014 Jesse Glick.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package hudson.security;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.jvnet.hudson.test.JenkinsRule;
|
||||||
|
import org.jvnet.hudson.test.recipes.LocalData;
|
||||||
|
|
||||||
|
public class LDAPSecurityRealm_Test { // different name so as not to clash with LDAPSecurityRealmTest.groovy
|
||||||
|
|
||||||
|
@Rule public JenkinsRule r = new JenkinsRule();
|
||||||
|
|
||||||
|
@LocalData
|
||||||
|
@Test public void compatAndConfig() throws Exception {
|
||||||
|
check();
|
||||||
|
r.configRoundtrip();
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check() {
|
||||||
|
LDAPSecurityRealm sr = (LDAPSecurityRealm) r.jenkins.getSecurityRealm();
|
||||||
|
assertEquals("s", sr.server);
|
||||||
|
assertEquals("rDN", sr.rootDN);
|
||||||
|
assertEquals("uSB", sr.userSearchBase);
|
||||||
|
assertEquals("uS", sr.userSearch);
|
||||||
|
assertEquals("gSB", sr.groupSearchBase);
|
||||||
|
assertEquals("gSF", sr.groupSearchFilter);
|
||||||
|
assertEquals("gMF", sr.groupMembershipFilter);
|
||||||
|
assertEquals("mDN", sr.managerDN);
|
||||||
|
assertEquals("s3cr3t", sr.getManagerPassword());
|
||||||
|
assertTrue(sr.inhibitInferRootDN);
|
||||||
|
assertTrue(sr.disableMailAddressResolver);
|
||||||
|
assertEquals(Integer.valueOf(20), sr.getCacheSize());
|
||||||
|
assertEquals(Integer.valueOf(60), sr.getCacheTTL());
|
||||||
|
assertEquals(Collections.singletonMap("k", "v"), sr.getExtraEnvVars());
|
||||||
|
assertEquals("dNAN", sr.getDisplayNameAttributeName());
|
||||||
|
assertEquals("mAAN", sr.getMailAddressAttributeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<hudson>
|
||||||
|
<disabledAdministrativeMonitors/>
|
||||||
|
<version>1.480</version>
|
||||||
|
<numExecutors>2</numExecutors>
|
||||||
|
<mode>NORMAL</mode>
|
||||||
|
<useSecurity>true</useSecurity>
|
||||||
|
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
|
||||||
|
<securityRealm class="hudson.security.LDAPSecurityRealm">
|
||||||
|
<server>s</server>
|
||||||
|
<rootDN>rDN</rootDN>
|
||||||
|
<inhibitInferRootDN>true</inhibitInferRootDN>
|
||||||
|
<userSearchBase>uSB</userSearchBase>
|
||||||
|
<userSearch>uS</userSearch>
|
||||||
|
<groupSearchBase>gSB</groupSearchBase>
|
||||||
|
<groupSearchFilter>gSF</groupSearchFilter>
|
||||||
|
<groupMembershipFilter>gMF</groupMembershipFilter>
|
||||||
|
<managerDN>mDN</managerDN>
|
||||||
|
<managerPassword>czNjcjN0</managerPassword>
|
||||||
|
<disableMailAddressResolver>true</disableMailAddressResolver>
|
||||||
|
<cache>
|
||||||
|
<size>20</size>
|
||||||
|
<ttl>60</ttl>
|
||||||
|
</cache>
|
||||||
|
<extraEnvVars class="linked-hash-map">
|
||||||
|
<entry>
|
||||||
|
<string>k</string>
|
||||||
|
<string>v</string>
|
||||||
|
</entry>
|
||||||
|
</extraEnvVars>
|
||||||
|
<displayNameAttributeName>dNAN</displayNameAttributeName>
|
||||||
|
<mailAddressAttributeName>mAAN</mailAddressAttributeName>
|
||||||
|
</securityRealm>
|
||||||
|
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
|
||||||
|
<workspaceDir>${ITEM_ROOTDIR}/workspace</workspaceDir>
|
||||||
|
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
|
||||||
|
<markupFormatter class="hudson.markup.RawHtmlMarkupFormatter">
|
||||||
|
<disableSyntaxHighlighting>false</disableSyntaxHighlighting>
|
||||||
|
</markupFormatter>
|
||||||
|
<jdks/>
|
||||||
|
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
|
||||||
|
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
|
||||||
|
<clouds/>
|
||||||
|
<slaves/>
|
||||||
|
<quietPeriod>5</quietPeriod>
|
||||||
|
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
|
||||||
|
<views>
|
||||||
|
<hudson.model.AllView>
|
||||||
|
<owner class="hudson" reference="../../.."/>
|
||||||
|
<name>All</name>
|
||||||
|
<filterExecutors>false</filterExecutors>
|
||||||
|
<filterQueue>false</filterQueue>
|
||||||
|
<properties class="hudson.model.View$PropertyList"/>
|
||||||
|
</hudson.model.AllView>
|
||||||
|
</views>
|
||||||
|
<primaryView>All</primaryView>
|
||||||
|
<slaveAgentPort>0</slaveAgentPort>
|
||||||
|
<label></label>
|
||||||
|
<nodeProperties/>
|
||||||
|
<globalNodeProperties/>
|
||||||
|
</hudson>
|
||||||
Loading…
Reference in a new issue