You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/06/29 07:29:52 UTC

[isis] branch ISIS-2728 updated (4961c39 -> 70ec189)

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

danhaywood pushed a change to branch ISIS-2728
in repository https://gitbox.apache.org/repos/asf/isis.git.


 discard 4961c39  ISIS-2728: adds UserMemento#multiTenancyToken unit tests
 discard e275f35  ISIS-2728: adds multiTenancyToken into UserMemento
     add 84dac87  Merge pull request #646 from apache/ISIS-2733
     new 5ff019f  ISIS-2728: adds multiTenancyToken into UserMemento
     new 70ec189  ISIS-2728: adds UserMemento#multiTenancyToken unit tests

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (4961c39)
            \
             N -- N -- N   refs/heads/ISIS-2728 (70ec189)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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:

[isis] 01/02: ISIS-2728: adds multiTenancyToken into UserMemento

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

danhaywood pushed a commit to branch ISIS-2728
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 5ff019f9691e32aa21643df437dac43e3c5578a3
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 07:22:04 2021 +0100

    ISIS-2728: adds multiTenancyToken into UserMemento
---
 .../org/apache/isis/applib/services/user/UserMemento.java    | 12 ++++++++++--
 .../applib/services/user/UserMemento.layout.fallback.xml     |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
index 38825f7..4469a1e 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
@@ -183,7 +183,7 @@ public class UserMemento implements Serializable {
      * where the validity of the session is defined by headers in the request.
      */
     @Property
-    @PropertyLayout(fieldSetId = "authentication", sequence = "1")
+    @PropertyLayout(fieldSetId = "security", sequence = "1")
     @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
     @NonNull
     AuthenticationSource authenticationSource = AuthenticationSource.DEFAULT;
@@ -205,11 +205,18 @@ public class UserMemento implements Serializable {
 
 
     @Property(optionality = Optionality.OPTIONAL)
-    @PropertyLayout(fieldSetId = "authentication", sequence = "2")
+    @PropertyLayout(fieldSetId = "security", sequence = "2")
     @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
     boolean impersonating = false;
 
 
+    @Property(optionality = Optionality.OPTIONAL)
+    @PropertyLayout(fieldSetId = "security", sequence = "3")
+    @Getter @With(onMethod_ = {@Programmatic})
+    @Nullable
+    String multiTenancyToken;
+
+
     private static final String DEFAULT_AUTH_VALID_CODE = "";
 
     /**
@@ -282,6 +289,7 @@ public class UserMemento implements Serializable {
                 .avatarUrl(avatarUrl)
                 .impersonating(impersonating)
                 .realName(realName)
+                .multiTenancyToken(multiTenancyToken)
                 .roles(roles);
     }
 
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
index 1b2d386..abe976c 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
@@ -53,7 +53,7 @@ under the License.
                 </bs3:tab>
             </bs3:tabGroup>
             <cpt:fieldSet name="Details" id="details"/>
-            <cpt:fieldSet name="Authentication" id="authentication"/>
+            <cpt:fieldSet name="Security" id="security"/>
         </bs3:col>
         <bs3:col span="6">
             <cpt:collection id="roles"/>

[isis] 02/02: ISIS-2728: adds UserMemento#multiTenancyToken unit tests

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

danhaywood pushed a commit to branch ISIS-2728
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 70ec189f877b0197d02d7c8430a76c7f3b7473ed
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Jun 11 16:47:00 2021 +0100

    ISIS-2728: adds UserMemento#multiTenancyToken unit tests
---
 .../isis/applib/services/user/UserMemento.java     |  7 ++++++
 .../applib/services/user/UserMemento_Test.java     | 29 +++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
index 4469a1e..5b5c78b 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
@@ -210,6 +210,13 @@ public class UserMemento implements Serializable {
     boolean impersonating = false;
 
 
+    /**
+     * Indicates which tenancy (or tenancies) this user has access to.
+     *
+     * <p>
+     * The interpretation of this token is implementation-specific.
+     * </p>
+     */
     @Property(optionality = Optionality.OPTIONAL)
     @PropertyLayout(fieldSetId = "security", sequence = "3")
     @Getter @With(onMethod_ = {@Programmatic})
diff --git a/api/applib/src/test/java/org/apache/isis/applib/services/user/UserMemento_Test.java b/api/applib/src/test/java/org/apache/isis/applib/services/user/UserMemento_Test.java
index 504ac66..8cef9df 100644
--- a/api/applib/src/test/java/org/apache/isis/applib/services/user/UserMemento_Test.java
+++ b/api/applib/src/test/java/org/apache/isis/applib/services/user/UserMemento_Test.java
@@ -215,6 +215,29 @@ class UserMemento_Test {
     }
 
     @Nested
+    class withTenancyToken {
+
+        @Test
+        void user_and_roles_preserved_and_impersonating_flag_set() throws MalformedURLException {
+
+            // given
+            val userMemento = UserMemento.ofNameAndRoleNames("fredflintstone", "CAVEMAN", "HUSBAND");
+
+            // when
+            val userMemento2 = userMemento.withMultiTenancyToken("/ITA");
+
+            // then copy created
+            Assertions.assertThat(userMemento2).isNotSameAs(userMemento);
+
+            // then copy correct
+            Assertions.assertThat(userMemento2.getMultiTenancyToken()).isEqualTo("/ITA");
+
+            // then original unchanged
+            Assertions.assertThat(userMemento.getMultiTenancyToken()).isNull();
+        }
+    }
+
+    @Nested
     class all_the_withers {
 
         @Test
@@ -225,7 +248,9 @@ class UserMemento_Test {
                     .withRoleAdded("CAVEMAN")
                     .withRoleAdded("HUSBAND")
                     .withAvatarUrl(new java.net.URL("https://upload.wikimedia.org/wikipedia/en/a/ad/Fred_Flintstone.png"))
-                    .withRealName("Fred Flintstone");
+                    .withRealName("Fred Flintstone")
+                    .withMultiTenancyToken("/USA/Bedrock")
+                    ;
 
             // then
             Assertions.assertThat(userMemento.getName()).isEqualTo("fredflintstone");
@@ -250,6 +275,7 @@ class UserMemento_Test {
             Assertions.assertThat(userMemento2.getAvatarUrl()).isEqualTo(new java.net.URL("https://upload.wikimedia.org/wikipedia/en/a/ad/Fred_Flintstone.png"));
             Assertions.assertThat(userMemento2.getRealName()).isEqualTo("Fred Flintstone");
             Assertions.assertThat(userMemento2.isImpersonating()).isTrue();
+            Assertions.assertThat(userMemento2.getMultiTenancyToken()).isEqualTo("/USA/Bedrock");
 
             // then original unchanged
             Assertions.assertThat(userMemento.getName()).isEqualTo("fredflintstone");
@@ -259,6 +285,7 @@ class UserMemento_Test {
             Assertions.assertThat(userMemento.getAvatarUrl()).isEqualTo(new java.net.URL("https://upload.wikimedia.org/wikipedia/en/a/ad/Fred_Flintstone.png"));
             Assertions.assertThat(userMemento.getRealName()).isEqualTo("Fred Flintstone");
             Assertions.assertThat(userMemento.isImpersonating()).isFalse();
+            Assertions.assertThat(userMemento.getMultiTenancyToken()).isEqualTo("/USA/Bedrock");
 
         }
     }