Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow use of settings.xml for credentials. #27

Closed
wants to merge 15 commits into from

2 participants

@smoyer64

As noted in issue #25, adding an id element to the configuration section of this plugin and a bit of logic to find the associated username and password in the settings.xml file eliminates the need to put the credentials in the pom.xml file (or to enter them when prompted by the CLI).

This change set includes that functionality along with mojo tests to verify that the username and password are pulled from the correct locations.

smoyer64 added some commits
@smoyer64 smoyer64 Stubbed out logic to load the username and password from the settings
file if an <id> element is provided and username and password are both
null.
9b7aaf9
@smoyer64 smoyer64 Added code to get the username and password from the settings.xml file
if an id is provided (with null username and password values).
0d1ec05
@smoyer64 smoyer64 Added libraries required to process the contents of the settings file as
well as the libraries used to test maven plug-ins.
75d0401
@smoyer64 smoyer64 Copied a stubbed out example pom.xml and settings.xml file into the
project.
5ce7f07
@smoyer64 smoyer64 Stubbed out a base TestCase with some helper methods and added an empty
test class for the AbstractServerConnection (Mojo).
a12a700
@smoyer64 smoyer64 Eliminated HTTP imports that weren't provided by Maven dependencies (or
needed by the plug-in)
0c33375
@smoyer64 smoyer64 Fixed the annotation on the new settings parameter. d028989
@smoyer64 smoyer64 Cleaned up the utility methods and added comments. 61d8eef
@smoyer64 smoyer64 Added the rest of the pom.xml files and settings.xml file needed to test
how credentials are acquired by the plugin.
6013cf1
@smoyer64 smoyer64 Added the rest of the settings.xml and pom.xml files needed to
completely test the plugin's acquisition of credentials.
ebe47be
@smoyer64 smoyer64 Added Mockito to the test dependencies so that the plugin's log could be
mocked and analyzed.
6cf9a6b
@smoyer64 smoyer64 Completed the logic that determines how credentials are acquired by the
plugin.
8904017
@smoyer64 smoyer64 Finished writing tests for the 6 usable permutations of how credentials
can be acquired by the plugin.
77b20d5
@smoyer64 smoyer64 Changed the last few log messages related to the acquisition of
credentials from info to debug level.
6971ccd
@jamezp
Collaborator

Thank you for this! I'm on holiday for the rest of the week, but I'll give it a review as soon as I can. At a first glance it looks great.

@smoyer64

There's no hurry as I've built it on our Jenkins and included it from our internal Nexus instance. It's one of those instances where it's better not to break anyone else! In any case, I only modified AbstractServerConnection.java, and added a few dependencies to pom.xml (mostly test scoped). The other files are tests and test resources.

In any case, I'm happy to contribute back to the project as you've saved me a lot of time. I seemed to be stuck between jboss-maven-plugin being behind AS7 and jboss-as-maven-plugin not meeting our security groups requirements (no usernames and passwords can be checked into SCM).

Thanks for all your work ... have a great vacation ... and let me know if you need anything!

Steve

pom.xml
((22 lines not shown))
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings-builder</artifactId>
+ <version>3.0.3</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.0</version>
+ <scope>test</scope>
+ </dependency>
@jamezp Collaborator
jamezp added a note

All the versions should use a property in the version.groupId.artifactId format or something similar to the version properties that are already in the POM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jamezp jamezp commented on the diff
...ugin/common/AbstractJbossMavenPluginMojoTestCase.java
@@ -0,0 +1,117 @@
+/*
+ * File: MojoTestUtilities.java
+ * Date: Aug 5, 2011
+ *
+ * Copyright (c) 2011 by Select Systems - All rights reserved.
+ *
+ * By: Select Systems
+ * 111 Heritage Way, Suite S
+ * Boalsburg, PA 16827
+ *
+ * Revision history:
+ *
+ *
+ */
@jamezp Collaborator
jamezp added a note

I don't mind making the change, but this needs to have the JBoss LGPL license on it. Is that acceptable to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jamezp jamezp commented on the diff
...ss/as/plugin/common/AbstractServerConnectionTest.java
@@ -0,0 +1,180 @@
+/*
+ * File: AbstractServerConnectionTest.java
+ * Date: Nov 19, 2012
+ *
+ * Copyright (c) 2011 by Select Systems - All rights reserved.
+ *
+ * By: Select Systems
+ * 111 Heritage Way, Suite S
+ * Boalsburg, PA 16827
+ *
+ * Revision history:
+ *
+ *
+ */
@jamezp Collaborator
jamezp added a note

Same commit as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@smoyer64

Yes ... that can be relicensed and assigned as needed. Sorry I didn't catch that (I copied those classes from another plugin I've been working on). Do you need me to make these changes?

@jamezp
Collaborator

Nah, I'll go ahead an make them. I'll consider this your consent to change it :-)

@smoyer64

Perfect ... and thanks again!

@jamezp
Collaborator

Thank you very much @smoyer64 for the patch! Squashed commits and merged.

@jamezp jamezp closed this
@jamezp
Collaborator

I realize this is old and already merged, but I forgot to ask the licensing question.

We require that all contributions be made under the terms of the MIT License, http://www.opensource.org/licenses/mit-license.php. Do you agree to the these terms?

@jamezp
Collaborator

Just a ping on this as I'd like to get a release out this week. Note if you don't agree that's fine too, but I won't be able to use this awesome commit :-)

@smoyer64

I don't have a problem with that either ... and since I already assigned copyright, I don't think I can tell you no ;) Sorry for the delay but we had an unmovable dead-line and I had to stay focused on that project. Is there any functionality you'd like added to the plugin? Or do you have issues in Jira you'd like me to help with ... I can spend some of my time here at work helping OSS projects (easy for those that we use).

Thanks again!

Steve

@jamezp
Collaborator

No problem on the delay at all. Totally understand the deadline issue :-) Not that I can think of ATM, but if I do I'll let you know for sure. I mainly want this release to be more of a bug release and adding some features. I want 7.5.Final (after this release) to add more functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 20, 2012
  1. @smoyer64

    Stubbed out logic to load the username and password from the settings

    smoyer64 authored
    file if an <id> element is provided and username and password are both
    null.
  2. @smoyer64

    Added code to get the username and password from the settings.xml file

    smoyer64 authored
    if an id is provided (with null username and password values).
  3. @smoyer64

    Added libraries required to process the contents of the settings file as

    smoyer64 authored
    well as the libraries used to test maven plug-ins.
  4. @smoyer64
  5. @smoyer64

    Stubbed out a base TestCase with some helper methods and added an empty

    smoyer64 authored
    test class for the AbstractServerConnection (Mojo).
  6. @smoyer64
  7. @smoyer64
  8. @smoyer64
  9. @smoyer64

    Added the rest of the pom.xml files and settings.xml file needed to test

    smoyer64 authored
    how credentials are acquired by the plugin.
  10. @smoyer64

    Added the rest of the settings.xml and pom.xml files needed to

    smoyer64 authored
    completely test the plugin's acquisition of credentials.
  11. @smoyer64
  12. @smoyer64
  13. @smoyer64

    Finished writing tests for the 6 usable permutations of how credentials

    smoyer64 authored
    can be acquired by the plugin.
  14. @smoyer64

    Changed the last few log messages related to the acquisition of

    smoyer64 authored
    credentials from info to debug level.
Commits on Dec 1, 2012
  1. @smoyer64
This page is out of date. Refresh to see the latest.
View
38 pom.xml
@@ -48,14 +48,18 @@
<properties>
+ <version.junit.junit>4.11</version.junit.junit>
<version.org.jboss.as>7.1.2.Final</version.org.jboss.as>
<version.org.apache.maven.maven-plugin>2.2.1</version.org.apache.maven.maven-plugin>
+ <version.org.apache.maven.maven-settings>3.0.3</version.org.apache.maven.maven-settings>
<version.org.apache.maven.plugin-api>3.0.4</version.org.apache.maven.plugin-api>
+ <version.org.apache.maven.plugin-testing.maven-plugin-testing-harness>2.0-alpha-1</version.org.apache.maven.plugin-testing.maven-plugin-testing-harness>
<version.org.apache.maven.plugin-tools>3.1</version.org.apache.maven.plugin-tools>
<version.org.apache.maven.plugins.plugin>3.1</version.org.apache.maven.plugins.plugin>
<version.org.apache.maven.plugins.site-plugin>3.0</version.org.apache.maven.plugins.site-plugin>
<version.org.codehaus.plexus.plexus-utils>3.0.1</version.org.codehaus.plexus.plexus-utils>
<version.org.jboss.remoting3>3.2.12.GA</version.org.jboss.remoting3>
+ <version.org.mockito.mockito-all>1.9.0</version.org.mockito.mockito-all>
<version.org.sonatype.aether>1.8</version.org.sonatype.aether>
</properties>
@@ -161,5 +165,39 @@
<artifactId>plexus-utils</artifactId>
<version>${version.org.codehaus.plexus.plexus-utils}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit.junit}</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings</artifactId>
+ <version>${version.org.apache.maven.maven-settings}</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>${version.org.apache.maven.plugin-testing.maven-plugin-testing-harness}</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings-builder</artifactId>
+ <version>${version.org.apache.maven.maven-settings}</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${version.org.mockito.mockito-all}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
View
53 src/main/java/org/jboss/as/plugin/common/AbstractServerConnection.java
@@ -26,10 +26,13 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
+
import javax.security.auth.callback.CallbackHandler;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.domain.DomainClient;
import org.jboss.dmr.ModelNode;
@@ -41,6 +44,14 @@
* @author Stuart Douglas
*/
public abstract class AbstractServerConnection extends AbstractMojo implements ConnectionInfo, Closeable {
+
+ public static final String DEBUG_MESSAGE_NO_CREDS = "No username and password in settings.xml file - falling back to CLI entry";
+ public static final String DEBUG_MESSAGE_NO_ID = "No <id> element was found in the POM - Getting credentials from CLI entry";
+ public static final String DEBUG_MESSAGE_NO_SERVER_SECTION = "No <server> section was found for the specified id";
+ public static final String DEBUG_MESSAGE_NO_SETTINGS_FILE = "No settings.xml file was found in this Mojo's execution context";
+ public static final String DEBUG_MESSAGE_POM_HAS_CREDS = "Getting credentials from the POM";
+ public static final String DEBUG_MESSAGE_SETTINGS_HAS_CREDS = "Found username and password in the settings.xml file";
+ public static final String DEBUG_MESSAGE_SETTINGS_HAS_ID = "Found the server's id in the settings.xml file";
protected static final Object CLIENT_LOCK = new Object();
@@ -59,6 +70,19 @@
*/
@Parameter(defaultValue = "9999", property = "jboss-as.port")
private int port;
+
+ /**
+ * Specifies the id of the server if the username and password is to be
+ * retrieved from the settings.xml file
+ */
+ @Parameter(property = "jboss-as.id")
+ private String id;
+
+ /**
+ * Provides a reference to the settings file.
+ */
+ @Parameter(property = "settings", readonly = true, required = true, defaultValue = "${settings}")
+ private Settings settings;
/**
* Specifies the username to use if prompted to authenticate by the server.
@@ -168,10 +192,39 @@ public synchronized final InetAddress getHostAddress() {
public synchronized final CallbackHandler getCallbackHandler() {
CallbackHandler result = handler;
if (result == null) {
+ if(username == null && password == null) {
+ if(id != null) {
+ getCredentialsFromSettings();
+ } else {
+ getLog().debug(DEBUG_MESSAGE_NO_ID);
+ }
+ } else {
+ getLog().debug(DEBUG_MESSAGE_POM_HAS_CREDS);
+ }
result = handler = new ClientCallbackHandler(username, password);
}
return result;
}
+
+ private void getCredentialsFromSettings() {
+ if(settings != null) {
+ Server server = settings.getServer(id);
+ if(server != null) {
+ getLog().debug(DEBUG_MESSAGE_SETTINGS_HAS_ID);
+ password = server.getPassword();
+ username = server.getUsername();
+ if(username != null && password != null) {
+ getLog().debug(DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
+ } else {
+ getLog().debug(DEBUG_MESSAGE_NO_CREDS);
+ }
+ } else {
+ getLog().debug(DEBUG_MESSAGE_NO_SERVER_SECTION);
+ }
+ } else {
+ getLog().debug(DEBUG_MESSAGE_NO_SETTINGS_FILE);
+ }
+ }
private boolean isDomainServer(final ModelControllerClient client) {
boolean result = false;
View
117 src/test/java/org/jboss/as/plugin/common/AbstractJbossMavenPluginMojoTestCase.java
@@ -0,0 +1,117 @@
+/*
+ * File: MojoTestUtilities.java
+ * Date: Aug 5, 2011
+ *
+ * Copyright (c) 2011 by Select Systems - All rights reserved.
+ *
+ * By: Select Systems
+ * 111 Heritage Way, Suite S
+ * Boalsburg, PA 16827
+ *
+ * Revision history:
+ *
+ *
+ */
@jamezp Collaborator
jamezp added a note

I don't mind making the change, but this needs to have the JBoss LGPL license on it. Is that acceptable to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+package org.jboss.as.plugin.common;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.io.DefaultSettingsReader;
+import org.apache.maven.settings.io.SettingsParseException;
+import org.apache.maven.settings.io.SettingsReader;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ *
+ * @author swm16 (swm16@psu.edu)
+ */
+public abstract class AbstractJbossMavenPluginMojoTestCase extends AbstractMojoTestCase {
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Gets a settings.xml file from the input File and prepares it to be
+ * attached to a pom.xml
+ *
+ * @param a file object pointing to the candidate settings file
+ * @return the settings object
+ * @throws IOException - if the settings file can't be read
+ */
+ private Settings getSettingsFile(File userSettingsFile) throws IOException {
+ Map<String, ?> options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.TRUE );
+ SettingsReader reader = new DefaultSettingsReader();
+
+ Settings settings = null;
+ try {
+ settings = reader.read(userSettingsFile, options);
+ } catch(SettingsParseException e) {
+
+ }
+
+ return settings;
+ }
+
+ /**
+ * Creates a File object from the fileName provided and verifies that it
+ * exists.
+ *
+ * @param fileName the path of the test file
+ * @return a verified File object
+ */
+ public File getTestFileAndVerify(String fileName) {
+ File file = getTestFile(fileName);
+ assertNotNull(file);
+ assertTrue(file.exists());
+ return file;
+ }
+
+ /**
+ * Looks up the specified mojo by name, passing it the POM file that
+ * references it, then verifying that the lookup was successful.
+ *
+ * @param mojoName the name of the mojo being tested
+ * @param pomFile the pom.xml file to be used during testing
+ * @return the Mojo object under test
+ * @throws Exception if the mojo can not be found
+ */
+ public Mojo lookupMojoAndVerify(String mojoName, File pomFile) throws Exception {
+ Mojo mojo = lookupMojo(mojoName, pomFile);
+ assertNotNull(mojo);
+ return mojo;
+ }
+
+ /**
+ * Looks up the specified mojo by name, passing it the POM file that
+ * references it and a settings file that configures it, then verifying
+ * that the lookup was successful.
+ *
+ * @param mojoName the name of the mojo being tested
+ * @param pomFile the pom.xml file to be used during testing
+ * @param settingsFile the settings.xml file to be used during testing
+ * @return the Mojo object under test
+ * @throws Exception if the mojo can not be found
+ */
+ public Mojo lookupMojoVerifyAndApplySettings(String mojoName, File pomFile, File settingsFile) throws Exception {
+ Mojo mojo = lookupMojo(mojoName, pomFile);
+ assertNotNull(mojo);
+ setVariableValueToObject(mojo, "settings", getSettingsFile(settingsFile));
+ return mojo;
+ }
+
+}
View
180 src/test/java/org/jboss/as/plugin/common/AbstractServerConnectionTest.java
@@ -0,0 +1,180 @@
+/*
+ * File: AbstractServerConnectionTest.java
+ * Date: Nov 19, 2012
+ *
+ * Copyright (c) 2011 by Select Systems - All rights reserved.
+ *
+ * By: Select Systems
+ * 111 Heritage Way, Suite S
+ * Boalsburg, PA 16827
+ *
+ * Revision history:
+ *
+ *
+ */
@jamezp Collaborator
jamezp added a note

Same commit as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+package org.jboss.as.plugin.common;
+
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.io.File;
+
+import org.apache.maven.plugin.logging.Log;
+import org.jboss.as.plugin.deployment.Deploy;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+/**
+ * @author stevemoyer
+ *
+ */
+public class AbstractServerConnectionTest extends AbstractJbossMavenPluginMojoTestCase {
+
+ Log log;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ log = mock(Log.class);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Tests that if there is an <id> provided in the pom.xml file but no
+ * username and password, and there is no settings.xml file in the
+ * plugin's context, then the plugin falls back to prompting for
+ * credentials on the CLI.
+ */
+ @Test
+ public void testIdProvidedInPomButNoSettingsFile() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/id-provided-pom.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoAndVerify("deploy", pom);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ verify(log).debug(Deploy.DEBUG_MESSAGE_NO_SETTINGS_FILE);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+ /**
+ * Tests that if there is an <id> provided in the pom.xml file but no
+ * username and password, and there is a settings.xml file that doesn't
+ * match the id of the server, then the plugin falls back to prompting
+ * for credentials on the CLI.
+ */
+ @Test
+ public void testIdProvidedInPomButNoServerSection() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/id-provided-pom.xml");
+ File settings = getTestFileAndVerify("src/test/resources/unit/common/missing-id-settings.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoVerifyAndApplySettings("deploy", pom, settings);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ verify(log).debug(Deploy.DEBUG_MESSAGE_NO_SERVER_SECTION);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+ /**
+ * Tests that if there is an <id> provided in the pom.xml file but no
+ * username and password, and there is a settings.xml file that has a
+ * <server> section that matches the id, but there is no username and
+ * password specified, then the plugin falls back to prompting for
+ * credentials on the CLI.
+ */
+ @Test
+ public void testIdProvidedInPomButNoCredentials() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/id-provided-pom.xml");
+ File settings = getTestFileAndVerify("src/test/resources/unit/common/id-provided-settings.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoVerifyAndApplySettings("deploy", pom, settings);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ InOrder inOrder = inOrder(log);
+ inOrder.verify(log).debug(Deploy.DEBUG_MESSAGE_SETTINGS_HAS_ID);
+ inOrder.verify(log).debug(Deploy.DEBUG_MESSAGE_NO_CREDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+ /**
+ * Test that if credentials are provided in the pom.xml file, they are used
+ * regardless of whether an <id> element is also present.
+ */
+ @Test
+ public void testCredentialsProvidedInPom() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/credentials-provided-pom.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoAndVerify("deploy", pom);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ verify(log).debug(Deploy.DEBUG_MESSAGE_POM_HAS_CREDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+ /**
+ * Tests that if there is an <id> provided in the pom.xml file but no
+ * username and password, and there is a settings.xml file that has a
+ * <server> section that matches the id, and the section includes
+ * credentials, then they are used by the plugin.
+ */
+ @Test
+ public void testCredentialsProvidedInSettings() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/id-provided-pom.xml");
+ File settings = getTestFileAndVerify("src/test/resources/unit/common/credentials-provided-settings.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoVerifyAndApplySettings("deploy", pom, settings);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ InOrder inOrder = inOrder(log);
+ inOrder.verify(log).debug(Deploy.DEBUG_MESSAGE_SETTINGS_HAS_ID);
+ inOrder.verify(log).debug(Deploy.DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+ /**
+ * Test that if there is no <id> element and no credentials in the pom.xml
+ * file, then it falls back to prompting for them on the CLI.
+ */
+ @Test
+ public void testNoCredentialsOrIdInPom() {
+ File pom = getTestFileAndVerify("src/test/resources/unit/common/missing-id-pom.xml");
+ try {
+ Deploy mojo = (Deploy) lookupMojoAndVerify("deploy", pom);
+ mojo.setLog(log);
+ mojo.getCallbackHandler();
+ verify(log).debug(Deploy.DEBUG_MESSAGE_NO_ID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Couldn't find \"deploy\" mojo");
+ }
+ }
+
+}
View
22 src/test/resources/unit/common/credentials-provided-pom.xml
@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>testing</groupId>
+ <artifactId>testing</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <version>7.4.Final-SNAPSHOT</version>
+ <configuration>
+ <username>testuserinpom</username>
+ <password>testpassinpom</password>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
14 src/test/resources/unit/common/credentials-provided-settings.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
+ xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <servers>
+ <server>
+ <id>testid</id>
+ <username>testuserinsettings</username>
+ <password>testpassinsettings</password>
+ </server>
+ </servers>
+
+</settings>
View
21 src/test/resources/unit/common/id-provided-pom.xml
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>testing</groupId>
+ <artifactId>testing</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <version>7.4.Final-SNAPSHOT</version>
+ <configuration>
+ <id>testid</id>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
12 src/test/resources/unit/common/id-provided-settings.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
+ xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <servers>
+ <server>
+ <id>testid</id>
+ </server>
+ </servers>
+
+</settings>
View
20 src/test/resources/unit/common/missing-id-pom.xml
@@ -0,0 +1,20 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>testing</groupId>
+ <artifactId>testing</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <version>7.4.Final-SNAPSHOT</version>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
12 src/test/resources/unit/common/missing-id-settings.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
+ xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <servers>
+ <server>
+ <id>otherid</id>
+ </server>
+ </servers>
+
+</settings>
Something went wrong with that request. Please try again.