Commit c2e8d576 authored by Greg Messner's avatar Greg Messner
Browse files

Added support for specifying scopes as an array (#338).

parent 6db9b9f9
package org.gitlab4j.api; package org.gitlab4j.api;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -63,6 +64,24 @@ public class ApplicationsApi extends AbstractApi { ...@@ -63,6 +64,24 @@ public class ApplicationsApi extends AbstractApi {
return (getApplications(getDefaultPerPage()).stream()); return (getApplications(getDefaultPerPage()).stream());
} }
/**
* Create an OAUTH Application.
*
* @param name the name for the OAUTH Application
* @param redirectUri the redirect URI for the OAUTH Application
* @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid, profile, email)
* @return the created Application instance
* @throws GitLabApiException if any exception occurs
*/
public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) throws GitLabApiException {
if (scopes == null || scopes.length == 0) {
throw new GitLabApiException("scopes cannot be null or empty");
}
return (createApplication(name, redirectUri, Arrays.asList(scopes)));
}
/** /**
* Create an OAUTH Application. * Create an OAUTH Application.
* *
......
...@@ -28,7 +28,6 @@ import static org.junit.Assert.assertNull; ...@@ -28,7 +28,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.Assume.assumeNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.gitlab4j.api.Constants.ApplicationScope; import org.gitlab4j.api.Constants.ApplicationScope;
...@@ -52,8 +51,8 @@ public class TestApplications extends AbstractIntegrationTest { ...@@ -52,8 +51,8 @@ public class TestApplications extends AbstractIntegrationTest {
private static final String TEST_APPLICATION_NAME = "Test Application for GitLab4J-API"; private static final String TEST_APPLICATION_NAME = "Test Application for GitLab4J-API";
private static final String TEST_APPLICATION_REDIRECT = "http://example.com/application"; private static final String TEST_APPLICATION_REDIRECT = "http://example.com/application";
private static final List<ApplicationScope> TEST_APPLICATION_SCOPES = private static final ApplicationScope[] TEST_APPLICATION_SCOPES =
Arrays.asList(ApplicationScope.SUDO, ApplicationScope.EMAIL); {ApplicationScope.SUDO, ApplicationScope.EMAIL};
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
......
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