-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8bb0ac
commit 8fd86ff
Showing
5 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
backend/src/test/java/io/papermc/hangar/controller/api/v1/ProjectsControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.papermc.hangar.controller.api.v1; | ||
|
||
import io.papermc.hangar.controller.api.v1.helper.ControllerTest; | ||
import io.papermc.hangar.controller.api.v1.helper.TestData; | ||
import io.papermc.hangar.model.common.NamedPermission; | ||
import io.papermc.hangar.model.internal.api.requests.CreateAPIKeyForm; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
class ProjectsControllerTest extends ControllerTest { | ||
|
||
@Test | ||
void testGetProject() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/projects/TestProject") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.name", is("TestProject"))) | ||
.andExpect(jsonPath("$.namespace.owner", is("PaperMC"))); | ||
} | ||
|
||
@Test | ||
void testGetHiddenProject() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/projects/TestProject") | ||
.with(this.apiKey(TestData.KEY_PROJECT_ONLY))) | ||
.andExpect(status().is(404)); | ||
} | ||
|
||
@Test | ||
void testGetMembers() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/projects/TestProject/members") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(1))) | ||
.andExpect(jsonPath("$.result[0].user", is("PaperMC"))) | ||
.andExpect(jsonPath("$.result[0].roles[0].title", is("Owner"))); | ||
} | ||
|
||
@Test | ||
void testGetStats() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetStargazers() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetWatchers() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetProjectsByAuthor() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/projects?owner=PaperMC") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(1))) | ||
.andExpect(jsonPath("$.result[0].name", is("TestProject"))) | ||
.andExpect(jsonPath("$.result[0].namespace.owner", is("PaperMC"))); | ||
} | ||
|
||
@Test | ||
void testGetProjectsByQuery() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/projects?q=Test") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(1))) | ||
.andExpect(jsonPath("$.result[0].name", is("TestProject"))) | ||
.andExpect(jsonPath("$.result[0].namespace.owner", is("PaperMC"))); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
backend/src/test/java/io/papermc/hangar/controller/api/v1/UserControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.papermc.hangar.controller.api.v1; | ||
|
||
import io.papermc.hangar.controller.api.v1.helper.ControllerTest; | ||
import io.papermc.hangar.controller.api.v1.helper.TestData; | ||
import io.papermc.hangar.model.common.NamedPermission; | ||
import io.papermc.hangar.model.internal.api.requests.CreateAPIKeyForm; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
class UserControllerTest extends ControllerTest { | ||
|
||
@Test | ||
void testGetUserOrg() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/users/" + TestData.ORG.getName()) | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.name", is(TestData.ORG.getName()))) | ||
.andExpect(jsonPath("$.isOrganization", is(true))); | ||
} | ||
|
||
@Test | ||
void testGetUser() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/users/" + TestData.USER_ADMIN.getName()) | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.name", is(TestData.USER_ADMIN.getName()))) | ||
.andExpect(jsonPath("$.isOrganization", is(false))); | ||
} | ||
|
||
@Test | ||
void testGetUsers() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/users?query=Test") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(3))) | ||
.andExpect(jsonPath("$.result[*].name", contains("TestUser", "TestMember", "TestAdmin"))); | ||
} | ||
|
||
@Test | ||
void testGetStarred() { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetWatching() { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetPinned() { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetAuthors() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/authors?query=PaperMC") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(1))) | ||
.andExpect(jsonPath("$.result[*].name", contains("PaperMC"))); | ||
} | ||
|
||
@Test | ||
void testGetStaff() throws Exception { | ||
this.mockMvc.perform(get("/api/v1/staff?query=Test") | ||
.with(this.apiKey(TestData.KEY_ADMIN))) | ||
.andExpect(status().is(200)) | ||
.andExpect(jsonPath("$.pagination.count", is(1))) | ||
.andExpect(jsonPath("$.result[*].name", contains("TestAdmin"))); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
backend/src/test/java/io/papermc/hangar/controller/api/v1/VersionsControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.papermc.hangar.controller.api.v1; | ||
|
||
import io.papermc.hangar.controller.api.v1.helper.ControllerTest; | ||
import io.papermc.hangar.controller.api.v1.helper.TestData; | ||
import io.papermc.hangar.model.common.NamedPermission; | ||
import io.papermc.hangar.model.internal.api.requests.CreateAPIKeyForm; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.MediaType; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
class VersionsControllerTest extends ControllerTest { | ||
|
||
@Test | ||
void testUpload() throws Exception { | ||
// TODO | ||
this.mockMvc.perform(post("/api/v1/projects/TestProject/upload") | ||
.with(this.apiKey(TestData.KEY_ADMIN)) | ||
.header("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE)) | ||
.andExpect(status().is(201)) | ||
.andExpect(jsonPath("$.url", is(""))); | ||
} | ||
|
||
@Test | ||
void testGetVersion() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetVersions() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetLatestRelease() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetLatestVersion() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testGetStats() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testDownload() throws Exception { | ||
// TODO | ||
throw new RuntimeException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters