Commit 0189b872 authored by Greg Messner's avatar Greg Messner
Browse files

Added testing of sub groups.

parent 85631bbb
......@@ -28,6 +28,7 @@ public class AbstractIntegrationTest implements PropertyConstants {
protected static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY);
protected static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY, TEST_LOGIN_USERNAME);
protected static final String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
protected static final String TEST_SUB_GROUP = HelperUtils.getProperty(SUB_GROUP_KEY);
protected static class BaseTestResources {
protected GitLabApi gitLabApi;
......
......@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.gitlab4j.api.models.Group;
......@@ -42,6 +43,7 @@ public class IntegrationTestSuite implements PropertyConstants {
private static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY);
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
private static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY);
private static final String TEST_SUB_GROUP = HelperUtils.getProperty(SUB_GROUP_KEY);
protected static final String TEST_PRIVATE_TOKEN_NAME = "GitLab4J Test Private Token - " + HelperUtils.getRandomInt(1000);
protected static String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
......@@ -283,5 +285,19 @@ public class IntegrationTestSuite implements PropertyConstants {
gitLabApi.getRepositoryFileApi().updateFile(testProject, repoFile, "master", "Updated contents");
System.out.format("Updated %s repository file in %s%n", repoFile.getFilePath(), TEST_GROUP_PROJECT_NAME);
}
// Create a subgroup
List<Group> subGroups = gitLabApi.getGroupApi().getSubGroups(TEST_GROUP, null, null, TEST_SUB_GROUP, null, null, null, null);
if (subGroups.isEmpty()) {
Group groupSettings = new Group()
.withName(TEST_SUB_GROUP)
.withPath(TEST_SUB_GROUP)
.withDescription("Test Sub-Group")
.withVisibility(Visibility.PUBLIC)
.withRequestAccessEnabled(true)
.withParentId(testGroup.getId());
Group testSubGroup = gitLabApi.getGroupApi().addGroup(groupSettings);
System.out.format("Created %s sub-group (%s)%n", testSubGroup.getName(), testSubGroup.getPath());
}
}
}
......@@ -23,8 +23,9 @@ public interface PropertyConstants {
public static final String PROXY_PASSWORD_KEY = "TEST_PROXY_PASSWORD";
public static final String PROXY_URI_KEY = "TEST_PROXY_URI";
public static final String PROXY_USERNAME_KEY = "TEST_PROXY_USERNAME";
public static final String TEST_REQUEST_ACCESS_USERNAME_KEY = "TEST_REQUEST_ACCESS_USERNAME";
public static final String SUB_GROUP_KEY = "TEST_SUB_GROUP";
public static final String SUDO_AS_USERNAME_KEY = "TEST_SUDO_AS_USERNAME";
public static final String TEST_REQUEST_ACCESS_USERNAME_KEY = "TEST_REQUEST_ACCESS_USERNAME";
public static final String USERNAME_KEY = "TEST_USERNAME";
public static final String XFER_NAMESPACE_KEY = "TEST_XFER_NAMESPACE";
}
......@@ -90,6 +90,13 @@ public class TestNamespaceApi extends AbstractIntegrationTest {
assertEquals(TEST_NAMESPACE, namespaces.get(0).getName());
}
@Test
public void testFindSubgroupNamespaces() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces(TEST_SUB_GROUP);
assertNotNull(namespaces);
assertEquals(TEST_SUB_GROUP, namespaces.get(0).getName());
}
@Test
public void testFindNamespacesByPage() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces(TEST_NAMESPACE, 1, 10);
......
......@@ -36,11 +36,12 @@ TEST_BLOCK_USERNAME=user1
TEST_XFER_NAMESPACE=user1
TEST_REQUEST_ACCESS_USERNAME=user1
# This specifies the group, a project owned by the specified group, and a username to
# This specifies the group, a project owned by the specified group, a username, and a sub-group to
# test group membership functionality
TEST_GROUP=test-group
TEST_GROUP_PROJECT=test-group-project
TEST_GROUP_MEMBER_USERNAME=user1
TEST_SUB_GROUP=subgroup
# OPTIONAL: To test using GitLab4J-API with a proxy, set the following properties
TEST_PROXY_URI=
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment