forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestIgnoreCertificateErrors.java
112 lines (94 loc) · 4.41 KB
/
TestIgnoreCertificateErrors.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
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_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 TestIgnoreCertificateErrors implements PropertyConstants {
// The following needs to be set to your test repository
private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY);
private static final String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
private static boolean setupOk;
public TestIgnoreCertificateErrors() {
super();
}
@BeforeAll
public static void setup() {
String problems = "";
if (TEST_HOST_URL == null || TEST_HOST_URL.trim().isEmpty()) {
problems += "TEST_HOST_URL cannot be empty\n";
}
if (TEST_PRIVATE_TOKEN == null || TEST_PRIVATE_TOKEN.trim().isEmpty()) {
problems += "TEST_PRIVATE_TOKEN cannot be empty\n";
}
if (problems.isEmpty()) {
setupOk = true;
} else {
setupOk = false;
System.err.print(problems);
}
}
@BeforeEach
public void beforeMethod() {
assumeTrue(setupOk);
}
@Test
public void testGetVersion() throws GitLabApiException {
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
assertFalse(gitLabApi.getIgnoreCertificateErrors());
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("ignoreCertErrors: %b, version=%s, revision=%s%n", gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.setIgnoreCertificateErrors(true);
assertTrue(gitLabApi.getIgnoreCertificateErrors());
version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("ignoreCertErrors: %b, version=%s, revision=%s%n", gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.setIgnoreCertificateErrors(false);
assertFalse(gitLabApi.getIgnoreCertificateErrors());
version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("ignoreCertErrors: %b, version=%s, revision=%s%n", gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.close();
gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
gitLabApi.setIgnoreCertificateErrors(true);
assertTrue(gitLabApi.getIgnoreCertificateErrors());
version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("ignoreCertErrors: %b, version=%s, revision=%s%n", gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.setIgnoreCertificateErrors(false);
assertFalse(gitLabApi.getIgnoreCertificateErrors());
version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("ignoreCertErrors: %b, version=%s, revision=%s%n", gitLabApi.getIgnoreCertificateErrors(), version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.close();
}
}