-
Notifications
You must be signed in to change notification settings - Fork 474
Feature/protected branch and example test properties #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c2186d4
44eb844
d4906b7
1db1f77
cac5f11
5847870
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
# Rename this file to test-gitlab4j.properties with proper property values. | ||
TEST_NAMESPACE=some-namespace | ||
TEST_PROJECT_NAME=some-project-name | ||
TEST_HOST_URL=some-gitlab-url | ||
TEST_PRIVATE_TOKEN=some-private-token | ||
# | ||
# To test GitLab4J-API, you must have access to a GitLab server. | ||
# | ||
# Copy this file to test-gitlab4j.properties and set the property | ||
# values to match the GitLab server you are testing against. | ||
# | ||
|
||
# REQUIRED: The following values must be set or the tests will fail. | ||
# The TEST_PRIVATE_TOKEN and TEST_USERNAME must belong to an admin user. | ||
TEST_PRIVATE_TOKEN= | ||
TEST_ACCESS_TOKEN= | ||
TEST_USERNAME= | ||
TEST_NAMESPACE= | ||
TEST_PROJECT_NAME= | ||
TEST_HOST_URL= | ||
|
||
# OPTIONAL: To test the GroupApi, set these to an existing group name and group-project name, | ||
# and the username of a group member | ||
TEST_GROUP= | ||
TEST_GROUP_PROJECT= | ||
TEST_GROUP_MEMBER_USERNAME= | ||
|
||
# OPTIONAL: To test oauth2Login, set these properties | ||
TEST_LOGIN_USERNAME= | ||
TEST_LOGIN_PASSWORD= | ||
|
||
# OPTIONAL: To test sudo capability provide a username to sudo as | ||
TEST_SUDO_AS_USERNAME= | ||
|
||
# OPTIONAL: To test using GitLab4J-API with a proxy, set the following properties | ||
TEST_PROXY_URI= | ||
TEST_PROXY_USERNAME= | ||
TEST_PROXY_PASSWORD= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,10 +83,12 @@ public static void setup() { | |
problems += "Problem fetching test group, error=" + gle.getMessage() + "\n"; | ||
} | ||
|
||
try { | ||
testUser = gitLabApi.getUserApi().getUser(TEST_GROUP_MEMBER_USERNAME); | ||
} catch (GitLabApiException gle) { | ||
problems += "Problem fetching test user, error=" + gle.getMessage() + "\n"; | ||
if (TEST_GROUP_MEMBER_USERNAME != null && TEST_GROUP_MEMBER_USERNAME.length() > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (TEST_GROUP_MEMBER_USERNAME != null && !TEST_GROUP_MEMBER_USERNAME.isEmpty()) { ... } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my response above |
||
try { | ||
testUser = gitLabApi.getUserApi().getUser(TEST_GROUP_MEMBER_USERNAME); | ||
} catch (GitLabApiException gle) { | ||
problems += "Problem fetching test user, error=" + gle.getMessage() + "\n"; | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,11 @@ | |
|
||
/** | ||
* In order for these tests to run you must set the following properties in test-gitlab4j.properties | ||
* | ||
* | ||
* TEST_HOST_URL | ||
* TEST_PRIVATE_TOKEN | ||
* TEST_USERNAME | ||
* | ||
* | ||
* If any of the above are NULL, all tests in this class will be skipped. | ||
* | ||
* TEST_SUDO_AS_USERNAME | ||
|
@@ -56,7 +56,11 @@ public class TestUserApi { | |
TEST_PRIVATE_TOKEN = TestUtils.getProperty("TEST_PRIVATE_TOKEN"); | ||
TEST_USERNAME = TestUtils.getProperty("TEST_USERNAME"); | ||
TEST_SUDO_AS_USERNAME = TestUtils.getProperty("TEST_SUDO_AS_USERNAME"); | ||
TEST_SSH_KEY = TestUtils.getProperty("TEST_SSH_KEY"); | ||
TEST_SSH_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvbkmGRaANy2nmLrfYa9LkjMqjs9twYZXQKUPK18j" + | ||
"BWmNgnAm818IikxjfFit3Gqnnh9zdNzlzUYs2osmfdHwRLeFY3hKVR6WckGYVroQuV5ArUA4+oME+IIQ2soCv/" + | ||
"vNWfEmp2N1mpBTwi2mIYKurCKv6UpIpGK9D+ezNk5H0waVTK8EvZ/ey69Nu7C7RsbTYeyi5WY/jaUG5JbsEeKY" + | ||
"IW/2DIlUts7gcB2hzXtt7r7+6DLx82Vb+S2jPZu2JQaB4zfgS7LQgzHUy1aAAgUUpuAbvWzuGHKO0p551Ru4qi" + | ||
"tyXN2+OUVXcYAsuIIdGGB0wLvTDgiOOSZWnSE+sg6XX [email protected]"; | ||
} | ||
|
||
private static final String TEST_IMPERSONATION_TOKEN_NAME = "token1"; | ||
|
@@ -149,7 +153,7 @@ public void testGetOptionalUser() throws GitLabApiException { | |
@Test | ||
public void testSudoAsUser() throws GitLabApiException { | ||
|
||
assumeTrue(TEST_SUDO_AS_USERNAME != null); | ||
assumeTrue(TEST_SUDO_AS_USERNAME != null && TEST_SUDO_AS_USERNAME.length() > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my response above. |
||
|
||
try { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "develop", | ||
"push_access_levels": [ | ||
{ | ||
"access_level": 40, | ||
"access_level_description": "Masters" | ||
}, | ||
{ | ||
"access_level": 30, | ||
"access_level_description": "Developer access" | ||
} | ||
], | ||
"merge_access_levels": [ | ||
{ | ||
"access_level": 40, | ||
"access_level_description": "Masters" | ||
}, | ||
{ | ||
"access_level": 30, | ||
"access_level_description": "Developer access" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using
TEST_PROXY_URI.isEmpty()
for length checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST_PROXY_URI.length() > 0
vs
!TEST_PROXY_URI.isEmpty()
When checking for truth, I prefer to use a statement that results in true, not something that has to be negated to produce true. It's just a personal preference and is used throughout GitLab4J, so to change it in these instances would require a sweep through all the code to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lamdav
FYI, when checking for empty instead of not empty I should be using isEmpty(), so I have gone through all the tests and replaced str.size() == 0 with str.isEmpty(), just thought I would let you know.