/** * Return a {@link ConcourseClientPreferences} handler that is sourced from * a concourse_client.prefs file in the current working directory. * * @return the handler */ public static ConcourseClientPreferences fromCurrentWorkingDirectory() { return from(Paths.get("concourse_client.prefs")); }
/** * Return a {@link ConcourseClientPreferences} handler that is sourced from * a concourse_client.prefs file in the user's home directory. * * @return the handler */ public static ConcourseClientPreferences fromUserHomeDirectory() { return from(Paths.get(System.getProperty("user.home") + File.separator + "concourse_client.prefs")); }
/** * Return a {@link ConcourseClientPreferences} wrapper that is backed by the * configuration information in {@code file}. * * @param file the absolute path to the preferences file (relative paths * will resolve to the user's home directory) * @return the preferences * @deprecated use {@link ConcourseServerPreferences#from(Path...)} instead */ @Deprecated public static ConcourseClientPreferences open(String file) { return from(Paths.get(file)); }
/** * Create a new connection using the information specified in the prefs * {@code file}. * * @param file the absolute path to the prefs file that contains the * information for the Concourse deployment (relative paths will * resolve to the user's home directory) * @return the handle */ public static Concourse connectWithPrefs(String file) { ConcourseClientPreferences prefs = ConcourseClientPreferences .from(Paths.get(file)); return connectWithPrefs(prefs); }
prefs); ConcourseClientPreferences ccp = ConcourseClientPreferences .from(Paths.get(FileOps.touch(prefs.toString()))); ccp.setPort(getClientPort()); ccp.setUsername("admin");
/** * Return a {@link ConnectionPool} that has no limit on the number of * connections it can manage to the Concourse instance at {@code host}: * {@code port} on behalf of the user identified by {@code username} and * {@code password}, but will try to use previously created connections * before establishing new ones for any request. * * @param prefs * @return the ConnectionPool */ public static ConnectionPool newCachedConnectionPool(String prefs) { ConcourseClientPreferences cp = ConcourseClientPreferences .from(Paths.get(prefs)); return new CachedConnectionPool(cp.getHost(), cp.getPort(), cp.getUsername(), new String(cp.getPassword()), cp.getEnvironment(), DEFAULT_POOL_SIZE); }
/** * Return a new {@link ConnectionPool} with a fixed number of * connections to the Concourse instance defined in the client {@code prefs} * on behalf of the user defined in the client {@code prefs}. * <p> * If all the connections from the pool are active, subsequent request * attempts will block until a connection is returned. * </p> * * @param prefs * @param poolSize * @return the ConnectionPool */ public static ConnectionPool newFixedConnectionPool(String prefs, int poolSize) { ConcourseClientPreferences cp = ConcourseClientPreferences .from(Paths.get(prefs)); return new FixedConnectionPool(cp.getHost(), cp.getPort(), cp.getUsername(), new String(cp.getPassword()), cp.getEnvironment(), poolSize); }
getLaunchDirectory()); ConcourseClientPreferences prefs = ConcourseClientPreferences .from(Paths.get(options.prefs)); options.username = prefs.getUsername(); options.password = new String(prefs.getPasswordExplicit());
@Test public void testGetPortWhenNotProvided() { ConcourseClientPreferences prefs = ConcourseClientPreferences .from(prefsPath); Assert.assertEquals(1717, prefs.getPort()); }
@Test public void testGetPortWhenWrittenAsString() { appendLine("port = \"1717\""); ConcourseClientPreferences prefs = ConcourseClientPreferences .from(prefsPath); Assert.assertEquals(1717, prefs.getPort()); }
System.getProperty("user.dir.real")); ConcourseClientPreferences prefs = ConcourseClientPreferences .from(Paths.get(opts.prefs)); opts.username = prefs.getUsername(); opts.password = new String(prefs.getPasswordExplicit());
@Test public void testGetPasswordExplicitWhenPresent() { appendLine("username = foo"); appendLine("host = localhost"); appendLine("password = foofoo"); ConcourseClientPreferences prefs = ConcourseClientPreferences .from(prefsPath); Assert.assertEquals("foofoo", new String(prefs.getPasswordExplicit())); }
@Test public void testGetPasswordExplicitWhenAbset() { appendLine("username = foo"); appendLine("host = localhost"); ConcourseClientPreferences prefs = ConcourseClientPreferences .from(prefsPath); Assert.assertEquals(ConcourseClientPreferences.NO_PASSWORD_DEFINED, prefs.getPasswordExplicit()); }