io.fabric8.kubernetes.client.Config Java Examples
The following examples show how to use
io.fabric8.kubernetes.client.Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetNamespaceStepExecution.java From kubernetes-pipeline-plugin with Apache License 2.0 | 6 votes |
@Override protected String run() throws Exception { String namespace = null; try { FilePath workspace = getContext().get(FilePath.class); namespace = workspace.child(Config.KUBERNETES_NAMESPACE_PATH).readToString(); if (Utils.isNotNullOrEmpty(namespace)) { return namespace; } } catch (Throwable t) { //it might be executed outside of a `node` block in which case, we want to ignore. } NamespaceAction namespaceAction = new NamespaceAction(getContext().get(Run.class)); namespace = namespaceAction.getNamespace(); if (Utils.isNotNullOrEmpty(namespace)) { return namespace; } return step.getFallbackNamespace(); }
Example #2
Source File: NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(OkHttpClient client, Config config, String namespace, String explicitNamespace, Boolean fromServer, Boolean deletingExisting, List<Visitor> visitors, Object item, long gracePeriodSeconds, DeletionPropagation propagationPolicy, Boolean cascading, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier) { super(client, config); this.fallbackNamespace = namespace; this.explicitNamespace = explicitNamespace; this.fromServer = fromServer; this.deletingExisting = deletingExisting; this.visitors = visitors != null ? new ArrayList<>(visitors) : new ArrayList<Visitor>(); this.item = item; this.handler = handlerOf(item); this.cascading = cascading; this.watchRetryInitialBackoffMillis = watchRetryInitialBackoffMillis; this.watchRetryBackoffMultiplier = watchRetryBackoffMultiplier; if (handler == null) { throw new KubernetesClientException("No handler found for object:" + item); } this.gracePeriodSeconds = gracePeriodSeconds; this.propagationPolicy = propagationPolicy; this.visitors.add(new ChangeNamespace(explicitNamespace, fallbackNamespace)); }
Example #3
Source File: ConfigMapsWithoutProfilesTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-without-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #4
Source File: KubernetesMockServerTestResource.java From quarkus with Apache License 2.0 | 6 votes |
@Override public Map<String, String> start() { final Map<String, String> systemProps = new HashMap<>(); systemProps.put(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); systemProps.put(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); systemProps.put(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); systemProps.put(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); mockServer = new KubernetesMockServer(useHttps()); mockServer.init(); try (NamespacedKubernetesClient client = mockServer.createClient()) { systemProps.put(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, client.getConfiguration().getMasterUrl()); } configureMockServer(mockServer); return systemProps; }
Example #5
Source File: ConfigMapsWithProfilesTests.java From spring-cloud-kubernetes with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap<String, String> data = new HashMap<>(); data.put("application.yml", readResourceFile("application-with-profiles.yaml")); server.expect().withPath("/api/v1/namespaces/test/configmaps/" + APPLICATION_NAME) .andReturn(200, new ConfigMapBuilder().withNewMetadata() .withName(APPLICATION_NAME).endMetadata().addToData(data).build()) .always(); }
Example #6
Source File: KubeDiscovery.java From vxms with Apache License 2.0 | 6 votes |
/** * Resolves discovery annotation in AbstractVerticles * * @param service the service where to resolve the annotations * @param kubeConfig the kubernetes config */ public static void resolveBeanAnnotations(AbstractVerticle service, Config kubeConfig) { final JsonObject env = service.config(); final List<Field> serviceNameFields = findServiceFields(service); if (!env.getBoolean("kube.offline", false)) { // online final DefaultKubernetesClient client = new DefaultKubernetesClient(kubeConfig); // TODO be aware of OpenShiftClient if (!serviceNameFields.isEmpty()) { findServiceEntryAndSetValue(service, serviceNameFields, env, client); } else { // TODO check and handle Endpoints & Pods } } else { // resolve properties offline if (!serviceNameFields.isEmpty()) { resolveServicesOffline(service, serviceNameFields, env); } else { // TODO check and handle Endpoints & Pods } } }
Example #7
Source File: SSLUtils.java From kubernetes-client with Apache License 2.0 | 6 votes |
public static boolean isHttpsAvailable(Config config) { Config sslConfig = new ConfigBuilder(config) .withMasterUrl(Config.HTTPS_PROTOCOL_PREFIX + config.getMasterUrl()) .withRequestTimeout(1000) .withConnectionTimeout(1000) .build(); OkHttpClient client = HttpClientUtils.createHttpClient(config); try { Request request = new Request.Builder().get().url(sslConfig.getMasterUrl()) .build(); Response response = client.newCall(request).execute(); try (ResponseBody body = response.body()) { return response.isSuccessful(); } } catch (Throwable t) { LOG.warn("SSL handshake failed. Falling back to insecure connection."); } finally { if (client != null && client.connectionPool() != null) { client.connectionPool().evictAll(); } } return false; }
Example #8
Source File: NewProjectExamples.java From kubernetes-client with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws InterruptedException { String master = "https://localhost:8443/"; if (args.length == 1) { master = args[0]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); try (OpenShiftClient client = new DefaultOpenShiftClient(config)) { ProjectRequest request = null; try { request = client.projectrequests().createNew().withNewMetadata().withName("thisisatest").endMetadata().withDescription("Jimmi").withDisplayName("Jimmi").done(); } finally { if (request != null) { client.projects().withName(request.getMetadata().getName()).delete(); } } } }
Example #9
Source File: ClusterConfigurationTest.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Test public void should_load_configuration_from_properties() { // Given final Properties properties = new Properties(); properties.put("jkube.username", "user name"); properties.put("jkube.password", "the pa$$w*rd"); properties.put("jkube.masterUrl", "https://example.com"); properties.put("jkube.corner-case", "corner"); properties.put("manufactur8.jkube.corner-case", "cased"); // When final Config config = ClusterConfiguration.from(properties).build().getConfig(); // Then assertThat(config.getUsername()).isEqualTo("user name"); assertThat(config.getPassword()).isEqualTo("the pa$$w*rd"); assertThat(config.getMasterUrl()).isEqualTo("https://example.com/"); }
Example #10
Source File: ConfigMapExample.java From kubernetes-client with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws InterruptedException { Config config = new ConfigBuilder().build(); KubernetesClient client = new DefaultKubernetesClient(config); String namespace = null; if (args.length > 0) { namespace = args[0]; } if (namespace == null) { namespace = client.getNamespace(); } if (namespace == null) { namespace = "default"; } String name = "cheese"; try { Resource<ConfigMap, DoneableConfigMap> configMapResource = client.configMaps().inNamespace(namespace).withName(name); ConfigMap configMap = configMapResource.createOrReplace(new ConfigMapBuilder(). withNewMetadata().withName(name).endMetadata(). addToData("foo", "" + new Date()). addToData("bar", "beer"). build()); log("Upserted ConfigMap at " + configMap.getMetadata().getSelfLink() + " data " + configMap.getData()); } finally { client.close(); } }
Example #11
Source File: MultipleConfigMapsTests.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); createConfigmap(server, "s1", "defnamespace", new HashMap<String, String>() { { put("bean.common-message", "c1"); put("bean.message1", "m1"); } }); createConfigmap(server, "defname", "s2", new HashMap<String, String>() { { put("bean.common-message", "c2"); put("bean.message2", "m2"); } }); createConfigmap(server, "othername", "othernamespace", new HashMap<String, String>() { { put("bean.common-message", "c3"); put("bean.message3", "m3"); } }); }
Example #12
Source File: CertUtilsTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Disabled @Test public void testLoadingDodgyKubeConfig() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, InvalidKeySpecException { System.setProperty("kubeconfig", "/tmp/ceposta.kubeconfig"); KubernetesClient client = new DefaultKubernetesClient(); Config config = client.getConfiguration(); KeyStore ts = CertUtils.createTrustStore(config.getCaCertData(), null, null, "changeit"); KeyStore ks = CertUtils.createKeyStore(config.getClientCertData(), null, config.getClientKeyData(), null, "RSA", "changeit", null, "changeit"); }
Example #13
Source File: ElasticsearchIntegrationTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
public final void startES(final Settings settings, int timeOutSec, int assertNodes) throws Exception { // setup api server final String masterUrl = apiServer.getMockServer().url("/").toString(); System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, masterUrl); System.setProperty("kubernetes.trust.certificates", "true"); System.setProperty("kubernetes.keystore.file", keyStore); System.setProperty("kubernetes.keystore.passphrase", password); System.setProperty("kubernetes.truststore.file", keyStore); System.setProperty("kubernetes.truststore.passphrase", password); System.setProperty("sg.display_lic_none", "true"); FileUtils.deleteDirectory(new File("data")); esNode1 = new PluginAwareNode( settings, OpenShiftElasticSearchPlugin.class); log.debug("--------- Starting ES Node ----------"); esNode1.start(); log.debug("--------- Waiting for the cluster to go green ----------"); waitForCluster(ClusterHealthStatus.GREEN, TimeValue.timeValueSeconds(timeOutSec), esNode1.client(), assertNodes); seedSearchGuardAcls(); // seed kibana index like kibana XContentBuilder contentBuilder = XContentFactory.jsonBuilder() .startObject() .field("defaultIndex",".all") .endObject(); givenDocumentIsIndexed(".kibana", "config", ConfigurationSettings.DEFAULT_KIBANA_VERSION, contentBuilder); // create ops user to avoid issue: // https://github.com/fabric8io/openshift-elasticsearch-plugin/issues/106 givenDocumentIsIndexed(".operations.1970.01.01", "test", "0", "operation0"); }
Example #14
Source File: HttpServerTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void testListWithTrustCerts() { server.expect().withPath("/api/v1/namespaces/test/pods").andReturn(200, new PodListBuilder().build()).once(); //We override the config to create a client that doesn't trust all certs. Config override = new ConfigBuilder(server.getClient().getConfiguration()).build(); KubernetesClient client = new DefaultKubernetesClient(override); client.pods().list(); }
Example #15
Source File: ServiceMonitorHandler.java From dekorate with Apache License 2.0 | 5 votes |
@Override public Boolean delete(OkHttpClient client, Config config, String namespace, Boolean cascading, ServiceMonitor item) { if (cascading) { return new ServiceMonitorOperationsImpl(client, config).withItem(item).cascading(cascading).delete(); } else { return new ServiceMonitorOperationsImpl(client, config).withItem(item).inNamespace(namespace).delete(item); } }
Example #16
Source File: ClusterConfigurationTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Test public void should_load_configuration_from_empty_array() { // When final Config config = ClusterConfiguration.from().build().getConfig(); // Then assertThat(config).isNotNull(); }
Example #17
Source File: DefaultTektonClient.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override public NamespacedTektonClient inNamespace(String namespace) { Config updated = new ConfigBuilder(getConfiguration()) .withNamespace(namespace) .build(); return new DefaultTektonClient(getHttpClient(), updated); }
Example #18
Source File: Environment.java From enmasse with Apache License 2.0 | 5 votes |
private Environment() { if (Strings.isNullOrEmpty(token) || Strings.isNullOrEmpty(url)) { Config config = Config.autoConfigure(System.getenv() .getOrDefault("TEST_CLUSTER_CONTEXT", null)); token = config.getOauthToken(); url = config.getMasterUrl(); } String debugFormat = "{}:{}"; LOGGER.info(debugFormat, INSTALL_TYPE, installType.name()); if (installType == EnmasseInstallType.OLM) { LOGGER.info(debugFormat, OLM_INSTALL_TYPE, olmInstallType.name()); } if (Strings.isNullOrEmpty(this.kubernetesDomain)) { if (url.equals("https://api.crc.testing:6443")) { this.kubernetesDomain = "apps-crc.testing"; } else if (url.startsWith("https://api")) { //is api url for openshift4 try { this.kubernetesDomain = new URL(url).getHost().replace("api", "apps"); } catch (Exception ex) { throw new RuntimeException(ex); } } else { this.kubernetesDomain = "nip.io"; } } LOGGER.info(debugFormat, "CONFIG", config); LOGGER.info(debugFormat, "SCALE_CONFIG", scaleConfig); values.forEach(v -> LOGGER.info(debugFormat, v.getKey(), v.getValue())); }
Example #19
Source File: TektonMockServer.java From kubernetes-client with Apache License 2.0 | 5 votes |
public TektonClient createTekton() { Config config = new ConfigBuilder() .withMasterUrl(url("/")) .withNamespace("test") .withTrustCerts(true) .withTlsVersions(TLS_1_0) .build(); return new DefaultTektonClient(createHttpClientForMockServer(config), config); }
Example #20
Source File: HealthIndicatorTest.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); }
Example #21
Source File: SharedInformerFactory.java From kubernetes-client with Apache License 2.0 | 5 votes |
/** * Constructor with thread pool specified. * * @param threadPool specified thread pool. * @param okHttpClient OkHttp client * @param configuration configuration for client */ public SharedInformerFactory(ExecutorService threadPool, OkHttpClient okHttpClient, Config configuration) { super(new OperationContext().withOkhttpClient(okHttpClient).withConfig(configuration)); this.informerExecutor = threadPool; this.informers = new HashMap<>(); this.startedInformers = new HashMap<>(); this.baseOperation = this.newInstance(context); this.eventListeners = new ConcurrentLinkedQueue<>(); }
Example #22
Source File: ExecExample.java From kubernetes-client with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws InterruptedException { if (args.length < 1) { System.out.println("Usage: podName [master] [namespace]"); return; } String podName = args[0]; String namespace = "default"; String master = "https://localhost:8443/"; if (args.length > 1) { master = args[1]; } if (args.length > 2) { namespace = args[2]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config); ExecWatch watch = client.pods().inNamespace(namespace).withName(podName) .readingInput(System.in) .writingOutput(System.out) .writingError(System.err) .withTTY() .usingListener(new SimpleListener()) .exec()){ Thread.sleep(10 * 1000); } }
Example #23
Source File: InfoContributorTest.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); }
Example #24
Source File: OpenShiftClientFactory.java From che with Eclipse Public License 2.0 | 5 votes |
public UnclosableOpenShiftClient(OkHttpClient httpClient, Config config) { super( httpClient, config instanceof OpenShiftConfig ? (OpenShiftConfig) config : new OpenShiftConfig(config)); }
Example #25
Source File: HealthIndicatorTest.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() { mockClient = server.getClient(); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); }
Example #26
Source File: ServiceCatalogMockServer.java From kubernetes-client with Apache License 2.0 | 5 votes |
public ServiceCatalogClient createServiceCatalog() { Config config = new ConfigBuilder() .withMasterUrl(url("/")) .withNamespace("test") .withTrustCerts(true) .withTlsVersions(TLS_1_0) .build(); return new DefaultServiceCatalogClient(config); }
Example #27
Source File: ImageStreamTagExample.java From kubernetes-client with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws InterruptedException { String namespace = "myproject"; String master = "CLUSTER_URL"; Config config = new ConfigBuilder().withMasterUrl(master).build(); OpenShiftClient client = new DefaultOpenShiftClient(config); try { ImageStreamTag istag = new ImageStreamTagBuilder().withNewMetadata().withName("bar1:1.0.12").endMetadata() .withNewTag().withNewFrom().withKind("DockerImage").withName("openshift/wildfly-81-centos7:latest").endFrom().endTag() .build(); log("Created istag", client.imageStreamTags().inNamespace(namespace).create(istag)); Thread.sleep(30000); }finally { log("ImageStreamTags are :"); log(client.imageStreamTags().inNamespace(namespace).withName("bar1:1.0.12").get().toString()); log("ImageStreamTags using list are :"); log(client.imageStreamTags().list().getItems().get(0).toString()); log("Deleted istag",client.imageStreamTags().withName("bar1:1.0.12").delete()); client.close(); } }
Example #28
Source File: K8sManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Sets the openshift client( This supprots both the Openshift and Kubernetes) */ private void setClient() { if (masterURL != null && saToken != null && namespace != null) { Config config = new ConfigBuilder().withMasterUrl(masterURL).withOauthToken(saToken).withNamespace(namespace) //Get keystore password to connect with local clusters .withClientKeyPassphrase(System.getProperty(CLIENT_KEY_PASSPHRASE)).build(); this.openShiftClient = new DefaultOpenShiftClient(config); } else { log.error("Failed to make the connection to the cluster"); } }
Example #29
Source File: Fabric8OpenShiftClientFactoryTest.java From rh-che with Eclipse Public License 2.0 | 5 votes |
@Test public void returnsConfigUsingCurrentSubjectWhenSubjectsRegistryDoesNotContainTheCorrespondingOneAndNoRuntimeState() throws Exception { when(subjectsRegistry.getSubject(OWNER_USER_ID)).thenThrow(new NotFoundException("test error")); Config config = factory.buildConfig(defaultConfig, WS_ID); assertEquals(config, expectedConfig); verify(environmentProvider).getWorkspacesOpenshiftConfig(eq(currentSubject)); }
Example #30
Source File: Fabric8OpenShiftClientFactoryTest.java From rh-che with Eclipse Public License 2.0 | 5 votes |
@Test public void returnsConfigUsingGuessedSubjectWhenSubjectsRegistryDoesNotContainTheCorrespondingOneAndUsingCheSaAndRuntimeStateExists() throws Exception { when(subjectsRegistry.getSubject(OWNER_USER_ID)).thenThrow(new NotFoundException("test error")); when(runtimeStateCache.get(any())).thenReturn(Optional.of(runtimeState)); when(runtimeState.getNamespace()).thenReturn(GUESSED_NAMESPACE); when(cheServiceAccountTokenToggle.useCheServiceAccountToken(OWNER_USER_ID)).thenReturn(true); Config config = factory.buildConfig(defaultConfig, WS_ID); assertEquals(config, expectedConfig); verify(environmentProvider) .getWorkspacesOpenshiftConfig(eq(new GuessedSubject(OWNER_USER_ID, GUESSED_NAMESPACE))); }