diff --git a/heroku-api-integration-tests/pom.xml b/heroku-api-integration-tests/pom.xml
index 5c22f1e..6abc7a2 100644
--- a/heroku-api-integration-tests/pom.xml
+++ b/heroku-api-integration-tests/pom.xml
@@ -5,7 +5,7 @@
heroku-api-parent
com.heroku.api
- 0.17-SNAPSHOT
+ 3.0.0-SNAPSHOT
4.0.0
@@ -66,11 +66,6 @@
heroku-json-jersey-client
${project.parent.version}
-
- com.heroku.api
- heroku-http-play_2.9.1
- ${project.parent.version}
-
@@ -101,18 +96,24 @@
commons-io
commons-io
- 1.4
+ 2.5
+ test
+
+
+ commons-codec
+ commons-codec
+ 1.10
test
- com.googlecode.jmockit
+ org.jmockit
jmockit
- 0.999.13
+ 1.28
- 11.0.1
+ 19.0
true
@@ -145,7 +146,6 @@
src/test/resources/testng-asynchttpclient.xml
src/test/resources/testng-httpclient-jackson.xml
src/test/resources/testng-httpclient-gson.xml
- src/test/resources/testng-play.xml
src/test/resources/testng-jersey-client.xml
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/PlayModule.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/PlayModule.java
deleted file mode 100644
index ddf6476..0000000
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/PlayModule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.heroku.api;
-
-import com.google.inject.Provides;
-import com.heroku.api.connection.PlayConnection;
-import com.heroku.api.connection.PlayWSConnection;
-import com.heroku.api.exception.RequestFailedException;
-
-import java.io.IOException;
-
-import static com.heroku.api.IntegrationTestConfig.CONFIG;
-
-public class PlayModule extends ConnectionTestModule {
-
- @Provides
- PlayConnection getConnectionImpl() throws IOException {
-
- try {
- IntegrationTestConfig.TestUser testUser = CONFIG.getDefaultUser();
- return PlayWSConnection.apply();
- } catch (RequestFailedException e) {
- System.out.println(e.getMessage());
- System.out.println(e.getStatusCode());
- System.out.println(e.getResponseBody());
- System.out.flush();
- e.printStackTrace();
- throw e;
- }
-
- }
-}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/connection/ConnectionIntegrationTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/connection/ConnectionIntegrationTest.java
deleted file mode 100644
index 399517d..0000000
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/connection/ConnectionIntegrationTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.heroku.api.connection;
-
-import com.google.inject.Inject;
-import com.heroku.api.HerokuAPI;
-import com.heroku.api.IntegrationTestConfig;
-import com.heroku.api.LoginVerification;
-import com.heroku.api.TestModuleFactory;
-import com.heroku.api.exception.RequestFailedException;
-import com.heroku.api.request.login.BasicAuthLogin;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Guice;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-
-import static com.heroku.api.IntegrationTestConfig.CONFIG;
-import static org.testng.Assert.assertEquals;
-
-/**
- * Integration tests for authenticating with the Heroku API.
- *
- * @author Naaman Newbold
- */
-@Guice(moduleFactory = TestModuleFactory.class)
-public class ConnectionIntegrationTest {
-
- @Inject
- Connection connection;
-
- @Test(groups = "integration")
- public void testObtainingAnApiKey() {
- IntegrationTestConfig.TestUser testUser = CONFIG.getDefaultUser();
- String apiKey = HerokuAPI.obtainApiKey(testUser.getUsername(), testUser.getPassword());
- assertEquals(apiKey, testUser.getApiKey());
- }
-
- @Test(groups = "integration")
- public void testValidUsernameAndPassword() throws IOException {
- IntegrationTestConfig.TestUser testUser = CONFIG.getDefaultUser();
- LoginVerification verification = connection.execute(new BasicAuthLogin(testUser.getUsername(), testUser.getPassword()), testUser.getApiKey());
- assertEquals(verification.getEmail(), testUser.getUsername());
- }
-
- @DataProvider
- public Object[][] invalidUsernamesAndPasswords() {
- return new Object[][]{
- {null, null},
- {"", ""},
- {"rodneyMullen@powell.peralta.bones.brigade", "fakeUsernameAndPassword"}
- };
- }
-
- @Test(groups = "integration",
- dataProvider = "invalidUsernamesAndPasswords",
- expectedExceptions = RequestFailedException.class)
- public void testInvalidUsernameAndPassword(String username, String password) throws IOException {
- connection.execute(new BasicAuthLogin(username, password), CONFIG.getDefaultUser().getApiKey());
- }
-}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/finagle/FinagleConnectionTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/finagle/FinagleConnectionTest.java
index 496f2da..83fd916 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/finagle/FinagleConnectionTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/finagle/FinagleConnectionTest.java
@@ -6,6 +6,7 @@
import com.heroku.api.User;
import com.heroku.api.connection.FinagleConnection;
import com.heroku.api.request.user.UserInfo;
+import com.twitter.util.Await;
import com.twitter.util.Duration;
import com.twitter.util.Future;
import org.testng.annotations.Guice;
@@ -28,7 +29,12 @@ public class FinagleConnectionTest {
@SuppressWarnings("unchecked")
public void asyncTests() {
Future jsonArrayResponseFuture = connection.executeAsync(new UserInfo(), apiKey);
- User user = (User) jsonArrayResponseFuture.get(Duration.fromTimeUnit(10L, TimeUnit.SECONDS)).get();
+ User user = null;
+ try {
+ user = Await.result(jsonArrayResponseFuture, Duration.fromTimeUnit(10L, TimeUnit.SECONDS));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
assertEquals(user.getEmail(), IntegrationTestConfig.CONFIG.getDefaultUser().getUsername());
}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/httpclient/HttpClientConnectionTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/httpclient/HttpClientConnectionTest.java
index db12067..0141f43 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/httpclient/HttpClientConnectionTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/httpclient/HttpClientConnectionTest.java
@@ -1,29 +1,12 @@
package com.heroku.api.httpclient;
import com.heroku.api.App;
-import com.heroku.api.Heroku;
import com.heroku.api.IntegrationTestConfig;
import com.heroku.api.connection.HttpClientConnection;
-import com.heroku.api.http.Http;
-import com.heroku.api.request.addon.AddonList;
import com.heroku.api.request.app.AppList;
-import mockit.Instantiation;
-import mockit.Mock;
-import mockit.MockClass;
-import mockit.Mockit;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.AbstractHttpClient;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HttpContext;
import org.testng.Assert;
import org.testng.annotations.Test;
-import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -43,66 +26,4 @@ public void asyncTests() throws ExecutionException, TimeoutException, Interrupte
List jsonArrayResponse = jsonArrayResponseFuture.get(10L, TimeUnit.SECONDS);
Assert.assertTrue(jsonArrayResponse != null);
}
-
- @Test(singleThreaded = true)
- public void userAgentShouldContainHerokuJarWithVersionNumber() {
- Mockit.setUpMock(AbstractHttpClient.class, new MockAbstractHttpClient(new MockHooks() {
- @Override
- public void beforeAssertions(HttpUriRequest request, HttpContext context) {
- final String expectedUserAgent = "heroku.jar/" + Heroku.JarProperties.getProperty("heroku.jar.version") + " httpclient";
- final String userAgentSent = Http.UserAgent.LATEST.getHeaderValue("httpclient");
- final String userAgentReceived = request.getHeaders(Http.UserAgent.LATEST.getHeaderName())[0].getValue();
- Assert.assertEquals(expectedUserAgent, userAgentSent);
- Assert.assertEquals(expectedUserAgent, userAgentReceived);
- }
- }));
- connection.execute(new AddonList(), apiKey);
- Mockit.tearDownMocks(AbstractHttpClient.class);
- }
-
- @Test(singleThreaded = true)
- public void cookiesShouldBeIgnored() {
- // make a call to ensure a Set-Cookie is sent back to the client
- Mockit.setUpMock(AbstractHttpClient.class, new MockAbstractHttpClient(new MockHooks() {
- @Override
- public void responseHook(BasicHttpResponse response) {
- response.setHeader("Set-Cookie", "foo=bar; path=/;");
- }
- }));
- connection.execute(new AddonList(), apiKey);
-
- Mockit.setUpMock(AbstractHttpClient.class, new MockAbstractHttpClient(new MockHooks() {
- @Override
- public void beforeAssertions(HttpUriRequest request, HttpContext context) {
- Assert.assertEquals(request.getHeaders("Cookie").length, 0, "Cookies should be ignored, but there are cookies present.");
- }
- }));
- // run this twice to ensure the set-cookie was sent from the first request
- connection.execute(new AddonList(), apiKey);
- Mockit.tearDownMocks(AbstractHttpClient.class);
- }
-
- @MockClass(realClass = AbstractHttpClient.class, instantiation = Instantiation.PerMockSetup)
- public static final class MockAbstractHttpClient {
- private final MockHooks hooks;
-
- public MockAbstractHttpClient(MockHooks hooks) {
- this.hooks = hooks;
- }
-
- @Mock
- public final HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException {
- hooks.beforeAssertions(request, context);
- BasicHttpResponse basicHttpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
- basicHttpResponse.setEntity(new StringEntity("[]"));
- hooks.responseHook(basicHttpResponse);
- return basicHttpResponse;
- }
-
- }
-
- public static abstract class MockHooks {
- public void beforeAssertions(HttpUriRequest request, HttpContext context) {}
- public void responseHook(BasicHttpResponse response) {}
- }
}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/parser/JsonParseTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/parser/JsonParseTest.java
index 16fd972..95ed298 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/parser/JsonParseTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/parser/JsonParseTest.java
@@ -1,6 +1,7 @@
package com.heroku.api.parser;
import com.heroku.api.App;
+import com.heroku.api.Heroku;
import com.heroku.api.exception.ParseException;
import com.heroku.api.request.app.AppInfo;
import org.testng.Assert;
@@ -12,7 +13,9 @@
import java.util.List;
import static com.heroku.api.parser.Json.parse;
+import static com.heroku.api.parser.Json.encode;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
/**
* @author mh
@@ -30,25 +33,24 @@ Object[][] getParsers() {
@Test(dataProvider = "getParsers")
public void testParseAppWithDomainList(Parser parser) throws UnsupportedEncodingException {
- String appListWithConfiguredDomain = "[{\"name\":\"app\",\"stack\":\"bamboo-ree-1.8.7\",\"slug_size\":2383872,\"requested_stack\":null,\"created_at\":\"2010/06/01 07:48:24 -0700\",\"web_url\":\"http://app.heroku.com/\",\"owner_email\":\"test@heroku.com\",\"create_status\":\"complete\",\"id\":200120," +
- "\"domain_name\":{\"created_at\":\"2010/06/03 19:25:08 -0700\",\"updated_at\":\"2010/06/03 19:25:08 -0700\",\"default\":null,\"domain\":\"herokuapp.com\",\"id\":1234,\"app_id\":200120,\"base_domain\":\"herokuapp.com\"}," +
- "\"repo_size\":630784,\"git_url\":\"git@heroku.com:dropphotos.git\",\"repo_migrate_status\":\"complete\",\"dynos\":1,\"workers\":0}" +
+ String appListWithConfiguredDomain = "[{\"name\":\"app\",\"stack\":{\"name\":\"cedar-14\"},\"slug_size\":2383872,\"requested_stack\":null,\"created_at\":\"2010/06/01 07:48:24 -0700\",\"web_url\":\"http://app.heroku.com/\",\"owner_email\":\"test@heroku.com\",\"create_status\":\"complete\",\"id\":200120," +
+ "\"domain_name\":{\"created_at\":\"2010/06/03 19:25:08 -0700\",\"updated_at\":\"2010/06/03 19:25:08 -0700\",\"status\":\"pending\",\"hostname\":\"herokuapp.com\",\"id\":1234}," +
+ "\"repo_size\":630784,\"git_url\":\"git@heroku.com:dropphotos.git\",\"maintenance\":\"false\"}" +
"]";
final List appList = parser.parse(appListWithConfiguredDomain.getBytes("UTF-8"), APP_LIST_TYPE);
Assert.assertEquals(appList.size(), 1);
final App app = appList.get(0);
Assert.assertEquals(app.getName(), "app");
- Assert.assertEquals(app.getDomain().getDomain(), "herokuapp.com");
- Assert.assertEquals(app.getDomain().getDefault(), null);
- Assert.assertEquals(app.getDynos(), 1);
+ Assert.assertEquals(app.getDomain().getHostname(), "herokuapp.com");
+ Assert.assertEquals(app.getDomain().getStatus(), "pending");
}
@Test(dataProvider = "getParsers")
public void testParseAppWithoutDomainList(Parser parser) throws UnsupportedEncodingException {
- String appListWithConfiguredDomain = "[{\"name\":\"app\",\"stack\":\"bamboo-ree-1.8.7\",\"slug_size\":2383872,\"requested_stack\":null,\"created_at\":\"2010/06/01 07:48:24 -0700\",\"web_url\":\"http://app.heroku.com/\",\"owner_email\":\"test@heroku.com\",\"create_status\":\"complete\",\"id\":200120," +
+ String appListWithConfiguredDomain = "[{\"name\":\"app\",\"stack\":{\"name\":\"cedar-14\"},\"slug_size\":2383872,\"requested_stack\":null,\"created_at\":\"2010/06/01 07:48:24 -0700\",\"web_url\":\"http://app.heroku.com/\",\"owner_email\":\"test@heroku.com\",\"create_status\":\"complete\",\"id\":200120," +
"\"domain_name\":null," +
- "\"repo_size\":630784,\"git_url\":\"git@heroku.com:dropphotos.git\",\"repo_migrate_status\":\"complete\",\"dynos\":1,\"workers\":0}" +
+ "\"repo_size\":630784,\"git_url\":\"git@heroku.com:dropphotos.git\",\"maintenance\":\"false\"}" +
"]";
final List appList = parser.parse(appListWithConfiguredDomain.getBytes("UTF-8"), APP_LIST_TYPE);
@@ -56,7 +58,6 @@ public void testParseAppWithoutDomainList(Parser parser) throws UnsupportedEncod
final App app = appList.get(0);
Assert.assertEquals(app.getName(), "app");
Assert.assertEquals(app.getDomain(), null);
- Assert.assertEquals(app.getDynos(), 1);
}
@Test(dataProvider = "getParsers")
@@ -88,6 +89,14 @@ public void invalidJSONShouldThrowParseException() {
parse("{{".getBytes(), AppInfo.class);
}
+ @Test
+ public void testEncodeApp() {
+ App a = new App().on(Heroku.Stack.Cedar14);
+ a.setMaintenance(true);
+ String json = encode(a);
+ assertTrue(json.indexOf("true") != 0);
+ }
+
public static class SubAppInfo extends AppInfo {
public SubAppInfo(String appName) {
super(appName);
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/play/PlayConnectionTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/play/PlayConnectionTest.java
deleted file mode 100644
index 65fd0ec..0000000
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/play/PlayConnectionTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.heroku.api.play;
-
-import com.google.inject.Inject;
-import com.heroku.api.IntegrationTestConfig;
-import com.heroku.api.Key;
-import com.heroku.api.PlayModule;
-import com.heroku.api.connection.PlayWSConnection;
-import com.heroku.api.request.key.KeyList;
-import org.testng.annotations.Guice;
-import org.testng.annotations.Test;
-import play.api.libs.concurrent.Promise;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.testng.Assert.assertNotNull;
-
-@Guice(modules = PlayModule.class)
-public class PlayConnectionTest {
-
- @Inject
- PlayWSConnection connection;
-
- String apiKey = IntegrationTestConfig.CONFIG.getDefaultUser().getApiKey();
-
-
- @Test
- @SuppressWarnings("unchecked")
- public void asyncTests() {
- Promise> jsonArrayResponseFuture = connection.executeAsync(new KeyList(), apiKey);
- List keys = jsonArrayResponseFuture.await(10L, TimeUnit.SECONDS).get();
- assertNotNull(keys);
- }
-
-}
-
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/BaseRequestIntegrationTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/BaseRequestIntegrationTest.java
index f23cc50..1359760 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/BaseRequestIntegrationTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/BaseRequestIntegrationTest.java
@@ -5,10 +5,10 @@
import com.heroku.api.connection.Connection;
import com.heroku.api.exception.RequestFailedException;
import com.heroku.api.http.Http;
-import com.heroku.api.request.app.AppClone;
import com.heroku.api.request.app.AppCreate;
import com.heroku.api.request.app.AppDestroy;
-import com.heroku.api.request.config.ConfigAdd;
+import com.heroku.api.request.config.ConfigUpdate;
+import com.heroku.api.request.key.KeyRemove;
import com.heroku.api.request.log.LogStreamResponse;
import com.heroku.api.request.sharing.CollabList;
import com.heroku.api.response.Unit;
@@ -17,7 +17,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -51,13 +53,6 @@ public Object[][] newApp() {
return new Object[][]{{createApp()}};
}
- @DataProvider(parallel = true)
- public Object[][] clonedApp() {
- return new Object[][]{{
- connection.execute(new AppClone("template-java-spring-hibernate", new App()), apiKey)
- }};
- }
-
public App getApp() {
if (apps.size() > 0)
return apps.get(0);
@@ -67,11 +62,19 @@ public App getApp() {
public App createApp() {
System.out.println("Creating app...");
- App app = connection.execute(new AppCreate(new App().on(Heroku.Stack.Cedar)), apiKey);
+ App app = connection.execute(new AppCreate(new App().on(Heroku.Stack.Cedar14)), apiKey);
apps.add(app);
System.out.format("%s created\n", app.getName());
return app;
}
+
+ @BeforeSuite
+ public void deleteExistingKeys() throws InterruptedException {
+ for (IntegrationTestConfig.TestUser tu : IntegrationTestConfig.CONFIG.getTestUsers()) {
+ HerokuAPI api = new HerokuAPI(tu.getApiKey());
+ deleteKeys(api.listKeys());
+ }
+ }
@BeforeSuite
public void deleteExistingApps() throws InterruptedException {
@@ -109,16 +112,45 @@ void deleteApps(List appsToDelete) throws InterruptedException {
executorService.execute(new Runnable() {
@Override
public void run() {
- System.out.format("Deleting %s\n", res.getName());
+ System.out.format("Deleting app %s\n", res.getName());
deleteApp(res.getName());
- System.out.format("Deleted %s\n", res.getName());
+ System.out.format("Deleted app %s\n", res.getName());
+ }
+ });
+ }
+ // await termination of all the threads to complete app deletion.
+ executorService.shutdown();
+ executorService.awaitTermination(300L, TimeUnit.SECONDS);
+ System.out.format("Deleted apps in %dms\n", (System.currentTimeMillis() - start));
+ }
+
+ void deleteKeys(List keysToDelete) throws InterruptedException {
+ long start = System.currentTimeMillis();
+ ExecutorService executorService = Executors.newFixedThreadPool(10);
+ for (final Key res : keysToDelete) {
+ executorService.execute(new Runnable() {
+ @Override
+ public void run() {
+ System.out.format("Deleting key %s\n", res.getComment());
+ deleteKey(res.getId());
+ System.out.format("Deleted key %s\n", res.getComment());
}
});
}
// await termination of all the threads to complete app deletion.
executorService.shutdown();
executorService.awaitTermination(300L, TimeUnit.SECONDS);
- System.out.format("Deleted apps in %dms", (System.currentTimeMillis() - start));
+ System.out.format("Deleted keys in %dms\n", (System.currentTimeMillis() - start));
+ }
+
+ public void deleteKey(String sshkey) {
+ try {
+ connection.execute(new KeyRemove(sshkey), apiKey);
+ } catch (RequestFailedException e) {
+ if (e.getStatusCode() != Http.Status.FORBIDDEN.statusCode) {
+ throw e;
+ }
+ }
}
public void deleteApp(String appName) {
@@ -136,20 +168,12 @@ protected void addConfig(App app, String... nameValuePairs) {
throw new RuntimeException("Config must have an equal number of name and value pairs.");
}
- StringBuffer jsonConfig = new StringBuffer();
- jsonConfig = jsonConfig.append("{");
- String separator = "";
-
+ Map configVars = new HashMap();
for (int i = 0; i < nameValuePairs.length; i = i + 2) {
- jsonConfig = jsonConfig.append(
- String.format("%s\"%s\":\"%s\"", separator, nameValuePairs[i], nameValuePairs[i + 1])
- );
- separator = ",";
+ configVars.put(nameValuePairs[i], nameValuePairs[i + 1]);
}
- jsonConfig = jsonConfig.append("}");
-
- Request req = new ConfigAdd(app.getName(), new String(jsonConfig));
+ Request req = new ConfigUpdate(app.getName(), configVars);
connection.execute(req, apiKey);
}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/KeysRequestIntegrationTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/KeysRequestIntegrationTest.java
index cdb4c7b..67e28ac 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/KeysRequestIntegrationTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/KeysRequestIntegrationTest.java
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.UUID;
-import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/**
@@ -46,7 +45,6 @@ public class KeysRequestIntegrationTest {
@AfterClass(alwaysRun = true)
public void deleteAllKeys() {
-// connection.execute(new KeysRemoveAll(), API_KEY);
// delete keys individually to avoid race conditions.
// if a key is not found, ignore the failure because it's already been deleted.
for (String k : pubKeyComments) {
@@ -115,7 +113,7 @@ public boolean keyIsPresent(String comment) {
public boolean keyIsPresent(String comment, List keyList) {
for (Key k : keyList) {
- if (k.getContents().contains(comment)) {
+ if (comment.equals(k.getComment())) {
return true;
}
}
diff --git a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/RequestIntegrationTest.java b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/RequestIntegrationTest.java
index a734384..0d91ccf 100644
--- a/heroku-api-integration-tests/src/test/java/com/heroku/api/request/RequestIntegrationTest.java
+++ b/heroku-api-integration-tests/src/test/java/com/heroku/api/request/RequestIntegrationTest.java
@@ -5,7 +5,6 @@
import com.heroku.api.connection.HttpClientConnection;
import com.heroku.api.exception.RequestFailedException;
import com.heroku.api.http.Http;
-import com.heroku.api.http.HttpUtil;
import com.heroku.api.request.addon.AddonInstall;
import com.heroku.api.request.addon.AddonList;
import com.heroku.api.request.addon.AppAddonsList;
@@ -14,26 +13,17 @@
import com.heroku.api.request.app.AppInfo;
import com.heroku.api.request.app.AppList;
import com.heroku.api.request.config.ConfigList;
-import com.heroku.api.request.config.ConfigRemove;
import com.heroku.api.request.domain.DomainAdd;
import com.heroku.api.request.domain.DomainList;
import com.heroku.api.request.domain.DomainRemove;
import com.heroku.api.request.log.Log;
-import com.heroku.api.request.log.LogStreamResponse;
-import com.heroku.api.request.ps.ProcessList;
-import com.heroku.api.request.ps.Restart;
-import com.heroku.api.request.ps.Scale;
-import com.heroku.api.request.ps.Stop;
import com.heroku.api.request.releases.ListReleases;
import com.heroku.api.request.releases.ReleaseInfo;
import com.heroku.api.request.releases.Rollback;
-import com.heroku.api.request.run.Run;
-import com.heroku.api.request.run.RunResponse;
import com.heroku.api.request.sharing.CollabList;
import com.heroku.api.request.sharing.SharingAdd;
import com.heroku.api.request.sharing.SharingRemove;
import com.heroku.api.request.stack.StackList;
-import com.heroku.api.request.stack.StackMigrate;
import com.heroku.api.request.user.UserInfo;
import com.heroku.api.response.Unit;
import org.testng.ITestResult;
@@ -46,7 +36,7 @@
import java.util.List;
import java.util.Map;
-import static com.heroku.api.Heroku.Stack.Cedar;
+import static com.heroku.api.Heroku.Stack.Cedar14;
import static com.heroku.api.IntegrationTestConfig.CONFIG;
import static com.heroku.api.http.Http.Status.*;
import static org.testng.Assert.*;
@@ -80,62 +70,16 @@ public void testAppExistsCommand(App app) throws IOException {
@Test(retryAnalyzer = InternalServerErrorAnalyzer.class)
public void testCreateAppCommand() throws IOException {
- AppCreate cmd = new AppCreate(new App().on(Cedar));
+ AppCreate cmd = new AppCreate(new App().on(Cedar14));
App response = connection.execute(cmd, apiKey);
assertNotNull(response.getId());
- assertEquals(response.getStack(), Cedar);
- assertEquals(response.getCreateStatus(), "complete");
+ assertEquals(response.getStack(), Cedar14);
+ assertFalse(response.isMaintenance());
assertNull(response.getBuildpackProvidedDescription());
deleteApp(response.getName());
}
- @Test(retryAnalyzer = GeneralRetryAnalyzer.class)
- public void testCloneAppCommand() throws IOException {
- final HerokuAPI api = new HerokuAPI(connection, apiKey);
- final String templateName = "template-java-spring-hibernate";
-
- App response = api.cloneApp(templateName);
-
- assertNotNull(response.getId());
- assertNotSame(templateName, response.getName());
- assertEquals(response.getStack(), Cedar);
- assertEquals(response.getCreateStatus(), "complete");
- assertEquals(response.getBuildpackProvidedDescription(), "Java");
- deleteApp(response.getName());
- }
-
- @Test(retryAnalyzer = GeneralRetryAnalyzer.class)
- public void testCloneAppCommand_WithRequestedName() throws IOException {
- final HerokuAPI api = new HerokuAPI(connection, apiKey);
- final String templateName = "template-java-spring-hibernate";
- final String requestedAppName = "test" + System.currentTimeMillis();
-
- App response = api.cloneApp(templateName, new App().named(requestedAppName));
-
- assertNotNull(response.getId());
- assertNotSame(templateName, response.getName());
- assertEquals(response.getName(), requestedAppName);
- assertEquals(response.getStack(), Cedar);
- assertEquals(response.getCreateStatus(), "complete");
- assertEquals(response.getBuildpackProvidedDescription(), "Java");
- deleteApp(response.getName());
- }
-
- @Test(retryAnalyzer = InternalServerErrorAnalyzer.class)
- public void testCloneAppCommand_WithNonTemplateApp() throws IOException {
- final HerokuAPI api = new HerokuAPI(connection, apiKey);
- final String nonTemplateApp = "java";
-
- try {
- api.cloneApp(nonTemplateApp);
- fail();
- } catch (RequestFailedException e) {
- assertTrue(e.getMessage().contains("Failed to clone app"));
- assertEquals(e.getStatusCode(), FORBIDDEN.statusCode);
- }
- }
-
@DataProvider
public Object[][] logParameters() {
final String appName = getApp().getName();
@@ -170,7 +114,7 @@ public void testListAppsCommand(App app) throws IOException {
// don't use the app dataprovider because it'll try to delete an already deleted app
@Test(retryAnalyzer = InternalServerErrorAnalyzer.class)
public void testDestroyAppCommand() throws IOException {
- AppDestroy cmd = new AppDestroy(new HerokuAPI(connection, apiKey).createApp(new App().on(Cedar)).getName());
+ AppDestroy cmd = new AppDestroy(new HerokuAPI(connection, apiKey).createApp(new App().on(Cedar14)).getName());
Unit response = connection.execute(cmd, apiKey);
assertNotNull(response);
}
@@ -193,14 +137,16 @@ public void testSharingAddWithBrandNewUserCommand(App app) throws IOException {
public void testSharingTransferCommand() throws IOException {
assertNotSame(IntegrationTestConfig.CONFIG.getDefaultUser().getUsername(), sharingUser.getUsername());
HerokuAPI api = new HerokuAPI(IntegrationTestConfig.CONFIG.getDefaultUser().getApiKey());
- App app = api.createApp(new App().on(Cedar));
+ App app = api.createApp(new App().on(Cedar14));
api.addCollaborator(app.getName(), sharingUser.getUsername());
api.transferApp(app.getName(), sharingUser.getUsername());
HerokuAPI sharedUserAPI = new HerokuAPI(sharingUser.getApiKey());
App transferredApp = sharedUserAPI.getApp(app.getName());
- assertEquals(transferredApp.getOwnerEmail(), sharingUser.getUsername());
- sharedUserAPI.destroyApp(transferredApp.getName());
+
+ // TODO The transfer must be accepted first
+ //assertEquals(transferredApp.getOwnerEmail(), sharingUser.getUsername());
+ //sharedUserAPI.destroyApp(transferredApp.getName());
}
@Test(dataProvider = "newApp", invocationCount = 5, successPercentage = 20, retryAnalyzer = InternalServerErrorAnalyzer.class)
@@ -225,7 +171,7 @@ public void testConfigAddCommand() throws IOException {
config.put("FOO", "bar");
config.put("BAR", "foo");
config.put("회사", "히로쿠");
- api.addConfig(app.getName(), config);
+ api.updateConfig(app.getName(), config);
Map retrievedConfig = api.listConfig(app.getName());
assertEquals(retrievedConfig.get("FOO"), "bar");
assertEquals(retrievedConfig.get("BAR"), "foo");
@@ -241,47 +187,6 @@ public void testConfigCommand(App app) {
assertEquals(response.get("FOO"), "BAR");
}
- @Test(dataProvider = "newApp", retryAnalyzer = InternalServerErrorAnalyzer.class)
- public void testConfigRemoveCommand(App app) {
- addConfig(app, "회사", "히로쿠", "JOHN", "DOE");
- Request