use of com.amazonaws.services.route53.model.ResourceRecordSet 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.ResourceRecordSet in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createListExpectedListResourceRecordSetsRequestAllFound.
public static Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> createListExpectedListResourceRecordSetsRequestAllFound(String stack) {
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> m = new HashMap<ListResourceRecordSetsRequest, ListResourceRecordSetsResult>();
List<String> svcPrefixes = Arrays.asList(Constants.PREFIX_PORTAL, Constants.PREFIX_REPO, Constants.PREFIX_WORKERS);
Map<String, String> map = getSvcCNAMEsProps(stack, svcPrefixes);
for (String svcPrefix : svcPrefixes) {
ListResourceRecordSetsRequest req = new ListResourceRecordSetsRequest().withStartRecordType(RRType.CNAME).withStartRecordName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withMaxItems("1");
ResourceRecord rr = new ResourceRecord().withValue(map.get(svcPrefix + ".service.environment.cname.prefix") + ".elasticbeanstalk.com");
ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ResourceRecordSet().withName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withTTL(300L).withType(RRType.CNAME).withResourceRecords(rr));
m.put(req, res);
}
return m;
}
use of com.amazonaws.services.route53.model.ResourceRecordSet in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testGetResourceRecordSetForRecordNameNoneFound.
@Test
public void testGetResourceRecordSetForRecordNameNoneFound() {
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.createListExpectedListResourceRecordSetsRequestNoneFound(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");
assertTrue(rrs == null);
}
}
use of com.amazonaws.services.route53.model.ResourceRecordSet in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createListExpectedListResourceRecordSetsRequestNoneFound.
public static Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> createListExpectedListResourceRecordSetsRequestNoneFound(String stack) {
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> m = new HashMap<ListResourceRecordSetsRequest, ListResourceRecordSetsResult>();
// For Auth and Portal, simulate 'not last' situation i.e. the next record is returned
List<String> svcPrefixes = Arrays.asList(Constants.PREFIX_PORTAL);
Map<String, String> map = getSvcCNAMEsProps(stack, svcPrefixes);
for (String svcPrefix : svcPrefixes) {
ListResourceRecordSetsRequest req = new ListResourceRecordSetsRequest().withStartRecordType(RRType.CNAME).withStartRecordName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withMaxItems("1");
ResourceRecord rr = new ResourceRecord().withValue(map.get(svcPrefix + ".service.environment.cname.prefix") + "2.elasticbeanstalk.com");
ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ResourceRecordSet().withName(map.get(svcPrefix + ".service.environment.subdomain.cname") + "2").withTTL(300L).withType(RRType.CNAME).withResourceRecords(rr));
m.put(req, res);
}
// For Repo and Workers, simulate 'last' situation i.e. no record is returned
svcPrefixes = Arrays.asList(Constants.PREFIX_REPO, Constants.PREFIX_WORKERS);
map = getSvcCNAMEsProps(stack, svcPrefixes);
for (String svcPrefix : svcPrefixes) {
ListResourceRecordSetsRequest req = new ListResourceRecordSetsRequest().withStartRecordType(RRType.CNAME).withStartRecordName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withMaxItems("1");
ResourceRecord rr = null;
ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ArrayList<ResourceRecordSet>());
m.put(req, res);
}
return m;
}
Aggregations