use of io.fabric8.kubernetes.api.model.ObjectMeta in project camel by apache.
the class KubernetesServiceAccountsProducerTest method createAndDeleteServiceAccount.
@Test
public void createAndDeleteServiceAccount() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:create", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNT_NAME, "test");
Map<String, String> labels = new HashMap<String, String>();
labels.put("this", "rocks");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNTS_LABELS, labels);
ServiceAccount s = new ServiceAccount();
s.setKind("ServiceAccount");
Map<String, String> mp = new HashMap<String, String>();
mp.put("username", Base64.encodeBase64String("pippo".getBytes()));
mp.put("password", Base64.encodeBase64String("password".getBytes()));
ObjectMeta meta = new ObjectMeta();
meta.setName("test");
s.setMetadata(meta);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNT, s);
}
});
ServiceAccount sec = ex.getOut().getBody(ServiceAccount.class);
assertEquals(sec.getMetadata().getName(), "test");
ex = template.request("direct:delete", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNT_NAME, "test");
}
});
boolean secDeleted = ex.getOut().getBody(Boolean.class);
assertTrue(secDeleted);
}
use of io.fabric8.kubernetes.api.model.ObjectMeta in project camel by apache.
the class KubernetesSecretsProducerTest method createAndDeleteSecret.
@Test
public void createAndDeleteSecret() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:create", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SECRET_NAME, "test");
Map<String, String> labels = new HashMap<String, String>();
labels.put("this", "rocks");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SECRETS_LABELS, labels);
Secret s = new Secret();
s.setKind("Secret");
Map<String, String> mp = new HashMap<String, String>();
mp.put("username", Base64.encodeBase64String("pippo".getBytes()));
mp.put("password", Base64.encodeBase64String("password".getBytes()));
s.setData(mp);
ObjectMeta meta = new ObjectMeta();
meta.setName("test");
s.setMetadata(meta);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SECRET, s);
}
});
Secret sec = ex.getOut().getBody(Secret.class);
assertEquals(sec.getMetadata().getName(), "test");
ex = template.request("direct:delete", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SECRET_NAME, "test");
}
});
boolean secDeleted = ex.getOut().getBody(Boolean.class);
assertTrue(secDeleted);
}
Aggregations