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
35e83d8e
Commit
35e83d8e
authored
Jun 07, 2019
by
Philippe Vienne
Committed by
Greg Messner
Jun 07, 2019
Browse files
Corrected scopes for impersonation tokens (#374) (#375)
parent
18ff06d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/models/ImpersonationToken.java
View file @
35e83d8e
...
...
@@ -14,7 +14,7 @@ public class ImpersonationToken {
/** Enum to specify the scope of an ImpersonationToken. */
public
enum
Scope
{
API
,
READ_USER
;
API
,
READ_USER
,
READ_REPOSITORY
,
WRITE_REPOSITORY
,
READ_REGISTRY
,
SUDO
;
private
static
JacksonJsonEnumHelper
<
Scope
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
Scope
.
class
);
...
...
src/test/java/org/gitlab4j/api/TestUserApi.java
View file @
35e83d8e
...
...
@@ -214,13 +214,13 @@ public class TestUserApi extends AbstractIntegrationTest {
public
void
testCreateImpersonationToken
()
throws
GitLabApiException
,
ParseException
{
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
Scope
[]
scopes
=
{
Scope
.
API
,
Scope
.
READ_USER
};
Scope
[]
scopes
=
{
Scope
.
API
,
Scope
.
READ_USER
,
Scope
.
READ_REGISTRY
,
Scope
.
WRITE_REPOSITORY
,
Scope
.
SUDO
};
Date
expiresAt
=
ISO8601
.
toDate
(
"2018-01-01T00:00:00Z"
);
ImpersonationToken
token
=
gitLabApi
.
getUserApi
().
createImpersonationToken
(
user
.
getId
(),
TEST_IMPERSONATION_TOKEN_NAME
,
expiresAt
,
scopes
);
assertNotNull
(
token
);
assertNotNull
(
token
.
getId
());
assertEquals
(
TEST_IMPERSONATION_TOKEN_NAME
,
token
.
getName
());
assertEquals
(
2
,
token
.
getScopes
().
size
());
assertEquals
(
5
,
token
.
getScopes
().
size
());
gitLabApi
.
getUserApi
().
revokeImpersonationToken
(
user
.
getId
(),
token
.
getId
());
}
...
...
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