diff --git a/pom.xml b/pom.xml
index 3be1172..4f16073 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,4 +115,17 @@
test
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
diff --git a/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java b/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java
index 07aeeac..962d1b8 100644
--- a/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java
+++ b/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java
@@ -45,7 +45,11 @@
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import javax.net.ssl.HttpsURLConnection;
import jenkins.model.Jenkins;
import org.apache.commons.codec.binary.Base64;
@@ -959,20 +963,35 @@ private T patch(UriTemplate template, Object body, final Class modelClass
}
}
+ private Pattern nextPagePattern = Pattern.compile("<(.*)>;\\s*rel=\"next\"");
+
private List getList(UriTemplate template, final Class modelClass)
throws IOException, InterruptedException {
- HttpURLConnection connection = openConnection(template);
+ return getList(template.expand(), modelClass);
+ }
+
+ private List getList(String url, final Class modelClass) throws IOException, InterruptedException {
+ HttpURLConnection connection = openConnection(url);
withAuthentication(connection);
try {
connection.connect();
int status = connection.getResponseCode();
+
if (status / 100 == 2) {
+ Optional next = Optional.ofNullable(connection.getHeaderField("Link"))
+ .map(nextPagePattern::matcher)
+ .filter(Matcher::find)
+ .map(matcher -> matcher.group(1));
+
try (InputStream is = connection.getInputStream()) {
- List list = mapper.readerFor(mapper.getTypeFactory()
- .constructCollectionType(List.class, modelClass))
+ List list = mapper
+ .readerFor(mapper.getTypeFactory().constructCollectionType(List.class, modelClass))
.readValue(is);
+ if (next.isPresent()) {
+ list.addAll(getList(next.get(), modelClass));
+ }
// strip null values from the list
- for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
if (iterator.next() == null) {
iterator.remove();
}
@@ -986,9 +1005,13 @@ private List getList(UriTemplate template, final Class modelClass)
}
}
+ private HttpURLConnection openConnection(UriTemplate template) throws IOException {
+ return openConnection(template.expand());
+ }
+
@Restricted(NoExternalUse.class)
- protected HttpURLConnection openConnection(UriTemplate template) throws IOException {
- URL url = new URL(template.expand());
+ protected HttpURLConnection openConnection(String spec) throws IOException {
+ URL url = new URL(spec);
Jenkins jenkins = Jenkins.get();
if (jenkins.proxy == null) {
return (HttpURLConnection) url.openConnection();
diff --git a/src/test/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection_PagedRequests_Test.java b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection_PagedRequests_Test.java
new file mode 100644
index 0000000..1962ba1
--- /dev/null
+++ b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection_PagedRequests_Test.java
@@ -0,0 +1,212 @@
+package org.jenkinsci.plugin.gitea.client.impl;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jenkinsci.plugin.gitea.client.api.GiteaAuthNone;
+import org.jenkinsci.plugin.gitea.client.api.GiteaBranch;
+import org.jenkinsci.plugin.gitea.client.api.GiteaCommitStatus;
+import org.jenkinsci.plugin.gitea.client.api.GiteaHook;
+import org.jenkinsci.plugin.gitea.client.api.GiteaIssue;
+import org.jenkinsci.plugin.gitea.client.api.GiteaOrganization;
+import org.jenkinsci.plugin.gitea.client.api.GiteaOwner;
+import org.jenkinsci.plugin.gitea.client.api.GiteaPullRequest;
+import org.jenkinsci.plugin.gitea.client.api.GiteaRepository;
+import org.jenkinsci.plugin.gitea.client.api.GiteaTag;
+import org.jenkinsci.plugin.gitea.client.api.GiteaUser;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class DefaultGiteaConnection_PagedRequests_Test {
+
+ private GiteaRepository giteaRepository;
+
+ @Before
+ public void reset() {
+ giteaRepository = new GiteaRepository(
+ new GiteaOwner("", "", "", ""),
+ null, "", "", "",
+ true, false, false, false,
+ "", "", "", "",
+ 0L, 0L, 0L, 0L, "",
+ null
+ );
+ }
+
+ @Test
+ public void test_fetchOrganizationRepositories_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/orgs//repos";
+ String page2Url = "http://server.com/api/v1/orgs//repos?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "repoResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "repoResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List repositories = giteaConnection
+ .fetchRepositories(new GiteaOrganization("", "", "", "", "", ""));
+ assertThat(repositories.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchUserRepositories_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/users//repos";
+ String page2Url = "http://server.com/api/v1/users//repos?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "repoResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "repoResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List repositories = giteaConnection.fetchRepositories(new GiteaOwner("", "", "", ""));
+ assertThat(repositories.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchCurrentUserRepositories_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/user/repos";
+ String page2Url = "http://server.com/api/v1/user/repos?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "repoResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "repoResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List repositories = giteaConnection.fetchCurrentUserRepositories();
+ assertThat(repositories.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchBranches_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///branches";
+ String page2Url = "http://server.com/api/v1/repos///branches?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "branchesResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "branchesResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List branches = giteaConnection.fetchBranches("", "");
+ assertThat(branches.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchTags_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///tags";
+ String page2Url = "http://server.com/api/v1/repos///tags?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "tagsResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "tagsResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List tags = giteaConnection.fetchTags("", "");
+ assertThat(tags.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchCollaborators_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///collaborators";
+ String page2Url = "http://server.com/api/v1/repos///collaborators?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "usersResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "usersResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List users = giteaConnection.fetchCollaborators("", "");
+ assertThat(users.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchHooks_from_user_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///hooks";
+ String page2Url = "http://server.com/api/v1/repos///hooks?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "hooksResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "hooksResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List hooks = giteaConnection.fetchHooks("", "");
+ assertThat(hooks.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchHooks_from_org_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/orgs//hooks";
+ String page2Url = "http://server.com/api/v1/orgs//hooks?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "hooksResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "hooksResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List hooks = giteaConnection.fetchHooks("");
+ assertThat(hooks.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchCommitStatuses_from_org_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///statuses/sha";
+ String page2Url = "http://server.com/api/v1/repos///statuses/sha?page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "commitStatusResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "commitStatusResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List commitStates = giteaConnection.fetchCommitStatuses(giteaRepository, "sha");
+ assertThat(commitStates.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchPullRequests_from_org_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///pulls?state=open";
+ String page2Url = "http://server.com/api/v1/repos///pulls?state=open&page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "pullRequestsResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "pullRequestsResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List pullRequests = giteaConnection.fetchPullRequests("", "");
+ assertThat(pullRequests.size(), is(2));
+ }
+ }
+
+ @Test
+ public void test_fetchIssues_from_org_with_paged_response() throws Exception {
+ HashMap mocks = new HashMap<>();
+ String page1Url = "http://server.com/api/v1/repos///issues?state=open";
+ String page2Url = "http://server.com/api/v1/repos///issues?state=open&page2";
+ mocks.put(page1Url, createUrlConnectionMock(200, "issuesResponse.json", page2Url));
+ mocks.put(page2Url, createUrlConnectionMock(200, "issuesResponse.json"));
+ try (DefaultGiteaConnection giteaConnection = new GiteaConnection_PagedRequests("http://server.com",
+ new GiteaAuthNone(), mocks)) {
+ List issues = giteaConnection.fetchIssues(giteaRepository);
+ assertThat(issues.size(), is(2));
+ }
+ }
+
+ private HttpURLConnection createUrlConnectionMock(int statusCode, String responseResource) throws IOException {
+ return createUrlConnectionMock(statusCode, responseResource, null);
+ }
+
+ private HttpURLConnection createUrlConnectionMock(int statusCode, String responseResource, String nextPage)
+ throws IOException {
+ HttpURLConnection connection = Mockito.mock(HttpURLConnection.class);
+ Mockito.when(connection.getResponseCode()).thenReturn(statusCode);
+ Mockito.when(connection.getInputStream()).thenReturn(this.getClass().getResourceAsStream(responseResource));
+ if (nextPage != null) {
+ Mockito.when(connection.getHeaderField("Link")).thenReturn(String.format("<%s>; rel=\"next\"", nextPage));
+ }
+ return connection;
+ }
+
+}
diff --git a/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_DisabledPR_Issues.java b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_DisabledPR_Issues.java
index f0cfbfc..d949e37 100644
--- a/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_DisabledPR_Issues.java
+++ b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_DisabledPR_Issues.java
@@ -1,6 +1,5 @@
package org.jenkinsci.plugin.gitea.client.impl;
-import com.damnhandy.uri.template.UriTemplate;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugin.gitea.client.api.GiteaAuth;
import org.jenkinsci.plugin.gitea.client.api.GiteaHttpStatusException;
@@ -14,7 +13,7 @@ public class GiteaConnection_DisabledPR_Issues extends DefaultGiteaConnection {
}
@Override
- protected HttpURLConnection openConnection(UriTemplate template) throws IOException {
+ protected HttpURLConnection openConnection(String spec) throws IOException {
throw new GiteaHttpStatusException(404, "TEST Case");
}
}
diff --git a/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_PagedRequests.java b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_PagedRequests.java
new file mode 100644
index 0000000..296b173
--- /dev/null
+++ b/src/test/java/org/jenkinsci/plugin/gitea/client/impl/GiteaConnection_PagedRequests.java
@@ -0,0 +1,23 @@
+package org.jenkinsci.plugin.gitea.client.impl;
+
+
+import edu.umd.cs.findbugs.annotations.NonNull;
+import org.jenkinsci.plugin.gitea.client.api.GiteaAuth;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.Map;
+
+public class GiteaConnection_PagedRequests extends DefaultGiteaConnection {
+ private Map requestMocks;
+
+ GiteaConnection_PagedRequests(@NonNull String serverUrl, @NonNull GiteaAuth authentication, Map requestMocks) {
+ super(serverUrl, authentication);
+ this.requestMocks = requestMocks;
+ }
+
+ @Override
+ protected HttpURLConnection openConnection(String spec) throws IOException {
+ return requestMocks.get(spec);
+ }
+}
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/branchesResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/branchesResponse.json
new file mode 100644
index 0000000..7caecff
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/branchesResponse.json
@@ -0,0 +1,50 @@
+[
+ {
+ "commit": {
+ "added": [
+ "string"
+ ],
+ "author": {
+ "email": "user@example.com",
+ "name": "string",
+ "username": "string"
+ },
+ "committer": {
+ "email": "user@example.com",
+ "name": "string",
+ "username": "string"
+ },
+ "id": "string",
+ "message": "string",
+ "modified": [
+ "string"
+ ],
+ "removed": [
+ "string"
+ ],
+ "timestamp": "2021-09-17T08:25:50.169Z",
+ "url": "string",
+ "verification": {
+ "payload": "string",
+ "reason": "string",
+ "signature": "string",
+ "signer": {
+ "email": "user@example.com",
+ "name": "string",
+ "username": "string"
+ },
+ "verified": true
+ }
+ },
+ "effective_branch_protection_name": "string",
+ "enable_status_check": true,
+ "name": "string",
+ "protected": true,
+ "required_approvals": 0,
+ "status_check_contexts": [
+ "string"
+ ],
+ "user_can_merge": true,
+ "user_can_push": true
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/commitStatusResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/commitStatusResponse.json
new file mode 100644
index 0000000..3c71d93
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/commitStatusResponse.json
@@ -0,0 +1,33 @@
+[
+ {
+ "context": "string",
+ "created_at": "2021-09-17T07:51:33.446Z",
+ "creator": {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T07:51:33.446Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T07:51:33.446Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ },
+ "description": "string",
+ "id": 0,
+ "status": "string",
+ "target_url": "string",
+ "updated_at": "2021-09-17T07:51:33.446Z",
+ "url": "string"
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/hooksResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/hooksResponse.json
new file mode 100644
index 0000000..46504fb
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/hooksResponse.json
@@ -0,0 +1,15 @@
+[
+ {
+ "active": true,
+ "config": {
+
+ },
+ "created_at": "2021-09-17T07:43:00.781Z",
+ "events": [
+ "string"
+ ],
+ "id": 0,
+ "type": "string",
+ "updated_at": "2021-09-17T07:43:00.781Z"
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/issuesResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/issuesResponse.json
new file mode 100644
index 0000000..ad70f73
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/issuesResponse.json
@@ -0,0 +1,116 @@
+[
+ {
+ "assignee": {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T08:16:39.554Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T08:16:39.554Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ },
+ "assignees": [
+ {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T08:16:39.554Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T08:16:39.554Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ }
+ ],
+ "body": "string",
+ "closed_at": "2021-09-17T08:16:39.554Z",
+ "comments": 0,
+ "created_at": "2021-09-17T08:16:39.554Z",
+ "due_date": "2021-09-17T08:16:39.554Z",
+ "html_url": "string",
+ "id": 0,
+ "is_locked": true,
+ "labels": [
+ {
+ "color": "00aabb",
+ "description": "string",
+ "id": 0,
+ "name": "string",
+ "url": "string"
+ }
+ ],
+ "milestone": {
+ "closed_at": "2021-09-17T08:16:39.554Z",
+ "closed_issues": 0,
+ "created_at": "2021-09-17T08:16:39.554Z",
+ "description": "string",
+ "due_on": "2021-09-17T08:16:39.554Z",
+ "id": 0,
+ "open_issues": 0,
+ "state": "string",
+ "title": "string",
+ "updated_at": "2021-09-17T08:16:39.554Z"
+ },
+ "number": 0,
+ "original_author": "string",
+ "original_author_id": 0,
+ "pull_request": {
+ "merged": true,
+ "merged_at": "2021-09-17T08:16:39.554Z"
+ },
+ "ref": "string",
+ "repository": {
+ "full_name": "string",
+ "id": 0,
+ "name": "string",
+ "owner": "string"
+ },
+ "state": "string",
+ "title": "string",
+ "updated_at": "2021-09-17T08:16:39.554Z",
+ "url": "string",
+ "user": {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T08:16:39.554Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T08:16:39.555Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ }
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/pullRequestsResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/pullRequestsResponse.json
new file mode 100644
index 0000000..888b141
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/pullRequestsResponse.json
@@ -0,0 +1,33 @@
+[
+ {
+ "context": "string",
+ "created_at": "2021-09-17T07:54:36.713Z",
+ "creator": {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T07:54:36.713Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T07:54:36.713Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ },
+ "description": "string",
+ "id": 0,
+ "status": "string",
+ "target_url": "string",
+ "updated_at": "2021-09-17T07:54:36.713Z",
+ "url": "string"
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/repoResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/repoResponse.json
new file mode 100644
index 0000000..da7930b
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/repoResponse.json
@@ -0,0 +1,82 @@
+[
+ {
+ "allow_merge_commits": true,
+ "allow_rebase": true,
+ "allow_rebase_explicit": true,
+ "allow_squash_merge": true,
+ "archived": true,
+ "avatar_url": "string",
+ "clone_url": "string",
+ "created_at": "2021-09-17T08:56:05.122Z",
+ "default_branch": "string",
+ "default_merge_style": "string",
+ "description": "string",
+ "empty": true,
+ "external_tracker": {
+ "external_tracker_format": "string",
+ "external_tracker_style": "string",
+ "external_tracker_url": "string"
+ },
+ "external_wiki": {
+ "external_wiki_url": "string"
+ },
+ "fork": true,
+ "forks_count": 0,
+ "full_name": "string",
+ "has_issues": true,
+ "has_projects": true,
+ "has_pull_requests": true,
+ "has_wiki": true,
+ "html_url": "string",
+ "id": 0,
+ "ignore_whitespace_conflicts": true,
+ "internal": true,
+ "internal_tracker": {
+ "allow_only_contributors_to_track_time": true,
+ "enable_issue_dependencies": true,
+ "enable_time_tracker": true
+ },
+ "mirror": true,
+ "mirror_interval": "string",
+ "name": "string",
+ "open_issues_count": 0,
+ "open_pr_counter": 0,
+ "original_url": "string",
+ "owner": {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T08:56:05.122Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T08:56:05.122Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ },
+ "parent": null,
+ "permissions": {
+ "admin": true,
+ "pull": true,
+ "push": true
+ },
+ "private": true,
+ "release_counter": 0,
+ "size": 0,
+ "ssh_url": "string",
+ "stars_count": 0,
+ "template": true,
+ "updated_at": "2021-09-17T08:56:05.122Z",
+ "watchers_count": 0,
+ "website": "string"
+ }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/tagsResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/tagsResponse.json
new file mode 100644
index 0000000..bf21363
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/tagsResponse.json
@@ -0,0 +1,14 @@
+[
+ {
+ "commit": {
+ "created": "2021-09-17T08:24:25.249Z",
+ "sha": "string",
+ "url": "string"
+ },
+ "id": "string",
+ "message": "string",
+ "name": "string",
+ "tarball_url": "string",
+ "zipball_url": "string"
+ }
+ ]
\ No newline at end of file
diff --git a/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/usersResponse.json b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/usersResponse.json
new file mode 100644
index 0000000..ce2648f
--- /dev/null
+++ b/src/test/resources/org/jenkinsci/plugin/gitea/client/impl/usersResponse.json
@@ -0,0 +1,23 @@
+[
+ {
+ "active": true,
+ "avatar_url": "string",
+ "created": "2021-09-17T08:44:48.204Z",
+ "description": "string",
+ "email": "user@example.com",
+ "followers_count": 0,
+ "following_count": 0,
+ "full_name": "string",
+ "id": 0,
+ "is_admin": true,
+ "language": "string",
+ "last_login": "2021-09-17T08:44:48.204Z",
+ "location": "string",
+ "login": "string",
+ "prohibit_login": true,
+ "restricted": true,
+ "starred_repos_count": 0,
+ "visibility": "string",
+ "website": "string"
+ }
+]
\ No newline at end of file