-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for trustStore and trustStorePassword #34
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package brooklyn.networking.vclouddirector; | ||
|
||
import static org.testng.Assert.assertNotNull; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.List; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import com.vmware.vcloud.api.rest.schema.NatRuleType; | ||
|
||
import brooklyn.entity.BrooklynAppLiveTestSupport; | ||
import brooklyn.location.jclouds.JcloudsLocation; | ||
import brooklyn.util.exceptions.Exceptions; | ||
|
||
/** | ||
* Tests assume that brooklyn.properties have been configured with location specs for vCHS and TAI. | ||
* For example: | ||
* | ||
* <pre> | ||
* brooklyn.location.named.canopy-vCHS=jclouds:vcloud-director:https://p5v1-vcd.vchs.vmware.com/api | ||
* brooklyn.location.named.canopy-vCHS.identity=jo.blogs@cloudsoftcorp.com@M123456789-1234 | ||
* brooklyn.location.named.canopy-vCHS.credential=pa55w0rd | ||
* brooklyn.location.named.canopy-vCHS.advancednetworking.vcloud.network.id=041e176a-befc-4b28-89e2-3c5343ff4d12 | ||
* brooklyn.location.named.canopy-vCHS.advancednetworking.vcloud.network.publicip=23.92.230.21 | ||
* brooklyn.location.named.canopy-vCHS.trustStorePassword=changeit | ||
* | ||
* brooklyn.location.named.canopy-TAI=jclouds:vcloud-director:https://svdc.it-solutions.atos.net/api | ||
* brooklyn.location.named.canopy-TAI.identity=jo.blogs@myvorg_01 | ||
* brooklyn.location.named.canopy-TAI.credential=pa55w0rd | ||
* brooklyn.location.named.canopy-TAI.trustStore=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/security/cacerts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added more info in the javadoc |
||
* brooklyn.location.named.canopy-TAI.trustStorePassword=changeit | ||
* </pre> | ||
* | ||
* Notice `trustStore` will be automatically inferred as in canopy-vCHS location, but it can be overridden by using | ||
* `trustStore` as in canopy-TAI location | ||
*/ | ||
public class SecureNatServiceLiveTest extends BrooklynAppLiveTestSupport { | ||
|
||
// | ||
private static final String LOCATION_SPEC = "canopy-vCHS"; | ||
|
||
private static final String LOCATION_TAI_SPEC = "canopy-TAI"; | ||
|
||
protected JcloudsLocation loc; | ||
|
||
@BeforeMethod(alwaysRun=true) | ||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
loc = (JcloudsLocation) mgmt.getLocationRegistry().resolve(LOCATION_SPEC); | ||
} | ||
|
||
// TAI (as at 2014-12-16) is running vcloud-director version 5.1 | ||
@Test(groups="Live") | ||
public void testGetNatRulesAtTai() throws Exception { | ||
loc = (JcloudsLocation) mgmt.getLocationRegistry().resolve(LOCATION_TAI_SPEC); | ||
NatService service = newServiceBuilder(loc).build(); | ||
List<NatRuleType> rules = service.getNatRules(service.getEdgeGateway()); | ||
assertNotNull(rules); | ||
} | ||
|
||
// Simple test that just checks no errors (e.g. can authenticate etc) | ||
@Test(groups="Live") | ||
public void testGetNatRules() throws Exception { | ||
NatService service = newServiceBuilder(loc).build(); | ||
List<NatRuleType> rules = service.getNatRules(service.getEdgeGateway()); | ||
assertNotNull(rules); | ||
} | ||
|
||
private NatService.Builder newServiceBuilder(JcloudsLocation loc) { | ||
String endpoint = loc.getEndpoint(); | ||
|
||
// jclouds endpoint has suffix "/api"; but VMware SDK wants it without "api" | ||
String convertedUri; | ||
try { | ||
URI uri = URI.create(endpoint); | ||
convertedUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null).toString(); | ||
} catch (URISyntaxException e) { | ||
throw Exceptions.propagate(e); | ||
} | ||
|
||
String trustStore = (String) loc.getAllConfigBag().getStringKey("trustStore"); // if null, it will use default trustore | ||
String trustStorePassword = (String) loc.getAllConfigBag().getStringKey("trustStorePassword"); | ||
assertNotNull(trustStorePassword, "trustStorePassword not set on location " + loc); | ||
|
||
return NatService.builder() | ||
.identity(loc.getIdentity()) | ||
.credential(loc.getCredential()) | ||
.endpoint(convertedUri) | ||
.trustStore(trustStore) | ||
.trustStorePassword(trustStorePassword); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file
Copyright VMware, Inc
, as it says at the top of the file?!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started from a VMware class, but I've completely re-written that. Removing the copyright