diff --git a/mano-vim-k8s/src/test/java/com/ubiqube/etsi/mano/vim/k8s/OsClusterServiceTest.java b/mano-vim-k8s/src/test/java/com/ubiqube/etsi/mano/vim/k8s/OsClusterServiceTest.java index a375c16..2f244a6 100644 --- a/mano-vim-k8s/src/test/java/com/ubiqube/etsi/mano/vim/k8s/OsClusterServiceTest.java +++ b/mano-vim-k8s/src/test/java/com/ubiqube/etsi/mano/vim/k8s/OsClusterServiceTest.java @@ -17,10 +17,12 @@ package com.ubiqube.etsi.mano.vim.k8s; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Base64; @@ -171,6 +173,32 @@ void testBadGetClusterInfo() { assertTrue(res.isEmpty()); } + @Test + void testFromKubeConfigBad() { + final OsClusterService srv = createService(); + try (InputStream is = getClass().getResourceAsStream("/kubeConfig"); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + is.transferTo(baos); + final byte[] arr = baos.toByteArray(); + assertThrows(VimException.class, () -> srv.fromKubeConfig("badCtx", arr)); + } catch (final IOException e) { + throw new VimException(e); + } + } + + @Test + void testFromKubeConfigGood() { + final OsClusterService srv = createService(); + try (InputStream is = getClass().getResourceAsStream("/kubeConfig"); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + is.transferTo(baos); + final K8s res = srv.fromKubeConfig("capi-quickstart-admin@capi-quickstart", baos.toByteArray()); + assertNotNull(res); + } catch (final IOException e) { + throw new VimException(e); + } + } + private static String toBase64(final String r) { return Base64.getEncoder().encodeToString(r.getBytes()); }