Skip to content
Permalink
Browse files
Merge pull request #10 from kwhetstone/master
[JENKINS-36499] Update to the new Parent POM
  • Loading branch information
stephenc committed Oct 5, 2016
2 parents 37ec8d0 + 4c429ee commit bc0db50d1e67af115230f1e5c960a064e72effa7
43 pom.xml
@@ -5,17 +5,18 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
<version>2.15</version>
</parent>

<artifactId>openid</artifactId>
<version>2.2-SNAPSHOT</version>
<packaging>hpi</packaging>

<properties>
<findbugs-maven-plugin.version>3.0.1</findbugs-maven-plugin.version>
<!--TODO: Enforce when the code becomes 100% clean-->
<findbugs.failOnError>false</findbugs.failOnError>
<jenkins.version>1.609.3</jenkins.version>
<java.level>6</java.level>
<concurrency>1</concurrency>
</properties>

@@ -45,13 +46,13 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

@@ -66,38 +67,6 @@
<artifactId>mailer</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
<configuration>
<failOnError>${findbugs.failOnError}</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
</project>
@@ -107,11 +107,13 @@ public static ExtensionList<OpenIdExtension> all() {
*
* @param authRequest the authentication request.
* @throws MessageException if there is a message error extending the request
* @throws IllegalStateException if there is no Jenkins instance
*/
public static void extendRequest(AuthRequest authRequest) throws MessageException {
FetchRequest request = FetchRequest.createFetchRequest();
SecurityRealm sr = Jenkins.getActiveInstance().getSecurityRealm();
for (OpenIdExtension e : all()) {
if (e.isApplicable(Jenkins.getInstance().getSecurityRealm())) {
if (e.isApplicable(sr)) {
e.extend(authRequest);
e.extendFetch(request);
}
@@ -127,10 +129,12 @@ public static void extendRequest(AuthRequest authRequest) throws MessageExceptio
* @param authSuccess the authentication success.
* @param id the identity.
* @throws MessageException if there is a message error processing the success.
* @throws IllegalStateException if there is no Jenkins instance
*/
public static void processResponse(AuthSuccess authSuccess, Identity id) throws MessageException {
SecurityRealm sc = Jenkins.getActiveInstance().getSecurityRealm();
for (OpenIdExtension e : all()) {
if (e.isApplicable(Jenkins.getInstance().getSecurityRealm())) {
if (e.isApplicable(sc)) {
e.process(authSuccess, id);
}
}
@@ -25,6 +25,7 @@

import com.cloudbees.openid4java.team.TeamExtensionFactory;
import com.cloudbees.openid4java.team.TeamExtensionRequest;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.Failure;
import hudson.model.Hudson;
import hudson.util.HttpResponses;
@@ -81,6 +82,7 @@ public OpenIdSession(ConsumerManager manager, String openid, String finishUrl) t
/**
* Starts the login session.
*/
@SuppressFBWarnings(value="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION", justification="Just for this login.")
public HttpResponse doCommenceLogin() throws IOException, OpenIDException {
final AuthRequest authReq = manager.authenticate(endpoint, Hudson.getInstance().getRootUrl()+ finishUrl);

@@ -165,7 +165,7 @@ public HttpResponse doCommenceLogin(@QueryParameter String from) throws IOExcept
if (Stapler.getCurrentRequest().getHeader("Referer") != null) {
from = Stapler.getCurrentRequest().getHeader("Referer");
} else {
from = Jenkins.getInstance().getRootUrl();
from = Jenkins.getActiveInstance().getRootUrl();
}
}

@@ -83,7 +83,7 @@ public UserProperty newInstance(User user) {

@Override
public boolean isEnabled() {
return Jenkins.getInstance().getSecurityRealm() instanceof AbstractPasswordBasedSecurityRealm
return Jenkins.getActiveInstance().getSecurityRealm() instanceof AbstractPasswordBasedSecurityRealm
&& (openIdLoginService != null && !openIdLoginService.isDisabled());
}

@@ -30,6 +30,6 @@ public String getUrlName() {

// serve static resources
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
Jenkins.getInstance().getPlugin("openid").doDynamic(req,rsp);
Jenkins.getActiveInstance().getPlugin("openid").doDynamic(req,rsp);
}
}
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<div>
<link type="text/css" rel="stylesheet" href="${resURL}/openid-assets/openid.css"/>
@@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:if test="${!it.disabled}">
<div style="padding-top:3em">
@@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<l:layout title="${%OpenID Successfully Associated}">
<l:main-panel>
@@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%OpenIDs}">
<ul>
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
This plugin enables user authentication via OpenID.
</div>
@@ -32,21 +32,28 @@
import hudson.plugins.openid.OpenIdTestService.IdProperty;
import hudson.tasks.Mailer;
import hudson.tasks.Mailer.UserProperty;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

import java.io.IOException;
import java.util.Map;

import static hudson.plugins.openid.OpenIdTestService.*;
import static org.junit.Assert.*;

/**
* @author Nirmal Jonnalagedda
*/
public class OpenIdAXEmailAttributesTest extends OpenIdTestCase {

void _testEmailAttributes(String userName) throws Exception {
WebClient wc = new WebClient();
WebClient wc = jr.createWebClient();

OpenIdSsoSecurityRealm realm = new OpenIdSsoSecurityRealm(openid.url);
hudson.setSecurityRealm(realm);
OpenIdSsoSecurityRealm realm = new OpenIdSsoSecurityRealm(jr.openid.url);
jr.jenkins.setSecurityRealm(realm);

HtmlPage top = wc.goTo("");
top = top.getAnchorByText("log in").click();
@@ -56,61 +63,66 @@ void _testEmailAttributes(String userName) throws Exception {

assertTrue(up.hasExplicitlyConfiguredAddress());

if (openid.props.get(IdProperty.email) != null)
assertEquals(up.getAddress(), openid.props.get(IdProperty.email));
else if (openid.props.get(IdProperty.email2) != null)
assertEquals(up.getAddress(), openid.props.get(IdProperty.email2));
if (jr.openid.props.get(IdProperty.email) != null)
assertEquals(up.getAddress(), jr.openid.props.get(IdProperty.email));
else if (jr.openid.props.get(IdProperty.email2) != null)
assertEquals(up.getAddress(), jr.openid.props.get(IdProperty.email2));
else
assertEquals(up.getAddress(), openid.props.get(IdProperty.email3));
assertEquals(up.getAddress(), jr.openid.props.get(IdProperty.email3));
}

@Test
public void testEmailWithAXExtensionWithAllSameEmailAttributes() throws Exception {
openid = new OpenIdTestService(
getServiceUrl(),
jr.openid = new OpenIdTestService(
jr.getServiceUrl(),
getPropsAllSameEmails(),
Sets.newHashSet("foo", "bar"),
Lists.newArrayList(SREG_EXTENSION, AX_EXTENSION, TEAM_EXTENSION));

_testEmailAttributes(openid.props.get(IdProperty.nick));
_testEmailAttributes(jr.openid.props.get(IdProperty.nick));
}

@Test
public void testEmailWithAXExtensionWithAllDifferentEmailAttributes() throws Exception {
openid = new OpenIdTestService(
getServiceUrl(),
jr.openid = new OpenIdTestService(
jr.getServiceUrl(),
getPropsAllDifferentEmails(),
Sets.newHashSet("foo", "bar"),
Lists.newArrayList(SREG_EXTENSION, AX_EXTENSION, TEAM_EXTENSION));

_testEmailAttributes(openid.props.get(IdProperty.nick));
_testEmailAttributes(jr.openid.props.get(IdProperty.nick));
}

@Test
public void testEmailWithAXExtensionWithAnyTwoDifferentEmailAttributes() throws Exception {
openid = new OpenIdTestService(
getServiceUrl(),
jr.openid = new OpenIdTestService(
jr.getServiceUrl(),
getPropsWithAnyTwoDifferentEmails(),
Sets.newHashSet("foo", "bar"),
Lists.newArrayList(SREG_EXTENSION, AX_EXTENSION, TEAM_EXTENSION));

_testEmailAttributes(openid.props.get(IdProperty.nick));
_testEmailAttributes(jr.openid.props.get(IdProperty.nick));
}

@Test
public void testEmailWithAXExtensionWithAnyTwoSameEmailAttributes() throws Exception {
openid = new OpenIdTestService(
getServiceUrl(),
jr.openid = new OpenIdTestService(
jr.getServiceUrl(),
getPropsWithAnyTwoSameEmails(),
Sets.newHashSet("foo", "bar"),
Lists.newArrayList(SREG_EXTENSION, AX_EXTENSION, TEAM_EXTENSION));

_testEmailAttributes(openid.props.get(IdProperty.nick));
_testEmailAttributes(jr.openid.props.get(IdProperty.nick));
}

@Test
public void testEmailWithAXExtensionWithOneEmailAttribute() throws Exception {
openid = new OpenIdTestService(
getServiceUrl(),
jr.openid = new OpenIdTestService(
jr.getServiceUrl(),
getPropsWithOneEmail(),
Sets.newHashSet("foo", "bar"),
Lists.newArrayList(SREG_EXTENSION, AX_EXTENSION, TEAM_EXTENSION));

_testEmailAttributes(openid.props.get(IdProperty.nick));
_testEmailAttributes(jr.openid.props.get(IdProperty.nick));
}
}

0 comments on commit bc0db50

Please sign in to comment.