Skip to content

Commit 04bbd40

Browse files
authored
Merge branch 'develop' into bugfix-2642/member-role-controller-was-allowing-anonymous-security
2 parents b797ff8 + 3f5994d commit 04bbd40

File tree

5 files changed

+21
-105
lines changed

5 files changed

+21
-105
lines changed

README.md

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Gradle Build & Deploy - Develop](https://github.com/objectcomputing/check-ins/actions/workflows/gradle-build-development.yml/badge.svg)](https://github.com/objectcomputing/check-ins/actions/workflows/gradle-build-development.yml)
1+
[![Gradle Build & Deploy - Develop](https://github.com/objectcomputing/check-ins/actions/workflows/gradle-build-develop.yml/badge.svg)](https://github.com/objectcomputing/check-ins/actions/workflows/gradle-build-develop.yml)
22
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
33

44
<!-- TOC -->
@@ -29,99 +29,9 @@ This web application is written in [Micronaut](https://micronaut.io) for uploadi
2929

3030
See [Setting up your environment](https://objectcomputing.github.io/check-ins/getting-started/setup/) for instructions on setting up your development environment.
3131

32-
# Project setup
33-
34-
There are two files required to run the application successfully. Both of which must be created and placed in
35-
`src/main/resources/secrets`.
36-
37-
### directory.json
38-
39-
This is a simple JSON file containing the identifier for the Google Drive folder into which the uploaded files are to be deposited.
40-
41-
```json
42-
{
43-
"upload-directory-id": "GOOGLE_DRIVE_FOLDER_ID"
44-
}
45-
```
46-
47-
### credentials.json
48-
49-
This JSON file should create the generated credentials for a service account that has access to write to the identified Google Drive folder. Information on configuring GCP service account credentials can be [found here](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).
50-
51-
Note: Be sure that the target Google Drive folder has edit access granted to the service account.
52-
53-
<!-- the two required files are no longer needed -->
54-
5532
## Running the application
5633

57-
#### Installs
58-
59-
- [Podman](https://podman.io/)
60-
- [Podman-Compose](https://github.com/containers/podman-compose)
61-
62-
#### Building
63-
64-
1. Start the database in a Podman container:
65-
- Initialize and start a Podman VM:
66-
```shell
67-
$ podman machine init
68-
$ podman machine start
69-
```
70-
- Start the Podman container:
71-
```shell
72-
$ podman-compose up
73-
```
74-
2. In a different terminal, execute the following commands :
75-
76-
- On Bash/Zsh -
77-
78-
```sh
79-
$ OAUTH_CLIENT_ID=<Insert_Client_ID> OAUTH_CLIENT_SECRET=<Insert_Client_Secret> MICRONAUT_ENVIRONMENTS=local ./gradlew build
80-
```
81-
82-
```sh
83-
$ ./gradlew assemble
84-
```
85-
86-
```sh
87-
$ OAUTH_CLIENT_ID=<Insert_Client_ID> OAUTH_CLIENT_SECRET=<Insert_Client_Secret> MICRONAUT_ENVIRONMENTS=local ./gradlew run
88-
```
89-
90-
- On Powershell/Command-Line -
91-
Set the following environment variables -
92-
```sh
93-
MICRONAUT_ENVIRONMENTS=local
94-
OAUTH_CLIENT_ID=<Client_ID>
95-
OAUTH_CLIENT_SECRET=<Client_Secret>
96-
```
97-
Build and run the application -
98-
```sh
99-
$ gradlew build
100-
```
101-
```sh
102-
$ gradlew assemble
103-
```
104-
```sh
105-
$ gradlew run
106-
```
107-
108-
3. Open the browser to run the application at `http://localhost:8080`
109-
4. Access swagger-UI at - `http://localhost:8080/swagger-ui`
110-
111-
# Testing
112-
113-
1. To run the server tests, run the following:
114-
```sh
115-
$ ./gradlew :server:check
116-
```
117-
2. To run the UI tests, run the following:
118-
```sh
119-
$ ./gradlew :web-ui:check
120-
```
121-
3. To update snapshots, run the following:
122-
```sh
123-
$ cd web-ui && yarn test -u
124-
```
34+
See [Running the Application](https://objectcomputing.github.io/check-ins/getting-started/running/) for instructions on running the application locally.
12535

12636
# Contributing
12737

server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServices.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public interface ReviewAssignmentServices {
1616
void delete(UUID id);
1717
Set<ReviewAssignment> findAllByReviewPeriodIdAndReviewerId(UUID reviewPeriodId, @Nullable UUID reviewerId);
1818

19+
Set<ReviewAssignment> defaultReviewAssignments(UUID reviewPeriodId);
1920
}

server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ public Set<ReviewAssignment> findAllByReviewPeriodIdAndReviewerId(UUID reviewPer
8282
} else {
8383
reviewAssignments = reviewAssignmentRepository.findByReviewPeriodIdAndReviewerId(reviewPeriodId, reviewerId);
8484
}
85-
if (reviewAssignments.isEmpty()) {
86-
//If no assignments exist for the review period, then a set of default review assignments should be returned
87-
reviewAssignments = defaultReviewAssignments(reviewPeriodId);
88-
}
8985

9086
return reviewAssignments;
9187
}
@@ -109,7 +105,7 @@ public void delete(UUID id) {
109105
}
110106
}
111107

112-
private Set<ReviewAssignment> defaultReviewAssignments(UUID reviewPeriodId) {
108+
public Set<ReviewAssignment> defaultReviewAssignments(UUID reviewPeriodId) {
113109
Set<ReviewAssignment> reviewAssignments = new HashSet<>();
114110

115111
memberProfileRepository.findAll().forEach(memberProfile -> {

server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodController.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
public class ReviewPeriodController {
3434

3535
private final ReviewPeriodServices reviewPeriodServices;
36+
private final ReviewAssignmentServices reviewAssignmentServices;
3637

37-
public ReviewPeriodController(ReviewPeriodServices reviewPeriodServices) {
38+
public ReviewPeriodController(ReviewPeriodServices reviewPeriodServices, ReviewAssignmentServices reviewAssignmentServices) {
3839
this.reviewPeriodServices = reviewPeriodServices;
40+
this.reviewAssignmentServices = reviewAssignmentServices;
3941
}
4042

4143
/**
@@ -47,11 +49,17 @@ public ReviewPeriodController(ReviewPeriodServices reviewPeriodServices) {
4749
@Post
4850
@RequiredPermission(Permission.CAN_CREATE_REVIEW_PERIOD)
4951
public HttpResponse<ReviewPeriod> createReviewPeriod(@Body @Valid ReviewPeriodCreateDTO period, HttpRequest<?> request) {
52+
HttpResponse httpResponse;
53+
Set<ReviewAssignment> reviewAssignments;
54+
5055
ReviewPeriod reviewPeriod = reviewPeriodServices.save(period.convertToEntity());
51-
return HttpResponse.created(reviewPeriod)
56+
httpResponse = HttpResponse.created(reviewPeriod)
5257
.headers(headers -> headers
5358
.location(URI.create(String.format("%s/%s", request.getPath(), reviewPeriod.getId())))
5459
);
60+
reviewAssignments = reviewAssignmentServices.defaultReviewAssignments(reviewPeriod.getId());
61+
reviewAssignmentServices.saveAll(reviewPeriod.getId(), reviewAssignments.stream().toList(), true);
62+
return httpResponse;
5563
}
5664

5765
/**

server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentControllerTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void testGETFindAssignmentsByPeriodIdDefaultAssignments() {
146146

147147
final HttpResponse<Set<ReviewAssignment>> response = client.toBlocking().exchange(request, Argument.setOf(ReviewAssignment.class));
148148

149+
// A review period only has default review assignments added to it when
150+
// the review period is created through the controller. And, they are
151+
// no longer added to the review period when retrieving the review
152+
// assignments for a specific review period. Therefore, this review
153+
// period should have zero review assignments associated with it.
149154
assertNotNull(response.body());
150-
assertEquals(3, Objects.requireNonNull(response.body()).size());
151-
assertTrue(response.body().stream().anyMatch(ra -> ra.getRevieweeId().equals(memberOne.getId())));
152-
assertTrue(response.body().stream().anyMatch(ra -> ra.getRevieweeId().equals(memberTwo.getId())));
153-
assertTrue(response.body().stream().anyMatch(ra -> ra.getRevieweeId().equals(memberThree.getId())));
154-
assertEquals(HttpStatus.OK, response.getStatus());
155+
assertEquals(0, Objects.requireNonNull(response.body()).size());
155156
}
156157

157158
@Test
@@ -287,4 +288,4 @@ void deleteReviewAssignmentWithoutPermissions() {
287288
assertNotNull(responseException.getResponse());
288289
assertEquals(HttpStatus.FORBIDDEN, responseException.getStatus());
289290
}
290-
}
291+
}

0 commit comments

Comments
 (0)