Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
car-roll committed Sep 12, 2023
1 parent 4c0aada commit 832b776
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/test/java/hudson/plugins/ec2/AmazonEC2CloudTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.mockito.Mockito;
import org.xml.sax.SAXException;

import hudson.util.VersionNumber;
import jenkins.model.Jenkins;

import java.io.IOException;
Expand Down Expand Up @@ -74,8 +73,8 @@ public void setUp() throws Exception {

@Test
public void testConfigRoundtrip() throws Exception {
r.submit(getConfigForm());
r.assertEqualBeans(cloud, r.jenkins.clouds.get(AmazonEC2Cloud.class), "cloudName,region,useInstanceProfileForCredentials,privateKey,instanceCap,roleArn,roleSessionName");
r.submit(getConfigForm(cloud));
r.assertEqualBeans(cloud, r.jenkins.clouds.get(AmazonEC2Cloud.class), "region,useInstanceProfileForCredentials,privateKey,instanceCap,roleArn,roleSessionName");
}

@Test
Expand All @@ -88,14 +87,14 @@ public void testAmazonEC2FactoryGetInstance() throws Exception {

@Test
public void testSshKeysCredentialsIdRemainsUnchangedAfterUpdatingOtherFields() throws Exception {
HtmlForm form = getConfigForm();
HtmlTextInput input = form.getInputByName("_.cloudName");
HtmlForm form = getConfigForm(cloud);
HtmlTextInput input = form.getInputByName("_.roleSessionName");

input.setText("test-cloud-2");
input.setText("updatedSessionName");
r.submit(form);
AmazonEC2Cloud actual = r.jenkins.clouds.get(AmazonEC2Cloud.class);
assertEquals("test-cloud-2", actual.getCloudName());
r.assertEqualBeans(cloud, actual, "region,useInstanceProfileForCredentials,sshKeysCredentialsId,instanceCap,roleArn,roleSessionName");
assertEquals("updatedSessionName", actual.getRoleSessionName());
r.assertEqualBeans(cloud, actual, "region,useInstanceProfileForCredentials,sshKeysCredentialsId,instanceCap,roleArn");
}

@Test
Expand Down Expand Up @@ -162,8 +161,8 @@ public void testCustomSshCredentialTypes() throws IOException {
assertThat(actual.resolvePrivateKey(), notNullValue());
}

private HtmlForm getConfigForm() throws IOException, SAXException {
return r.createWebClient().goTo("configureClouds").getFormByName("config");
private HtmlForm getConfigForm(AmazonEC2Cloud cloud) throws IOException, SAXException {
return r.createWebClient().goTo(cloud.getUrl() + "configure").getFormByName("config");
}

}

0 comments on commit 832b776

Please sign in to comment.