Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
c2e8d576
Commit
c2e8d576
authored
May 04, 2019
by
Greg Messner
Browse files
Added support for specifying scopes as an array (#338).
parent
6db9b9f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ApplicationsApi.java
View file @
c2e8d576
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.
*
*
...
...
src/test/java/org/gitlab4j/api/TestApplications.java
View file @
c2e8d576
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment