KubeConfigUtils { public static String getUserToken(Config config, Context context) { AuthInfo authInfo = getUserAuthInfo(config, context); if (authInfo != null) { return authInfo.getToken(); } return null; } private  KubeConfigUtils(); static Config parseConfig(File file); static Config parseConfigFromString(String contents); static NamedContext getCurrentContext(Config config); static String getUserToken(Config config, Context context); static AuthInfo getUserAuthInfo(Config config, Context context); static Cluster getCluster(Config config, Context context); static int getNamedUserIndexFromConfig(Config config, String userName); static void persistKubeConfigIntoFile(Config kubeConfig, String kubeConfigPath);  }
@Test void testGetUserToken() { Config config = getTestKubeConfig(); Context context = Objects.requireNonNull(KubeConfigUtils.getCurrentContext(config)).getContext(); String token = KubeConfigUtils.getUserToken(config, context); assertEquals("test-token-2", token); }