Skip to content

Commit

Permalink
Merge branch 'master' into 26-api-restrict-user-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanEngland committed Mar 26, 2024
2 parents ce5dd90 + 7fb4b20 commit 08f9ffb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ on:

permissions:
contents: read
checks: write
pull-requests: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout this repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -53,7 +54,7 @@ jobs:
cache-overwrite-existing: true
- name: Run Gradle build
working-directory: ./main
run: ./gradlew -U --info build
run: ./gradlew -U build -x test

- name: Upload interface definition
uses: actions/[email protected]
Expand All @@ -67,4 +68,10 @@ jobs:
working-directory: ./main
run: ./gradlew --info test


- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
main/build/test-results/**/*.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void testGetPeople() {
void testFilterPeople() {
given()
.when()
.param("name","PI")
.param("name","John Flamsteed")
.get("people")
.then()
.statusCode(200)
Expand All @@ -39,7 +39,7 @@ void testGetPerson() {
Integer personId =
given()
.when()
.param("name","PI")
.param("name","John Flamsteed")
.get("people")
.then()
.statusCode(200)
Expand All @@ -54,7 +54,7 @@ void testGetPerson() {
.then()
.statusCode(200)
.body(
containsString("\"fullName\":\"PI\"")
containsString("\"fullName\":\"John Flamsteed\"")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.hamcrest.Matchers.*;

@QuarkusTest
@TestSecurity(user = "pi", roles = "default-roles-orppst")
@TestSecurity(user="John Flamsteed", roles = "default-roles-orppst")
public class ProposalResourceTest {
String JSON_UTF16 = "application/json; charset=UTF-16";
@Inject
Expand All @@ -36,7 +36,7 @@ void setup() {
}));
proposalId = given()
.when()
.param("title", "%title")
.param("title", "Observing the stars")
.get("proposals")
.then()
.statusCode(200)
Expand All @@ -48,7 +48,7 @@ void setup() {
Integer coiInvestigatorId =
given()
.when()
.param("fullName", "CO-I")
.param("fullName", "George Airy")
.get("people")
.then()
.body(
Expand All @@ -75,7 +75,7 @@ void testGetObservingProposal() {
.then()
.statusCode(200)
.body(
containsString("\"title\":\"the proposal title\",")
containsString("\"title\":\"Observing the stars\",")
)
;

Expand All @@ -97,7 +97,7 @@ void testListSpecificProposal()
Integer relatedProposalId =
given()
.when()
.param("title","the proposal title")
.param("title","Observing the stars")
.get("proposals")
.then()
.statusCode(200)
Expand Down Expand Up @@ -132,28 +132,28 @@ void testReplaceJustification() throws JsonProcessingException {
void testReplaceTitle() {
//replace title with another
given()
.body("replacement title")
.body("Observing something else")
.header("Content-Type", MediaType.TEXT_PLAIN)
.when()
.put("proposals/"+proposalId+"/title")
.then()
.statusCode(201)
.body(
containsString("replacement title")
containsString("Observing something else")
)
;

}


@Test
void testAddPersonAsInvestigator() {
void testUpdateCoInvestigator() {
Investigator coiInvestigator = new Investigator(InvestigatorKind.COI, true, person);
//first get the DB id of the newly added COI Investigator
Integer coiInvestigatorId =
given()
.when()
.param("fullName", "CO-I")
.param("fullName", "George Airy")
.get("proposals/"+proposalId+"/investigators")
.then()
.body(
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/orph2020/pst/apiimpl/rest/UseCasePiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void testCreateProposal() throws JsonProcessingException {
//find the PI
int personid = given()
.when()
.param("name","PI")
.param("name","John Flamsteed")
.get("people")
.then()
.statusCode(200)
Expand All @@ -99,7 +99,7 @@ void testCreateProposal() throws JsonProcessingException {
.then()
.statusCode(200)
.body(
"fullName", equalTo("PI")
"fullName", equalTo("John Flamsteed")
).extract().as(Person.class, raObjectMapper);


Expand Down Expand Up @@ -138,7 +138,7 @@ void testCreateProposal() throws JsonProcessingException {
int coiPersonId =
given()
.when()
.param("name","CO-I")
.param("name","George Airy")
.get("people")
.then()
.statusCode(200)
Expand All @@ -155,7 +155,7 @@ void testCreateProposal() throws JsonProcessingException {
.then()
.statusCode(200)
.body(
"fullName", equalTo("CO-I")
"fullName", equalTo("George Airy")
).extract().as(Person.class, raObjectMapper);

//create a new Investigator
Expand Down Expand Up @@ -231,7 +231,7 @@ void testCreateProposal() throws JsonProcessingException {
Integer relatedProposalId =
given()
.when()
.param("title","%title%") // note only searching for title in part as other tests change this
.param("title","%Observing%") // note only searching for title in part as other tests change this
.get("proposals")
.then()
.statusCode(200)
Expand Down

0 comments on commit 08f9ffb

Please sign in to comment.