groupRepos(String org)
92 | throws IOException {
93 | return Collections.singletonList(new GitlabProject());
94 | }
95 |
96 | @Override byte[] getDescriptor(String org, String repo, String branch,
97 | String filePath) throws IOException {
98 | return "".getBytes();
99 | }
100 | };
101 | }
102 | };
103 | }
104 |
105 | }
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/OptionsBuilderTest.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler;
2 |
3 | import org.assertj.core.api.BDDAssertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | /**
7 | * @author Marcin Grzejszczak
8 | */
9 | class OptionsBuilderTest {
10 |
11 | @Test void should_contain_project_names() {
12 | Options options = OptionsBuilder.builder()
13 | .project("foo", "foo", "foo")
14 | .project("bar", "bar", "bar")
15 | .build();
16 |
17 | BDDAssertions.then(options.projects)
18 | .extracting("projectName")
19 | .contains("foo", "bar");
20 | }
21 | }
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/OptionsTest.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler;
2 |
3 | import org.assertj.core.api.BDDAssertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | /**
7 | * @author Marcin Grzejszczak
8 | */
9 | class OptionsTest {
10 |
11 | @Test
12 | void should_return_true_when_project_ignored() {
13 | Options build = OptionsBuilder.builder()
14 | .exclude("^.*github\\.io$").build();
15 |
16 | BDDAssertions.then(build.isIgnored("foo.github.io")).isTrue();
17 | BDDAssertions.then(build.isIgnored("foo")).isFalse();
18 | }
19 |
20 | @Test void should_override_the_project_name() {
21 | Options build = OptionsBuilder.builder()
22 | .projectName("foo", "bar")
23 | .build();
24 |
25 | BDDAssertions.then(build.projectName("foo"))
26 | .isEqualTo("bar");
27 | }
28 | }
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/ProjectCrawlerTests.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler;
2 |
3 | import org.assertj.core.api.BDDAssertions;
4 | import org.junit.jupiter.api.AfterEach;
5 | import org.junit.jupiter.api.BeforeEach;
6 | import org.junit.jupiter.api.Test;
7 |
8 | /**
9 | * @author Marcin Grzejszczak
10 | */
11 | class ProjectCrawlerTests {
12 |
13 | @BeforeEach
14 | void before() {
15 | TestRepositoryManagementBuilder.EXECUTED = false;
16 | }
17 |
18 | @AfterEach
19 | void after() {
20 | TestRepositoryManagementBuilder.EXECUTED = false;
21 | }
22 |
23 | @Test
24 | void should_call_the_test_repo_manager_for_repositories() {
25 | new ProjectCrawler(OptionsBuilder.builder()
26 | .repository(Repositories.OTHER)
27 | .build())
28 | .repositories("foo");
29 |
30 | BDDAssertions.then(TestRepositoryManagementBuilder.EXECUTED).isTrue();
31 | }
32 |
33 | @Test
34 | void should_call_the_test_repo_manager_for_path() {
35 | new ProjectCrawler(OptionsBuilder.builder()
36 | .repository(Repositories.OTHER)
37 | .build())
38 | .fileContent("org", "repo", "branch", "path");
39 |
40 | BDDAssertions.then(TestRepositoryManagementBuilder.EXECUTED).isTrue();
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/RepositoryManagementBuilderTests.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler;
2 |
3 | import org.assertj.core.api.BDDAssertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | /**
7 | * @author Marcin Grzejszczak
8 | */
9 | class RepositoryManagementBuilderTests {
10 |
11 | @Test
12 | void should_do_nothing_by_default() {
13 | BDDAssertions.then(new RepositoryManagementBuilder() {
14 |
15 | }.build(OptionsBuilder.builder().build())).isNull();
16 | }
17 | }
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/TestRepositoryManagementBuilder.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler;
2 |
3 | /**
4 | * @author Marcin Grzejszczak
5 | */
6 | public class TestRepositoryManagementBuilder implements RepositoryManagementBuilder {
7 |
8 | static boolean EXECUTED = false;
9 |
10 | @Override public RepositoryManagement build(Options options) {
11 | EXECUTED = true;
12 | return new RepositoryManagement() {
13 | };
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/java/io/cloudpipelines/projectcrawler/util/SocketUtils.java:
--------------------------------------------------------------------------------
1 | package io.cloudpipelines.projectcrawler.util;
2 |
3 | import java.net.DatagramSocket;
4 | import java.net.InetAddress;
5 | import java.net.ServerSocket;
6 | import java.util.Random;
7 | import java.util.SortedSet;
8 | import java.util.TreeSet;
9 | import javax.net.ServerSocketFactory;
10 |
11 | // TAKEN FROM SPRING
12 |
13 | /**
14 | * Simple utility methods for working with network sockets — for example,
15 | * for finding available ports on {@code localhost}.
16 | *
17 | * Within this class, a TCP port refers to a port for a {@link ServerSocket};
18 | * whereas, a UDP port refers to a port for a {@link DatagramSocket}.
19 | *
20 | * @author Sam Brannen
21 | * @author Ben Hale
22 | * @author Arjen Poutsma
23 | * @author Gunnar Hillert
24 | * @author Gary Russell
25 | * @since 4.0
26 | */
27 | public class SocketUtils {
28 |
29 | /**
30 | * The default minimum value for port ranges used when finding an available
31 | * socket port.
32 | */
33 | public static final int PORT_RANGE_MIN = 1024;
34 |
35 | /**
36 | * The default maximum value for port ranges used when finding an available
37 | * socket port.
38 | */
39 | public static final int PORT_RANGE_MAX = 65535;
40 |
41 |
42 | private static final Random random = new Random(System.currentTimeMillis());
43 |
44 |
45 | /**
46 | * Although {@code SocketUtils} consists solely of static utility methods,
47 | * this constructor is intentionally {@code public}.
48 | *
Rationale
49 | * Static methods from this class may be invoked from within XML
50 | * configuration files using the Spring Expression Language (SpEL) and the
51 | * following syntax.
52 | *
<bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" />
53 | * If this constructor were {@code private}, you would be required to supply
54 | * the fully qualified class name to SpEL's {@code T()} function for each usage.
55 | * Thus, the fact that this constructor is {@code public} allows you to reduce
56 | * boilerplate configuration with SpEL as can be seen in the following example.
57 | * <bean id="socketUtils" class="org.springframework.util.SocketUtils" />
58 | * <bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
59 | * <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" />
60 | */
61 | public SocketUtils() {
62 | /* no-op */
63 | }
64 |
65 |
66 | /**
67 | * Find an available TCP port randomly selected from the range
68 | * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
69 | * @return an available TCP port number
70 | * @throws IllegalStateException if no available port could be found
71 | */
72 | public static int findAvailableTcpPort() {
73 | return findAvailableTcpPort(PORT_RANGE_MIN);
74 | }
75 |
76 | /**
77 | * Find an available TCP port randomly selected from the range
78 | * [{@code minPort}, {@value #PORT_RANGE_MAX}].
79 | * @param minPort the minimum port number
80 | * @return an available TCP port number
81 | * @throws IllegalStateException if no available port could be found
82 | */
83 | public static int findAvailableTcpPort(int minPort) {
84 | return findAvailableTcpPort(minPort, PORT_RANGE_MAX);
85 | }
86 |
87 | /**
88 | * Find an available TCP port randomly selected from the range
89 | * [{@code minPort}, {@code maxPort}].
90 | * @param minPort the minimum port number
91 | * @param maxPort the maximum port number
92 | * @return an available TCP port number
93 | * @throws IllegalStateException if no available port could be found
94 | */
95 | public static int findAvailableTcpPort(int minPort, int maxPort) {
96 | return SocketType.TCP.findAvailablePort(minPort, maxPort);
97 | }
98 |
99 | /**
100 | * Find the requested number of available TCP ports, each randomly selected
101 | * from the range [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
102 | * @param numRequested the number of available ports to find
103 | * @return a sorted set of available TCP port numbers
104 | * @throws IllegalStateException if the requested number of available ports could not be found
105 | */
106 | public static SortedSet findAvailableTcpPorts(int numRequested) {
107 | return findAvailableTcpPorts(numRequested, PORT_RANGE_MIN, PORT_RANGE_MAX);
108 | }
109 |
110 | /**
111 | * Find the requested number of available TCP ports, each randomly selected
112 | * from the range [{@code minPort}, {@code maxPort}].
113 | * @param numRequested the number of available ports to find
114 | * @param minPort the minimum port number
115 | * @param maxPort the maximum port number
116 | * @return a sorted set of available TCP port numbers
117 | * @throws IllegalStateException if the requested number of available ports could not be found
118 | */
119 | public static SortedSet findAvailableTcpPorts(int numRequested, int minPort, int maxPort) {
120 | return SocketType.TCP.findAvailablePorts(numRequested, minPort, maxPort);
121 | }
122 |
123 | /**
124 | * Find an available UDP port randomly selected from the range
125 | * [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
126 | * @return an available UDP port number
127 | * @throws IllegalStateException if no available port could be found
128 | */
129 | public static int findAvailableUdpPort() {
130 | return findAvailableUdpPort(PORT_RANGE_MIN);
131 | }
132 |
133 | /**
134 | * Find an available UDP port randomly selected from the range
135 | * [{@code minPort}, {@value #PORT_RANGE_MAX}].
136 | * @param minPort the minimum port number
137 | * @return an available UDP port number
138 | * @throws IllegalStateException if no available port could be found
139 | */
140 | public static int findAvailableUdpPort(int minPort) {
141 | return findAvailableUdpPort(minPort, PORT_RANGE_MAX);
142 | }
143 |
144 | /**
145 | * Find an available UDP port randomly selected from the range
146 | * [{@code minPort}, {@code maxPort}].
147 | * @param minPort the minimum port number
148 | * @param maxPort the maximum port number
149 | * @return an available UDP port number
150 | * @throws IllegalStateException if no available port could be found
151 | */
152 | public static int findAvailableUdpPort(int minPort, int maxPort) {
153 | return SocketType.UDP.findAvailablePort(minPort, maxPort);
154 | }
155 |
156 | /**
157 | * Find the requested number of available UDP ports, each randomly selected
158 | * from the range [{@value #PORT_RANGE_MIN}, {@value #PORT_RANGE_MAX}].
159 | * @param numRequested the number of available ports to find
160 | * @return a sorted set of available UDP port numbers
161 | * @throws IllegalStateException if the requested number of available ports could not be found
162 | */
163 | public static SortedSet findAvailableUdpPorts(int numRequested) {
164 | return findAvailableUdpPorts(numRequested, PORT_RANGE_MIN, PORT_RANGE_MAX);
165 | }
166 |
167 | /**
168 | * Find the requested number of available UDP ports, each randomly selected
169 | * from the range [{@code minPort}, {@code maxPort}].
170 | * @param numRequested the number of available ports to find
171 | * @param minPort the minimum port number
172 | * @param maxPort the maximum port number
173 | * @return a sorted set of available UDP port numbers
174 | * @throws IllegalStateException if the requested number of available ports could not be found
175 | */
176 | public static SortedSet findAvailableUdpPorts(int numRequested, int minPort, int maxPort) {
177 | return SocketType.UDP.findAvailablePorts(numRequested, minPort, maxPort);
178 | }
179 |
180 |
181 | private enum SocketType {
182 |
183 | TCP {
184 | @Override
185 | protected boolean isPortAvailable(int port) {
186 | try {
187 | ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(
188 | port, 1, InetAddress.getByName("localhost"));
189 | serverSocket.close();
190 | return true;
191 | }
192 | catch (Exception ex) {
193 | return false;
194 | }
195 | }
196 | },
197 |
198 | UDP {
199 | @Override
200 | protected boolean isPortAvailable(int port) {
201 | try {
202 | DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"));
203 | socket.close();
204 | return true;
205 | }
206 | catch (Exception ex) {
207 | return false;
208 | }
209 | }
210 | };
211 |
212 | /**
213 | * Determine if the specified port for this {@code SocketType} is
214 | * currently available on {@code localhost}.
215 | */
216 | protected abstract boolean isPortAvailable(int port);
217 |
218 | /**
219 | * Find a pseudo-random port number within the range
220 | * [{@code minPort}, {@code maxPort}].
221 | * @param minPort the minimum port number
222 | * @param maxPort the maximum port number
223 | * @return a random port number within the specified range
224 | */
225 | private int findRandomPort(int minPort, int maxPort) {
226 | int portRange = maxPort - minPort;
227 | return minPort + random.nextInt(portRange + 1);
228 | }
229 |
230 | /**
231 | * Find an available port for this {@code SocketType}, randomly selected
232 | * from the range [{@code minPort}, {@code maxPort}].
233 | * @param minPort the minimum port number
234 | * @param maxPort the maximum port number
235 | * @return an available port number for this socket type
236 | * @throws IllegalStateException if no available port could be found
237 | */
238 | int findAvailablePort(int minPort, int maxPort) {
239 | int portRange = maxPort - minPort;
240 | int candidatePort;
241 | int searchCounter = 0;
242 | do {
243 | if (++searchCounter > portRange) {
244 | throw new IllegalStateException(String.format(
245 | "Could not find an available %s port in the range [%d, %d] after %d attempts",
246 | name(), minPort, maxPort, searchCounter));
247 | }
248 | candidatePort = findRandomPort(minPort, maxPort);
249 | }
250 | while (!isPortAvailable(candidatePort));
251 |
252 | return candidatePort;
253 | }
254 |
255 | /**
256 | * Find the requested number of available ports for this {@code SocketType},
257 | * each randomly selected from the range [{@code minPort}, {@code maxPort}].
258 | * @param numRequested the number of available ports to find
259 | * @param minPort the minimum port number
260 | * @param maxPort the maximum port number
261 | * @return a sorted set of available port numbers for this socket type
262 | * @throws IllegalStateException if the requested number of available ports could not be found
263 | */
264 | SortedSet findAvailablePorts(int numRequested, int minPort, int maxPort) {
265 | SortedSet availablePorts = new TreeSet();
266 | int attemptCount = 0;
267 | while ((++attemptCount <= numRequested + 100) && availablePorts.size() < numRequested) {
268 | availablePorts.add(findAvailablePort(minPort, maxPort));
269 | }
270 |
271 | if (availablePorts.size() != numRequested) {
272 | throw new IllegalStateException(String.format(
273 | "Could not find %d available %s ports in the range [%d, %d]",
274 | numRequested, name(), minPort, maxPort));
275 | }
276 |
277 | return availablePorts;
278 | }
279 | }
280 |
281 | }
282 |
--------------------------------------------------------------------------------
/src/test/resources/META-INF/services/io.cloudpipelines.projectcrawler.RepositoryManagementBuilder:
--------------------------------------------------------------------------------
1 | io.cloudpipelines.projectcrawler.TestRepositoryManagementBuilder
--------------------------------------------------------------------------------
/src/test/resources/bitbucket/projects.json:
--------------------------------------------------------------------------------
1 | {
2 | "pagelen": 10,
3 | "values": [
4 | {
5 | "scm": "git",
6 | "website": "",
7 | "has_wiki": false,
8 | "uuid": "{2969f380-836c-46e7-beaf-0c74d7ca9a24}",
9 | "links": {
10 | "watchers": {
11 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/watchers"
12 | },
13 | "branches": {
14 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/refs/branches"
15 | },
16 | "tags": {
17 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/refs/tags"
18 | },
19 | "commits": {
20 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/commits"
21 | },
22 | "clone": [
23 | {
24 | "href": "https://bitbucket.org/scpipelines/github-webhook.git",
25 | "name": "https"
26 | },
27 | {
28 | "href": "git@bitbucket.org:scpipelines/github-webhook.git",
29 | "name": "ssh"
30 | }
31 | ],
32 | "self": {
33 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook"
34 | },
35 | "source": {
36 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/src"
37 | },
38 | "html": {
39 | "href": "https://bitbucket.org/scpipelines/github-webhook"
40 | },
41 | "avatar": {
42 | "href": "https://bytebucket.org/ravatar/%7B2969f380-836c-46e7-beaf-0c74d7ca9a24%7D?ts=default"
43 | },
44 | "hooks": {
45 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/hooks"
46 | },
47 | "forks": {
48 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/forks"
49 | },
50 | "downloads": {
51 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/downloads"
52 | },
53 | "pullrequests": {
54 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-webhook/pullrequests"
55 | }
56 | },
57 | "fork_policy": "allow_forks",
58 | "name": "github-webhook",
59 | "project": {
60 | "key": "GIT",
61 | "type": "project",
62 | "uuid": "{1c1015cc-bf6b-4857-b0ae-f548c1c2e625}",
63 | "links": {
64 | "self": {
65 | "href": "https://api.bitbucket.org/2.0/teams/scpipelines/projects/GIT"
66 | },
67 | "html": {
68 | "href": "https://bitbucket.org/account/user/scpipelines/projects/GIT"
69 | },
70 | "avatar": {
71 | "href": "https://bitbucket.org/account/user/scpipelines/projects/GIT/avatar/32"
72 | }
73 | },
74 | "name": "github-webhook"
75 | },
76 | "language": "",
77 | "created_on": "2018-07-25T07:00:28.296081+00:00",
78 | "mainbranch": {
79 | "type": "branch",
80 | "name": "master"
81 | },
82 | "full_name": "scpipelines/github-webhook",
83 | "has_issues": false,
84 | "owner": {
85 | "username": "scpipelines",
86 | "display_name": "sc-pipelines",
87 | "type": "team",
88 | "uuid": "{7d9675e0-6e92-41b8-aec4-dff4487d8bf5}",
89 | "links": {
90 | "self": {
91 | "href": "https://api.bitbucket.org/2.0/teams/scpipelines"
92 | },
93 | "html": {
94 | "href": "https://bitbucket.org/scpipelines/"
95 | },
96 | "avatar": {
97 | "href": "https://bitbucket.org/account/scpipelines/avatar/"
98 | }
99 | }
100 | },
101 | "updated_on": "2018-07-25T07:00:28.695833+00:00",
102 | "size": 279046,
103 | "type": "repository",
104 | "slug": "github-webhook",
105 | "is_private": false,
106 | "description": ""
107 | },
108 | {
109 | "scm": "git",
110 | "website": "",
111 | "has_wiki": false,
112 | "uuid": "{33176226-263c-43a6-8709-7b5e8411df11}",
113 | "links": {
114 | "watchers": {
115 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/watchers"
116 | },
117 | "branches": {
118 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/refs/branches"
119 | },
120 | "tags": {
121 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/refs/tags"
122 | },
123 | "commits": {
124 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/commits"
125 | },
126 | "clone": [
127 | {
128 | "href": "https://bitbucket.org/scpipelines/github-analytics.git",
129 | "name": "https"
130 | },
131 | {
132 | "href": "git@bitbucket.org:scpipelines/github-analytics.git",
133 | "name": "ssh"
134 | }
135 | ],
136 | "self": {
137 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics"
138 | },
139 | "source": {
140 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/src"
141 | },
142 | "html": {
143 | "href": "https://bitbucket.org/scpipelines/github-analytics"
144 | },
145 | "avatar": {
146 | "href": "https://bytebucket.org/ravatar/%7B33176226-263c-43a6-8709-7b5e8411df11%7D?ts=default"
147 | },
148 | "hooks": {
149 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/hooks"
150 | },
151 | "forks": {
152 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/forks"
153 | },
154 | "downloads": {
155 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/downloads"
156 | },
157 | "pullrequests": {
158 | "href": "https://api.bitbucket.org/2.0/repositories/scpipelines/github-analytics/pullrequests"
159 | }
160 | },
161 | "fork_policy": "allow_forks",
162 | "name": "github-analytics",
163 | "project": {
164 | "key": "GIT-2",
165 | "type": "project",
166 | "uuid": "{e62c6dff-ca9d-4067-ae65-77e8498f5f00}",
167 | "links": {
168 | "self": {
169 | "href": "https://api.bitbucket.org/2.0/teams/scpipelines/projects/GIT-2"
170 | },
171 | "html": {
172 | "href": "https://bitbucket.org/account/user/scpipelines/projects/GIT-2"
173 | },
174 | "avatar": {
175 | "href": "https://bitbucket.org/account/user/scpipelines/projects/GIT-2/avatar/32"
176 | }
177 | },
178 | "name": "github-analytics"
179 | },
180 | "language": "",
181 | "created_on": "2018-07-25T08:39:20.103485+00:00",
182 | "mainbranch": {
183 | "type": "branch",
184 | "name": "master"
185 | },
186 | "full_name": "scpipelines/github-analytics",
187 | "has_issues": false,
188 | "owner": {
189 | "username": "scpipelines",
190 | "display_name": "sc-pipelines",
191 | "type": "team",
192 | "uuid": "{7d9675e0-6e92-41b8-aec4-dff4487d8bf5}",
193 | "links": {
194 | "self": {
195 | "href": "https://api.bitbucket.org/2.0/teams/scpipelines"
196 | },
197 | "html": {
198 | "href": "https://bitbucket.org/scpipelines/"
199 | },
200 | "avatar": {
201 | "href": "https://bitbucket.org/account/scpipelines/avatar/"
202 | }
203 | }
204 | },
205 | "updated_on": "2018-07-25T08:39:20.515725+00:00",
206 | "size": 354313,
207 | "type": "repository",
208 | "slug": "github-analytics",
209 | "is_private": false,
210 | "description": ""
211 | }
212 | ],
213 | "page": 1,
214 | "size": 2
215 | }
--------------------------------------------------------------------------------
/src/test/resources/gitlab/curls:
--------------------------------------------------------------------------------
1 | $ echo "Getting projects for group"
2 | $ curl --header "Private-Token: foo-bar" https://gitlab.com/api/v4/groups/sc-pipelines/projects
3 | $ echo "Getting a file"
4 | $ curl --header "Private-Token: foo-bar" 'https://gitlab.com/api/v4/projects/7620377/repository/files/sc-pipelines%2Eyml?ref=master' | jq
--------------------------------------------------------------------------------
/src/test/resources/gitlab/v4_file_from_path.json:
--------------------------------------------------------------------------------
1 | {
2 | "file_name": "sc-pipelines.yml",
3 | "file_path": "sc-pipelines.yml",
4 | "size": 1293,
5 | "encoding": "base64",
6 | "content_sha256": "fa6bf9d208dc13439b4122ec43df507990359f2929c1bb7102dad1964b49ad8c",
7 | "ref": "master",
8 | "blob_id": "8bae677dbc61a5bf8c1dc0cb6164b4468b376487",
9 | "commit_id": "adba557aa5dc80a47708d6a9887a7a0d1a70c990",
10 | "last_commit_id": "0489ec15cae3b8acdd313c4fc28256532c2ac8c9",
11 | "content": "IyBUaGlzIGZpbGUgZGVzY3JpYmVzIHdoaWNoIHNlcnZpY2VzIGFyZSByZXF1aXJlZCBieSB0aGlzIGFwcGxpY2F0aW9uCiMgaW4gb3JkZXIgZm9yIHRoZSBzbW9rZSB0ZXN0cyBvbiB0aGUgVEVTVCBlbnZpcm9ubWVudCBhbmQgZW5kIHRvIGVuZCB0ZXN0cwojIG9uIHRoZSBTVEFHRSBlbnZpcm9ubWVudCB0byBwYXNzCgojIGxvd2VyY2FzZSBuYW1lIG9mIHRoZSBlbnZpcm9ubWVudAp0ZXN0OgogICMgbGlzdCBvZiByZXF1aXJlZCBzZXJ2aWNlcwogIHNlcnZpY2VzOgogICAgIyBQcmVwYXJlZCBmb3IgUENGIERFVgogICAgIyB0eXBlIGFuZCBuYW1lIG9mIHRoZSBzZXJ2aWNlCiAgICAtIG5hbWU6IG15c3FsLWdpdGh1Yi1hbmFseXRpY3MKICAgICAgdHlwZTogYnJva2VyCiAgICAgIGJyb2tlcjogcC1teXNxbAogICAgICBwbGFuOiA1MTJtYgogICAgLSBuYW1lOiBnaXRodWItcmFiYml0bXEKICAgICAgdHlwZTogYnJva2VyCiAgICAgIGJyb2tlcjogY2xvdWRhbXFwCiAgICAgIHBsYW46IGxlbXVyCiAgICAtIG5hbWU6IGdpdGh1Yi1ldXJla2EKICAgICAgdHlwZTogYXBwCiAgICAgIGNvb3JkaW5hdGVzOiBjb20uZXhhbXBsZS5ldXJla2E6Z2l0aHViLWV1cmVrYTowLjAuMS5NMQogICAgICBwYXRoVG9NYW5pZmVzdDogc2MtcGlwZWxpbmVzL21hbmlmZXN0LWV1cmVrYS55bWwKICAgIC0gdHlwZTogc3R1YnJ1bm5lcgogICAgICBuYW1lOiBzdHVicnVubmVyCiAgICAgIGNvb3JkaW5hdGVzOiBjb20uZXhhbXBsZS5naXRodWI6Z2l0aHViLWFuYWx5dGljcy1zdHViLXJ1bm5lci1ib290LWNsYXNzcGF0aC1zdHViczowLjAuMS5NMQogICAgICBwYXRoVG9NYW5pZmVzdDogc2MtcGlwZWxpbmVzL21hbmlmZXN0LXN0dWJydW5uZXIueW1sCnN0YWdlOgogIHNlcnZpY2VzOgogICAgIyBQcmVwYXJlZCBmb3IgUENGIERFVgogICAgIyB0eXBlIGFuZCBuYW1lIG9mIHRoZSBzZXJ2aWNlCiAgICAtIG5hbWU6IG15c3FsLWdpdGh1Yi1hbmFseXRpY3MKICAgICAgdHlwZTogYnJva2VyCiAgICAgIGJyb2tlcjogcC1teXNxbAogICAgICBwbGFuOiA1MTJtYgogICAgLSBuYW1lOiBnaXRodWItcmFiYml0bXEKICAgICAgdHlwZTogYnJva2VyCiAgICAgIGJyb2tlcjogY2xvdWRhbXFwCiAgICAgIHBsYW46IGxlbXVyCiAgICAtIG5hbWU6IGdpdGh1Yi1ldXJla2EKICAgICAgdHlwZTogYXBwCiAgICAgIGNvb3JkaW5hdGVzOiBjb20uZXhhbXBsZS5ldXJla2E6Z2l0aHViLWV1cmVrYTowLjAuMS5NMQogICAgICBwYXRoVG9NYW5pZmVzdDogc2MtcGlwZWxpbmVzL21hbmlmZXN0LWV1cmVrYS55bWwK"
12 | }
--------------------------------------------------------------------------------
/src/test/resources/gitlab/v4_projects_for_group.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": 7620377,
4 | "description": "",
5 | "name": "github-analytics",
6 | "name_with_namespace": "sc-pipelines / github-analytics",
7 | "path": "github-analytics",
8 | "path_with_namespace": "sc-pipelines/github-analytics",
9 | "created_at": "2018-07-24T22:37:47.677Z",
10 | "default_branch": "master",
11 | "tag_list": [],
12 | "ssh_url_to_repo": "git@gitlab.com:sc-pipelines/github-analytics.git",
13 | "http_url_to_repo": "https://gitlab.com/sc-pipelines/github-analytics.git",
14 | "web_url": "https://gitlab.com/sc-pipelines/github-analytics",
15 | "readme_url": "https://gitlab.com/sc-pipelines/github-analytics/blob/master/README.adoc",
16 | "avatar_url": null,
17 | "star_count": 0,
18 | "forks_count": 0,
19 | "last_activity_at": "2018-07-24T22:37:47.677Z",
20 | "_links": {
21 | "self": "https://gitlab.com/api/v4/projects/7620377",
22 | "issues": "https://gitlab.com/api/v4/projects/7620377/issues",
23 | "merge_requests": "https://gitlab.com/api/v4/projects/7620377/merge_requests",
24 | "repo_branches": "https://gitlab.com/api/v4/projects/7620377/repository/branches",
25 | "labels": "https://gitlab.com/api/v4/projects/7620377/labels",
26 | "events": "https://gitlab.com/api/v4/projects/7620377/events",
27 | "members": "https://gitlab.com/api/v4/projects/7620377/members"
28 | },
29 | "archived": false,
30 | "visibility": "internal",
31 | "resolve_outdated_diff_discussions": false,
32 | "container_registry_enabled": true,
33 | "issues_enabled": true,
34 | "merge_requests_enabled": true,
35 | "wiki_enabled": true,
36 | "jobs_enabled": true,
37 | "snippets_enabled": true,
38 | "shared_runners_enabled": true,
39 | "lfs_enabled": true,
40 | "creator_id": 829256,
41 | "namespace": {
42 | "id": 3282590,
43 | "name": "sc-pipelines",
44 | "path": "sc-pipelines",
45 | "kind": "group",
46 | "full_path": "sc-pipelines",
47 | "parent_id": null
48 | },
49 | "import_status": "none",
50 | "open_issues_count": 0,
51 | "public_jobs": true,
52 | "ci_config_path": null,
53 | "shared_with_groups": [],
54 | "only_allow_merge_if_pipeline_succeeds": false,
55 | "request_access_enabled": false,
56 | "only_allow_merge_if_all_discussions_are_resolved": false,
57 | "printing_merge_request_link_enabled": true,
58 | "merge_method": "merge"
59 | },
60 | {
61 | "id": 7620371,
62 | "description": "",
63 | "name": "github-webhook",
64 | "name_with_namespace": "sc-pipelines / github-webhook",
65 | "path": "github-webhook",
66 | "path_with_namespace": "sc-pipelines/github-webhook",
67 | "created_at": "2018-07-24T22:36:45.175Z",
68 | "default_branch": "master",
69 | "tag_list": [],
70 | "ssh_url_to_repo": "git@gitlab.com:sc-pipelines/github-webhook.git",
71 | "http_url_to_repo": "https://gitlab.com/sc-pipelines/github-webhook.git",
72 | "web_url": "https://gitlab.com/sc-pipelines/github-webhook",
73 | "readme_url": "https://gitlab.com/sc-pipelines/github-webhook/blob/master/README.adoc",
74 | "avatar_url": null,
75 | "star_count": 0,
76 | "forks_count": 0,
77 | "last_activity_at": "2018-07-24T22:36:45.175Z",
78 | "_links": {
79 | "self": "https://gitlab.com/api/v4/projects/7620371",
80 | "issues": "https://gitlab.com/api/v4/projects/7620371/issues",
81 | "merge_requests": "https://gitlab.com/api/v4/projects/7620371/merge_requests",
82 | "repo_branches": "https://gitlab.com/api/v4/projects/7620371/repository/branches",
83 | "labels": "https://gitlab.com/api/v4/projects/7620371/labels",
84 | "events": "https://gitlab.com/api/v4/projects/7620371/events",
85 | "members": "https://gitlab.com/api/v4/projects/7620371/members"
86 | },
87 | "archived": false,
88 | "visibility": "internal",
89 | "resolve_outdated_diff_discussions": false,
90 | "container_registry_enabled": true,
91 | "issues_enabled": true,
92 | "merge_requests_enabled": true,
93 | "wiki_enabled": true,
94 | "jobs_enabled": true,
95 | "snippets_enabled": true,
96 | "shared_runners_enabled": true,
97 | "lfs_enabled": true,
98 | "creator_id": 829256,
99 | "namespace": {
100 | "id": 3282590,
101 | "name": "sc-pipelines",
102 | "path": "sc-pipelines",
103 | "kind": "group",
104 | "full_path": "sc-pipelines",
105 | "parent_id": null
106 | },
107 | "import_status": "none",
108 | "open_issues_count": 0,
109 | "public_jobs": true,
110 | "ci_config_path": null,
111 | "shared_with_groups": [],
112 | "only_allow_merge_if_pipeline_succeeds": false,
113 | "request_access_enabled": false,
114 | "only_allow_merge_if_all_discussions_are_resolved": false,
115 | "printing_merge_request_link_enabled": true,
116 | "merge_method": "merge"
117 | }
118 | ]
--------------------------------------------------------------------------------
/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------