Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
b47733e2
Commit
b47733e2
authored
4 years ago
by
Greg Messner
Browse files
Options
Download
Email Patches
Plain Diff
Fixed tests related to SSH keys
parent
c20d0d36
main
5.0.x
5.0.x.jdk17
6.x
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/org/gitlab4j/api/TestUserApi.java
+15
-10
src/test/java/org/gitlab4j/api/TestUserApi.java
with
15 additions
and
10 deletions
+15
-10
src/test/java/org/gitlab4j/api/TestUserApi.java
+
15
-
10
View file @
b47733e2
...
@@ -57,12 +57,12 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -57,12 +57,12 @@ public class TestUserApi extends AbstractIntegrationTest {
private
static
final
String
TEST_SUDO_AS_USERNAME
=
HelperUtils
.
getProperty
(
SUDO_AS_USERNAME_KEY
);
private
static
final
String
TEST_SUDO_AS_USERNAME
=
HelperUtils
.
getProperty
(
SUDO_AS_USERNAME_KEY
);
private
static
final
String
TEST_IMPERSONATION_TOKEN_NAME
=
"token1"
;
private
static
final
String
TEST_IMPERSONATION_TOKEN_NAME
=
"token1"
;
private
static
final
String
TEST_SSH_KEY
=
private
static
final
String
TEST_SSH_KEY
=
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC
vbkmGRaANy2nmLrfYa9LkjMqjs9twYZXQKUPK18j
"
+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC
3rWzl/oPAD+Em2iGTmR81HcYZsopvnKp7jelI4XS91fT1NjCRrGsxf5Mw/
"
+
"BWmNgnAm818IikxjfFit3Gqnnh9zdNzlzUYs2osmfdHwRLeFY3hKVR6WckGYVroQuV5ArUA4+oME+IIQ2soCv/
"
+
"KnmtBjhk+kQjkhIrnsBDcs6DZWtNcHJtyWJZrYsfxMTqWCaQv+OTRwVboqS2pmPcbK3gizUd5GCLFTKbg4OMpdywTwi6NAPwQ
"
+
"vNWfEmp2N1mpBTwi2mIYKurCKv6UpIpGK9D+ezNk5H0waVTK8EvZ/ey69Nu7C7RsbTYeyi5WY/jaUG5JbsEeKY
"
+
"rtn3xwiVnGGCfBSyRFppcYP81otALctrlAW57V5+bQwFIJteJ+NWe1UmPxrqQ0N/a+dEEoJHzwX8RtVSkULafrRw8avn6Zp2x
"
+
"IW/2DIlUts7gcB2hzXtt7r7+6DLx82Vb+S2jPZu2JQaB4zfgS7LQgzHUy1aAAgUUpuAbvWzuGHKO0p551Ru4qi"
+
"1OlD2aIEMQWvepNTRW6UDMSmWFc61ycy1pF5sCT5rij+b/fN4qCEvQs6R7GmCzaaZzbWuAqaxLRdITm/WUxdG6rjh"
;
"tyXN2+OUVXcYAsuIIdGGB0wLvTDgiOOSZWnSE+sg6XX user@example.com"
;
private
static
final
String
TEST_USER_EMAIL
=
"test-user-email123@gitlab4j.org"
;
private
static
final
String
TEST_USER_EMAIL
=
"test-user-email123@gitlab4j.org"
;
private
static
final
String
TEST_EXTERNAL_USERNAME
=
HelperUtils
.
getProperty
(
EXTERNAL_USERNAME_KEY
);
private
static
final
String
TEST_EXTERNAL_USERNAME
=
HelperUtils
.
getProperty
(
EXTERNAL_USERNAME_KEY
);
...
@@ -114,7 +114,7 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -114,7 +114,7 @@ public class TestUserApi extends AbstractIntegrationTest {
List
<
SshKey
>
sshKeys
=
gitLabApi
.
getUserApi
().
getSshKeys
();
List
<
SshKey
>
sshKeys
=
gitLabApi
.
getUserApi
().
getSshKeys
();
if
(
sshKeys
!=
null
)
{
if
(
sshKeys
!=
null
)
{
for
(
SshKey
key
:
sshKeys
)
{
for
(
SshKey
key
:
sshKeys
)
{
if
(
TEST_SSH_KEY
.
equals
(
key
.
getKey
()
))
{
if
(
key
.
getKey
().
startsWith
(
TEST_SSH_KEY
))
{
gitLabApi
.
getUserApi
().
deleteSshKey
(
key
.
getId
());
gitLabApi
.
getUserApi
().
deleteSshKey
(
key
.
getId
());
}
}
}
}
...
@@ -367,14 +367,19 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -367,14 +367,19 @@ public class TestUserApi extends AbstractIntegrationTest {
assumeTrue
(
TEST_SSH_KEY
!=
null
);
assumeTrue
(
TEST_SSH_KEY
!=
null
);
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
"Test-Key"
,
TEST_SSH_KEY
);
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
"Test-Key"
,
TEST_SSH_KEY
);
assertNotNull
(
sshKey
);
assertNotNull
(
sshKey
);
assert
Equals
(
TEST_SSH_KEY
,
sshKey
.
getKey
());
assert
True
(
TEST_SSH_KEY
,
sshKey
.
getKey
()
.
startsWith
(
TEST_SSH_KEY
)
);
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key1"
,
TEST_SSH_KEY
);
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key1"
,
TEST_SSH_KEY
);
assertNotNull
(
sshKey
);
assertNotNull
(
sshKey
);
assert
Equals
(
TEST_SSH_KEY
,
sshKey
.
getKey
());
assert
True
(
TEST_SSH_KEY
,
sshKey
.
getKey
()
.
startsWith
(
TEST_SSH_KEY
)
);
assertEquals
(
user
.
getId
(),
sshKey
.
getUserId
());
assertEquals
(
user
.
getId
(),
sshKey
.
getUserId
());
Optional
<
SshKey
>
optional
=
gitLabApi
.
getUserApi
().
getOptionalSshKey
(
sshKey
.
getId
());
assertNotNull
(
optional
.
isPresent
());
assertTrue
(
TEST_SSH_KEY
,
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
));
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
}
}
...
@@ -383,7 +388,7 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -383,7 +388,7 @@ public class TestUserApi extends AbstractIntegrationTest {
assumeTrue
(
TEST_SSH_KEY
!=
null
);
assumeTrue
(
TEST_SSH_KEY
!=
null
);
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key
1
"
,
TEST_SSH_KEY
);
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key
2
"
,
TEST_SSH_KEY
);
assertNotNull
(
sshKey
);
assertNotNull
(
sshKey
);
Optional
<
SshKey
>
optional
=
gitLabApi
.
getUserApi
().
getOptionalSshKey
(
sshKey
.
getId
());
Optional
<
SshKey
>
optional
=
gitLabApi
.
getUserApi
().
getOptionalSshKey
(
sshKey
.
getId
());
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets