use of com.amazonaws.services.route53.model.HostedZone in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53Setup method getHostedZone.
public HostedZone getHostedZone(String hostedZoneDomainName) {
HostedZone zone = null;
if (!hostedZoneDomainName.endsWith(".")) {
hostedZoneDomainName = hostedZoneDomainName + ".";
}
ListHostedZonesResult res = route53Client.listHostedZones();
List<HostedZone> l = res.getHostedZones();
// Should only be one hz in our case, no need to handle getIstruncated() etc.
for (HostedZone hz : l) {
if (hz.getName().equals(hostedZoneDomainName)) {
zone = hz;
break;
}
}
if (zone == null) {
throw new IllegalArgumentException("Hosted zone for domain " + hostedZoneDomainName + " could not be found.");
}
return zone;
}
use of com.amazonaws.services.route53.model.HostedZone in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testGetResourceRecordSetForRecordNameAllFound.
@Test
public void testGetResourceRecordSetForRecordNameAllFound() {
String stack = "stack";
String hostedZoneDomainName = stack + ".sagebase.org.";
ListHostedZonesResult res = new ListHostedZonesResult();
List<HostedZone> expectedHostedZones = new ArrayList<HostedZone>();
HostedZone hz = new HostedZone().withName(hostedZoneDomainName);
expectedHostedZones.add(hz);
hz = new HostedZone().withName("anotherzone.sagebase.org");
expectedHostedZones.add(hz);
res.setHostedZones(expectedHostedZones);
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> expectedResourceRecordSetsResults = TestHelper.createListExpectedListResourceRecordSetsRequestAllFound(stack);
when(mockClient.listHostedZones()).thenReturn(res);
// Args for getResourceRecordSetForRecordName().listResourceRecordSets()
for (ListResourceRecordSetsRequest req : expectedResourceRecordSetsResults.keySet()) {
when(mockClient.listResourceRecordSets(req)).thenReturn(expectedResourceRecordSetsResults.get(req));
}
Route53Setup r53Setup = new Route53Setup(factory, config, resources);
for (String svcPrefix : Arrays.asList(Constants.PREFIX_PORTAL, Constants.PREFIX_REPO, Constants.PREFIX_WORKERS)) {
ResourceRecordSet rrs = r53Setup.getResourceRecordSetForRecordName(svcPrefix + ".stack.inst.r53.sagebase.org");
assertFalse(rrs == null);
assertEquals(rrs.getName(), svcPrefix + ".stack.inst.r53.sagebase.org");
assertEquals(rrs.getResourceRecords().get(0).getValue(), svcPrefix + "-stack-inst-sagebase-org.elasticbeanstalk.com");
}
}
use of com.amazonaws.services.route53.model.HostedZone in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testGetHostedZoneExistentZone.
// @After
// public void tearDown() {
// }
//
@Test
public void testGetHostedZoneExistentZone() {
String stack = "stack";
String hostedZoneDomainName = stack + ".sagebase.org.";
ListHostedZonesResult res = new ListHostedZonesResult();
List<HostedZone> expectedHostedZones = new ArrayList<HostedZone>();
HostedZone hz = new HostedZone().withName(hostedZoneDomainName);
expectedHostedZones.add(hz);
hz = new HostedZone().withName("anotherzone.sagebase.org.");
expectedHostedZones.add(hz);
res.setHostedZones(expectedHostedZones);
when(mockClient.listHostedZones()).thenReturn(res);
Route53Setup r53Setup = new Route53Setup(factory, config, resources);
HostedZone z = r53Setup.getHostedZone(stack + ".sagebase.org");
assertEquals(hostedZoneDomainName, z.getName());
}
use of com.amazonaws.services.route53.model.HostedZone in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testSetupResourcesAllFound.
@Ignore
@Test
public void testSetupResourcesAllFound() throws Exception {
String stack = "stack";
String hostedZoneDomainName = stack + ".sagebase.org.";
ListHostedZonesResult res = new ListHostedZonesResult();
List<HostedZone> expectedHostedZones = new ArrayList<HostedZone>();
HostedZone hz = new HostedZone().withName(hostedZoneDomainName);
expectedHostedZones.add(hz);
hz = new HostedZone().withName("anotherzone.sagebase.org.");
expectedHostedZones.add(hz);
res.setHostedZones(expectedHostedZones);
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> expectedResourceRecordSetsResults = TestHelper.createListExpectedListResourceRecordSetsRequestAllFound(stack);
when(mockClient.listHostedZones()).thenReturn(res);
// Args for getResourceRecordSetForRecordName().listResourceRecordSets()
for (ListResourceRecordSetsRequest req : expectedResourceRecordSetsResults.keySet()) {
when(mockClient.listResourceRecordSets(req)).thenReturn(expectedResourceRecordSetsResults.get(req));
}
ChangeInfo expectedChangeInfo = new ChangeInfo().withId("changeInfoId").withStatus(ChangeStatus.INSYNC);
ChangeResourceRecordSetsResult expectedChangeResourceRecordSetsResult = new ChangeResourceRecordSetsResult().withChangeInfo(expectedChangeInfo);
when(mockClient.changeResourceRecordSets(any(ChangeResourceRecordSetsRequest.class))).thenReturn(expectedChangeResourceRecordSetsResult);
Route53Setup r53Setup = new Route53Setup(factory, config, resources);
}
use of com.amazonaws.services.route53.model.HostedZone in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testGetHostedZoneNonExistentZone.
@Test(expected = IllegalArgumentException.class)
public void testGetHostedZoneNonExistentZone() {
String hostedZoneDomainName = "r53.sagebase.org.";
ListHostedZonesResult res = new ListHostedZonesResult();
List<HostedZone> expectedHostedZones = new ArrayList<HostedZone>();
HostedZone hz = new HostedZone().withName("sone1.org.");
expectedHostedZones.add(hz);
hz = new HostedZone().withName("zone2.org.");
expectedHostedZones.add(hz);
res.setHostedZones(expectedHostedZones);
when(mockClient.listHostedZones()).thenReturn(res);
Route53Setup r53Setup = new Route53Setup(factory, config, resources);
HostedZone z = r53Setup.getHostedZone("r53.sagebase.org");
}
Aggregations