forked from awslabs/ec2-spot-jenkins-plugin
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artem Stasiuk
committed
Jan 21, 2020
1 parent
b77ce1b
commit 26ec7ff
Showing
6 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/com/amazon/jenkins/ec2fleet/AWSUtilsIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.amazon.jenkins.ec2fleet; | ||
|
||
import com.amazonaws.ClientConfiguration; | ||
import hudson.ProxyConfiguration; | ||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class AWSUtilsIntegrationTest { | ||
|
||
private static final int PROXY_PORT = 8888; | ||
private static final String PROXY_HOST = "localhost"; | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
public void getClientConfiguration_when_no_proxy_returns_configuration_without_proxy() { | ||
j.jenkins.proxy = null; | ||
ClientConfiguration clientConfiguration = AWSUtils.getClientConfiguration("somehost"); | ||
Assert.assertNull(clientConfiguration.getProxyHost()); | ||
} | ||
|
||
@Test | ||
public void getClientConfiguration_when_proxy_returns_configuration_with_proxy() { | ||
j.jenkins.proxy = new ProxyConfiguration(PROXY_HOST, PROXY_PORT); | ||
ClientConfiguration clientConfiguration = AWSUtils.getClientConfiguration("somehost"); | ||
Assert.assertEquals(PROXY_HOST, clientConfiguration.getProxyHost()); | ||
Assert.assertEquals(PROXY_PORT, clientConfiguration.getProxyPort()); | ||
Assert.assertNull(clientConfiguration.getProxyUsername()); | ||
Assert.assertNull(clientConfiguration.getProxyPassword()); | ||
} | ||
|
||
@Test | ||
public void getClientConfiguration_when_proxy_with_credentials_returns_configuration_with_proxy() { | ||
j.jenkins.proxy = new ProxyConfiguration(PROXY_HOST, PROXY_PORT, "a", "b"); | ||
ClientConfiguration clientConfiguration = AWSUtils.getClientConfiguration("somehost"); | ||
Assert.assertEquals(PROXY_HOST, clientConfiguration.getProxyHost()); | ||
Assert.assertEquals(PROXY_PORT, clientConfiguration.getProxyPort()); | ||
Assert.assertEquals("a", clientConfiguration.getProxyUsername()); | ||
Assert.assertEquals("b", clientConfiguration.getProxyPassword()); | ||
} | ||
|
||
@Test | ||
public void getClientConfiguration_when_endpoint_is_invalid_url_use_it_as_is() { | ||
j.jenkins.proxy = new ProxyConfiguration(PROXY_HOST, PROXY_PORT); | ||
ClientConfiguration clientConfiguration = AWSUtils.getClientConfiguration("rumba"); | ||
Assert.assertEquals(PROXY_HOST, clientConfiguration.getProxyHost()); | ||
Assert.assertEquals(PROXY_PORT, clientConfiguration.getProxyPort()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters