You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2023/02/24 12:08:31 UTC

[syncope] branch master updated (45b7ca1294 -> 1ece2b2c55)

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


    from 45b7ca1294 More flexible assertions for SRA IT cases
     new aa207f24d8 WA: improving default mapping for AttrRelease policy
     new 1ece2b2c55 Even more flexible assertions for SRA IT cases

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/syncope/fit/sra/AbstractSRAITCase.java   |  6 +++---
 .../test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java  |  4 ++++
 .../syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java | 12 +++++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)


[syncope] 01/02: WA: improving default mapping for AttrRelease policy

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit aa207f24d848b504783be5a1ead8aecc3eae34ed
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Feb 24 12:40:40 2023 +0100

    WA: improving default mapping for AttrRelease policy
---
 .../syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java
index f7eb0b3e57..0a8334cbf9 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/mapping/DefaultAttrReleaseMapper.java
@@ -25,7 +25,7 @@ import org.apache.syncope.common.lib.policy.DefaultAttrReleasePolicyConf;
 import org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository;
 import org.apereo.cas.authentication.principal.cache.AbstractPrincipalAttributesRepository;
 import org.apereo.cas.authentication.principal.cache.CachingPrincipalAttributesRepository;
-import org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesCoreProperties;
+import org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesCoreProperties.MergingStrategyTypes;
 import org.apereo.cas.services.AbstractRegisteredServiceAttributeReleasePolicy;
 import org.apereo.cas.services.ChainingAttributeReleasePolicy;
 import org.apereo.cas.services.DenyAllAttributeReleasePolicy;
@@ -53,6 +53,7 @@ public class DefaultAttrReleaseMapper implements AttrReleaseMapper {
         ReturnAllowedAttributeReleasePolicy returnAllowed = null;
         if (!conf.getAllowedAttrs().isEmpty()) {
             returnAllowed = new ReturnAllowedAttributeReleasePolicy();
+            returnAllowed.setAllowedAttributes(conf.getAllowedAttrs());
         }
 
         AbstractRegisteredServiceAttributeReleasePolicy attributeReleasePolicy;
@@ -83,8 +84,7 @@ public class DefaultAttrReleaseMapper implements AttrReleaseMapper {
                     ? new CachingPrincipalAttributesRepository(parc.getTimeUnit().name(), parc.getExpiration())
                     : new DefaultPrincipalAttributesRepository();
 
-            par.setMergingStrategy(
-                    PrincipalAttributesCoreProperties.MergingStrategyTypes.valueOf(parc.getMergingStrategy().name()));
+            par.setMergingStrategy(MergingStrategyTypes.valueOf(parc.getMergingStrategy().name()));
             par.setIgnoreResolvedAttributes(par.isIgnoreResolvedAttributes());
             par.setAttributeRepositoryIds(new HashSet<>(parc.getAttrRepos()));
             attributeReleasePolicy.setPrincipalAttributesRepository(par);
@@ -93,6 +93,12 @@ public class DefaultAttrReleaseMapper implements AttrReleaseMapper {
         if (returnMapped != null && returnAllowed != null) {
             ChainingAttributeReleasePolicy chain = new ChainingAttributeReleasePolicy();
             chain.addPolicies(returnMapped, returnAllowed);
+
+            if (conf.getPrincipalAttrRepoConf() != null && !conf.getPrincipalAttrRepoConf().getAttrRepos().isEmpty()) {
+                DefaultAttrReleasePolicyConf.PrincipalAttrRepoConf parc = conf.getPrincipalAttrRepoConf();
+                chain.setMergingPolicy(MergingStrategyTypes.valueOf(parc.getMergingStrategy().name()));
+            }
+
             return chain;
         }
 


[syncope] 02/02: Even more flexible assertions for SRA IT cases

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 1ece2b2c55db31e84098065ded1e2a8f7b31e97e
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Feb 24 13:08:22 2023 +0100

    Even more flexible assertions for SRA IT cases
---
 .../src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java | 6 +++---
 .../src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java     | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
index 0b7beafbff..d0bb96a093 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
@@ -263,9 +263,9 @@ public abstract class AbstractSRAITCase extends AbstractITCase {
         assertEquals(MediaType.TEXT_HTML, headers.get(HttpHeaders.ACCEPT).asText());
         assertThat(headers.get("X-Forwarded-Host").asText(), is(oneOf("localhost:" + PORT, "127.0.0.1:" + PORT)));
 
-        assertEquals(
-                StringUtils.substringBefore(originalRequestURI, "?"),
-                StringUtils.substringBefore(json.get("url").asText(), "?"));
+        String withHost = StringUtils.substringBefore(originalRequestURI, "?");
+        String withIP = withHost.replace("localhost", "127.0.0.1");
+        assertThat(StringUtils.substringBefore(json.get("url").asText(), "?"), is(oneOf(withHost, withIP)));
 
         return headers;
     }
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
index fb27f5ef09..580b78ebd1 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
@@ -277,6 +277,10 @@ public class OIDCSRAITCase extends AbstractSRAITCase {
         assertEquals(MediaType.APPLICATION_JSON, headers.get(HttpHeaders.CONTENT_TYPE).asText());
         assertThat(headers.get("X-Forwarded-Host").asText(), is(oneOf("localhost:" + PORT, "127.0.0.1:" + PORT)));
 
+        String withHost = client.getBaseURI().toASCIIString().replace("/protected", "");
+        String withIP = withHost.replace("localhost", "127.0.0.1");
+        assertThat(json.get("url").asText(), is(oneOf(withHost, withIP)));
+
         assertEquals(client.getBaseURI().toASCIIString().replace("/protected", ""), json.get("url").asText());
     }
 }