I hereby claim:
- I am tommysitu on github.
- I am tommystarling (https://keybase.io/tommystarling) on keybase.
- I have a public key ASAAdTNIUXyW3INytjJfmpDcPsALXrBgB_i1u2lAnQIgYwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
@Test | |
public void shouldUpgradeAccountIfPaymentIsSuccessful() throws Exception { | |
hoverflyRule.simulate(dsl( | |
service(matches("*.payment.*")) | |
.post("/v1/charges") | |
.body(equalsToJson(json(new Charge("id", 20000, GBP)))) | |
.willReturn(success()), | |
service(matches("*.account.*")) | |
.put("/v1/account/id") | |
.body(equalsToJson("{\"type\":\"premium\"}")) |
@Test | |
public void shouldUpgradeAccountIfPaymentIsSuccessful() throws Exception { | |
when(paymentService.process(new Charge("id", 20000, GBP))) | |
.thenReturn(new ChargeStatus(SUCCESSFUL)); | |
serviceUnderTest.upgrade("id"); | |
verify(accountService).update(eq("id"), eq(PREMIUM)); | |
} |
@Component | |
public class K8sGateway { | |
private final RestTemplate restTemplate; | |
private final K8sConfig k8sConfig; | |
@Autowired | |
public K8sGateway(RestTemplate k8sRestTemplate, K8sConfig k8sConfig) { | |
this.restTemplate = k8sRestTemplate; | |
this.k8sConfig = k8sConfig; |
@Bean | |
public RestTemplate k8sRestTemplate(K8sConfig k8sConfig) { | |
RestTemplate restTemplate = new RestTemplate(); | |
Path caCertFile = Paths.get(k8sConfig.getCaCertPath()); | |
if (Files.exists(caCertFile) && Files.isRegularFile(caCertFile)) { | |
SSLContext sslContext = SslUtils.createSslContextFromCertFile(caCertFile); | |
CloseableHttpClient httpsClient = HttpClients.custom().useSystemProperties().setSSLContext(sslContext).build(); |
@Test | |
public void shouldBeAbleToCallHttpsServerUsingSelfSignedCertificate() throws Exception { | |
// Given | |
K8sService expected = new K8sService(new Metadata("hoverfly", "some-uuid", "default"), new Spec()); | |
hoverflyRule.simulate(dsl( | |
service("https://kubernetes") | |
.get("/api/v1/namespaces/default/services/hoverfly") | |
.willReturn(success(HttpBodyConverter.json(expected))) | |
)); |
@ClassRule | |
public static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode( | |
configs() | |
.sslCertificatePath("ssl/ca.crt") | |
.sslKeyPath("ssl/ca.key")); |