forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestAccessToken.java
77 lines (64 loc) · 2.7 KB
/
TestAccessToken.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.Constants.TokenType;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Version;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
* TEST_HOST_URL
* TEST_ACCESS_TOKEN
* TEST_PRIVATE_TOKEN
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@org.junit.jupiter.api.Disabled("Integration tests are disabled, see https://github.com/gitlab4j/gitlab4j-api/issues/1165")
public class TestAccessToken extends AbstractIntegrationTest {
// TEST_ACCESS_TOKEN must be defined to run this test
private static final String TEST_ACCESS_TOKEN = HelperUtils.getProperty("TEST_ACCESS_TOKEN");
private static GitLabApi gitLabApi;
public TestAccessToken() {
super();
}
@BeforeAll
public static void testSetup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
if (TEST_ACCESS_TOKEN == null || TEST_ACCESS_TOKEN.trim().isEmpty()) {
System.err.println("TEST_ACCESS_TOKEN cannot be empty");
}
}
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
@Test
public void testPrivateToken() throws GitLabApiException {
// This test uses the GitLabApi instance created in setup()
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("tokenType: %s, version=%s, revision=%s%n", TokenType.PRIVATE, gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
}
@Test
public void testAccessToken() throws GitLabApiException {
assumeTrue(TEST_ACCESS_TOKEN != null);
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TokenType.ACCESS, TEST_ACCESS_TOKEN);
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("tokenType: %s, version=%s, revision=%s%n", TokenType.ACCESS, gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.close();
}
}