Skip to content

Commit

Permalink
Merged in feature/SHIBUI-1772 (pull request #471)
Browse files Browse the repository at this point in the history
Update and fix reporting errors (SHIBUI-1723), and Capitalization problem (SHIBUI-1756)
  • Loading branch information
Shad Vider authored and Jonathan Johnson committed Apr 20, 2021
2 parents cf2d4b3 + 9d60736 commit 900ce9b
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {

void constructXmlNodeForResolver(DynamicHttpMetadataResolver resolver, def markupBuilderDelegate, Closure childNodes) {
markupBuilderDelegate.MetadataProvider(id: resolver.xmlId,
'xsi:type': 'DynamicHttpMetadataProvider',
'xsi:type': 'DynamicHTTPMetadataProvider',
requireValidMetadata: !resolver.requireValidMetadata ?: null,
failFastInitialization: !resolver.failFastInitialization ?: null,
sortKey: resolver.sortKey,
Expand Down Expand Up @@ -559,4 +559,4 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpClientErrorException;

import java.util.ArrayList;
import java.util.List;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.NOT_FOUND;
Expand Down Expand Up @@ -60,6 +62,23 @@ public final ResponseEntity<ErrorResponse> metadataFileNotFoundHandler(MetadataF

@ExceptionHandler(JsonSchemaValidationFailedException.class)
public final ResponseEntity<?> handleJsonSchemaValidationFailedException(JsonSchemaValidationFailedException ex) {
return ResponseEntity.status(BAD_REQUEST).body(new ErrorResponse("400", String.join("\n", ex.getErrors())));
return ResponseEntity.status(BAD_REQUEST).body(new ErrorResponse("400", String.join("\n", flattenErrorsList(ex.getErrors()))));
}

private List<String> flattenErrorsList(List<Object> errors) {
List<String> theseErrors = new ArrayList<>();
processErrorsList(theseErrors, errors);
return theseErrors;
}

private static void processErrorsList(List<String> outputErrorList, Object errors){
if(errors instanceof String){
outputErrorList.add((String)errors);
}
else if(errors instanceof List){
for(Object error2:(List)errors){
processErrorsList(outputErrorList, error2);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public DigestMethod(String algorithm) {
@Nullable
@Override
public String getAlgorithm() {
return null;
return this.algorithm;
}

@Override
public void setAlgorithm(@Nullable String value) {

this.algorithm = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

@Entity
@EqualsAndHashCode(callSuper = true, exclude = {"storageAttributeMap"})
@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
public class RequestInitiator extends AbstractElementExtensibleXMLObject implements org.opensaml.saml.ext.saml2mdreqinit.RequestInitiator {
@EqualsAndHashCode.Include
private String binding;
@Override
public String getBinding() {
Expand All @@ -27,6 +29,7 @@ public void setBinding(String binding) {
this.binding = binding;
}

@EqualsAndHashCode.Include
private String location;

@Override
Expand All @@ -39,6 +42,7 @@ public void setLocation(String location) {
this.location = location;
}

@EqualsAndHashCode.Include
private String responseLocation;

@Override
Expand All @@ -57,6 +61,11 @@ public void setResponseLocation(String location) {
@Transient
private AttributeMap attributeMap = new AttributeMap(this);

@EqualsAndHashCode.Include
private Set<Map.Entry<QName, String>> attributeMapEntrySet() {
return this.attributeMap.entrySet();
}

@PrePersist
void prePersist() {
this.storageAttributeMap = this.attributeMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.internet2.tier.shibboleth.admin.ui.domain.frontend;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.constraints.NotNull;
Expand Down Expand Up @@ -38,10 +39,12 @@ public EntityDescriptorRepresentation(String id,
@NotNull
private String entityId;

private OrganizationRepresentation organization;
//TODO: review requirement
private OrganizationRepresentation organization = new OrganizationRepresentation();

private List<ContactRepresentation> contacts;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private MduiRepresentation mdui;

private ServiceProviderSsoDescriptorRepresentation serviceProviderSsoDescriptor;
Expand All @@ -58,8 +61,10 @@ public EntityDescriptorRepresentation(String id,

private LocalDateTime modifiedDate;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> relyingPartyOverrides;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<String> attributeRelease;

private int version;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package edu.internet2.tier.shibboleth.admin.ui.domain.frontend;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

public class OrganizationRepresentation implements Serializable {

private static final long serialVersionUID = 802722455433573538L;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String name;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String displayName;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String url;

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
@Getter
public class JsonSchemaValidationFailedException extends RuntimeException {

List<String> errors;
List errors;

JsonSchemaValidationFailedException(List<?> errors) {
this.errors = (List<String>) errors;
this.errors = errors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class EntitiesControllerIntegrationTests extends Specification {
this.webClient.webClient.uriBuilderFactory.encodingMode = DefaultUriBuilderFactory.EncodingMode.NONE
}*/

//todo review
def "GET /api/entities returns the proper json"() {
given:
def expectedBody = '''
Expand All @@ -54,7 +55,6 @@ class EntitiesControllerIntegrationTests extends Specification {
{"locationUrl":"https://test.scaldingspoon.org/test1/acs","binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","makeDefault":false}
],
"serviceEnabled":false,
"relyingPartyOverrides":{},
"attributeRelease":["givenName","employeeNumber"]
}
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ class EntitiesControllerTests extends Specification {
result.andExpect(status().isNotFound())
}

//todo review
def 'GET /api/entities/http%3A%2F%2Ftest.scaldingspoon.org%2Ftest1'() {
given:
def expectedBody = '''
{
"id":null,
"serviceProviderName":null,
"entityId":"http://test.scaldingspoon.org/test1",
"organization":null,
"organization": {},
"contacts":null,
"mdui":null,
"serviceProviderSsoDescriptor": {
"protocolSupportEnum":"SAML 2",
"nameIdFormats":["urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"]
Expand All @@ -94,8 +94,10 @@ class EntitiesControllerTests extends Specification {
"serviceEnabled":false,
"createdDate":null,
"modifiedDate":null,
"relyingPartyOverrides":{},
"attributeRelease":["givenName","employeeNumber"]
"attributeRelease":["givenName","employeeNumber"],
"version":-1891841119,
"createdBy":null,
"current":false
}
'''
when:
Expand Down
Loading

0 comments on commit 900ce9b

Please sign in to comment.