Skip to content

Commit bde04c8

Browse files
authored
Merge pull request overture-stack#7 from overture-stack/hotfix/codacy-issues
Codacy recommended changes
2 parents ee10983 + 3440845 commit bde04c8

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

DockerFile

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ RUN apk add --no-cache curl tar bash \
1515
WORKDIR /usr/src/app
1616

1717
# copy just the pom.xml and install dependencies for caching
18-
ADD pom.xml .
18+
COPY pom.xml .
1919
RUN mvn verify clean --fail-never
2020

21-
ADD . .
21+
COPY . .
2222

2323
RUN mvn install -DskipTests
2424

src/main/java/bio/overture/microservicetemplate/controller/TestController.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package bio.overture.microservicetemplate.controller;
1818

19-
import bio.overture.microservicetemplate.jwt.JWTUser;
2019
import bio.overture.microservicetemplate.jwt.JWTFacadeInterface;
2120
import lombok.extern.slf4j.Slf4j;
2221
import lombok.val;
@@ -26,15 +25,14 @@
2625
import org.springframework.web.bind.annotation.RequestMapping;
2726
import org.springframework.web.bind.annotation.RestController;
2827

29-
import java.util.Optional;
3028

3129
@Slf4j
3230
@RestController
3331
@RequestMapping("/test")
3432
public class TestController {
3533

3634
@Autowired
37-
JWTFacadeInterface jwtFacade;
35+
private JWTFacadeInterface jwtFacade;
3836

3937
@GetMapping
4038
public String testGet() {

src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import lombok.SneakyThrows;
2020
import lombok.extern.slf4j.Slf4j;
2121
import lombok.val;
22-
import org.springframework.security.core.Authentication;
2322
import org.springframework.security.core.context.SecurityContextHolder;
2423
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
2524
import org.springframework.web.filter.GenericFilterBean;
@@ -44,7 +43,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
4443
val user = (JWTUser) details.getDecodedDetails();
4544

4645
boolean hasCorrectRole = user.getRoles().contains(REQUIRED_ROLE);
47-
boolean hasCorrectStatus = user.getStatus().toLowerCase().equals(REQUIRED_STATUS.toLowerCase());
46+
boolean hasCorrectStatus = user.getStatus().equalsIgnoreCase(REQUIRED_STATUS);
4847

4948
if(!hasCorrectRole || !hasCorrectStatus) {
5049
SecurityContextHolder.clearContext();

src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
@Data
2424
public class JWTUser {
2525

26-
String name;
27-
String firstName;
28-
String lastName;
29-
String email;
30-
String status;
31-
String createdAt;
32-
String lastLogin;
33-
String preferredLanguage;
34-
List<String> roles;
26+
private String name;
27+
private String firstName;
28+
private String lastName;
29+
private String email;
30+
private String status;
31+
private String createdAt;
32+
private String lastLogin;
33+
private String preferredLanguage;
34+
private List<String> roles;
3535

3636
}

src/test/java/bio/overture/microservicetemplate/MicroserviceTemplateApplicationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class MicroserviceTemplateApplicationTests {
2727

2828
@Test
2929
public void contextLoads() {
30+
// Passes if application starts
31+
assert(true);
3032
}
3133

3234
}

0 commit comments

Comments
 (0)