Skip to content
Snippets Groups Projects
Commit d1e22813 authored by Xiangliang Meng's avatar Xiangliang Meng
Browse files

Squashed commit of the following

commit 3b78f329 
Author: David Meng <xlmeng@amazon.com> 
Date: Wed Jul 27 2022 17:04:01 GMT-0400 (Eastern Daylight Time) 

    Rename the field to avoid shadowing the parent class field; add an assertion to the test case; refactor the method isDomainAdminServiceAccount to remove the nested if statement.
parent f05152f7
No related branches found
No related tags found
2 merge requests!257Adding AWS Helm Charts,!252Refactor code to SonarQube standards
......@@ -28,8 +28,6 @@ import com.google.gson.Gson;
import javassist.NotFoundException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -55,7 +53,7 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
private static final Gson gson = new Gson();
@Autowired
private JaxRsDpsLog logger;
private JaxRsDpsLog jaxRsDpsLogger;
@ExceptionHandler(AppException.class)
protected ResponseEntity<Object> handleAppException(AppException e) {
......@@ -94,7 +92,7 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
@ExceptionHandler(ConstraintViolationException.class)
protected ResponseEntity<Object> handleConstraintValidationException(ConstraintViolationException e) {
logger.error("Validation exception", e);
jaxRsDpsLogger.error("Validation exception", e);
List<String> msgs = new ArrayList<>();
for (ConstraintViolation<?> violation : e.getConstraintViolations()) {
......@@ -134,9 +132,9 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
String exceptionMsg = e.getError().getMessage();
if (e.getError().getCode() > 499) {
this.logger.error(exceptionMsg, e);
this.jaxRsDpsLogger.error(exceptionMsg, e);
} else {
this.logger.warning(exceptionMsg, e);
this.jaxRsDpsLogger.warning(exceptionMsg, e);
}
return new ResponseEntity<>(gson.toJson(exceptionMsg), HttpStatus.resolve(e.getError().getCode()));
......
......@@ -82,6 +82,9 @@ public class PartitionApiTest {
public void should_return204_when_givenUpdatingValidPartitionId() {
String partitionId = "partition1";
this.sut.patch(partitionId, partitionInfo);
ResponseEntity<Map<String, Property>> result = this.sut.get(partitionId);
assertEquals(HttpStatus.OK, result.getStatusCode());
}
@Test
......
......@@ -79,19 +79,13 @@ public class AuthorizationService implements IAuthorizationService {
memberEmail = headers.getUserId();
if(memberEmail != null)
{
if(memberEmail.equals(spu_email)){
return true;
}
else{
throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal");
}
}
if(memberEmail == null){
throw AppException.createUnauthorized("Unauthorized. The JWT token could not be validated");
} else if(memberEmail.equals(spu_email)){
return true;
} else{
throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal");
}
}
catch (AppException appE) {
throw appE;
......@@ -99,11 +93,7 @@ public class AuthorizationService implements IAuthorizationService {
catch (Exception e) {
throw new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Authentication Failure", e.getMessage(), e);
}
return false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment