diff --git a/galasa-extensions-parent/dev.galasa.auth.couchdb/src/test/java/dev/galasa/auth/couchdb/TestCouchdbAuthStore.java b/galasa-extensions-parent/dev.galasa.auth.couchdb/src/test/java/dev/galasa/auth/couchdb/TestCouchdbAuthStore.java index 0ec9b21d..975c65d8 100644 --- a/galasa-extensions-parent/dev.galasa.auth.couchdb/src/test/java/dev/galasa/auth/couchdb/TestCouchdbAuthStore.java +++ b/galasa-extensions-parent/dev.galasa.auth.couchdb/src/test/java/dev/galasa/auth/couchdb/TestCouchdbAuthStore.java @@ -105,7 +105,7 @@ public void testGetTokensReturnsTokensWithFailingRequestReturnsError() throws Ex MockLogFactory logFactory = new MockLogFactory(); List interactions = new ArrayList(); - interactions.add(new GetAllTokenDocumentsInteraction("https://my-auth-store/galasa_tokens/_all_docs?include_docs=true&endkey=%22_%22", HttpStatus.SC_INTERNAL_SERVER_ERROR, null)); + interactions.add(new GetAllTokenDocumentsInteraction("https://my-auth-store/galasa_tokens/_all_docs", HttpStatus.SC_INTERNAL_SERVER_ERROR, null)); MockCloseableHttpClient mockHttpClient = new MockCloseableHttpClient(interactions); @@ -137,7 +137,7 @@ public void testGetTokensReturnsTokensFromCouchdbOK() throws Exception { CouchdbAuthToken mockToken = new CouchdbAuthToken("token1", "dex-client", "my test token", Instant.now(), new CouchdbUser("johndoe", "dex-user-id")); List interactions = new ArrayList(); - interactions.add(new GetAllTokenDocumentsInteraction("https://my-auth-store/galasa_tokens/_all_docs?include_docs=true&endkey=%22_%22", HttpStatus.SC_OK, mockAllDocsResponse)); + interactions.add(new GetAllTokenDocumentsInteraction("https://my-auth-store/galasa_tokens/_all_docs", HttpStatus.SC_OK, mockAllDocsResponse)); interactions.add(new GetTokenDocumentInteraction("https://my-auth-store/galasa_tokens/token1", HttpStatus.SC_OK, mockToken)); MockCloseableHttpClient mockHttpClient = new MockCloseableHttpClient(interactions); diff --git a/galasa-extensions-parent/dev.galasa.extensions.common/src/main/java/dev/galasa/extensions/common/couchdb/CouchdbStore.java b/galasa-extensions-parent/dev.galasa.extensions.common/src/main/java/dev/galasa/extensions/common/couchdb/CouchdbStore.java index a7d86b99..5f93876b 100644 --- a/galasa-extensions-parent/dev.galasa.extensions.common/src/main/java/dev/galasa/extensions/common/couchdb/CouchdbStore.java +++ b/galasa-extensions-parent/dev.galasa.extensions.common/src/main/java/dev/galasa/extensions/common/couchdb/CouchdbStore.java @@ -8,7 +8,6 @@ import static dev.galasa.extensions.common.Errors.*; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; @@ -20,8 +19,6 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.ParseException; @@ -55,8 +52,6 @@ public abstract class CouchdbStore { protected final URI storeUri; - private Log logger = LogFactory.getLog(this.getClass()); - protected HttpRequestFactory httpRequestFactory; protected CloseableHttpClient httpClient; protected GalasaGson gson = new GalasaGson(); @@ -117,9 +112,7 @@ protected PutPostResponse createDocument(String dbName, String jsonContent) thro */ protected List getAllDocsFromDatabase(String dbName) throws CouchdbException { - //The end key is "_" because, design docs start with "_design", - // this will exclude any design documents from being fetched from couchdb. - HttpGet getTokensDocs = httpRequestFactory.getHttpGetRequest(storeUri + "/" + dbName + "/_all_docs?include_docs=true&endkey=%22_%22"); + HttpGet getTokensDocs = httpRequestFactory.getHttpGetRequest(storeUri + "/" + dbName + "/_all_docs"); String responseEntity = sendHttpRequest(getTokensDocs, HttpStatus.SC_OK); ViewResponse allDocs = gson.fromJson(responseEntity, ViewResponse.class); @@ -129,6 +122,11 @@ protected List getAllDocsFromDatabase(String dbName) throws CouchdbExce String errorMessage = ERROR_FAILED_TO_GET_DOCUMENTS_FROM_DATABASE.getMessage(dbName); throw new CouchdbException(errorMessage); } + + // Filter out design documents from the results + viewRows = viewRows.stream() + .filter((row) -> !row.key.equals("_design/docs")) + .collect(Collectors.toList()); return viewRows; } @@ -144,7 +142,6 @@ protected List getAllDocsFromDatabase(String dbName) throws CouchdbExce * @return a list of rows corresponding to documents within the database * @throws CouchdbException if there was a problem accessing the * CouchDB store or its response - * @throws UnsupportedEncodingException A failure occurred. */ protected List getAllDocsByLoginId(String dbName, String loginId) throws CouchdbException {