fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-lang] 09/49: Set upper limit on length so that application names can be saved in an SQL table.
Date Mon, 22 Jan 2018 15:01:04 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-lang.git

commit cefa08c7e871c78d8c43f77b2ae147030a9a2531
Author: myrle-krantz <mkrantz@mifos.org>
AuthorDate: Tue Apr 4 22:13:52 2017 +0200

    Set upper limit on length so that application names can be saved in an SQL table.
---
 src/main/java/io/mifos/core/lang/ApplicationName.java       |  4 ++++
 .../core/lang/validation/ValidApplicationNameTest.java      | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/main/java/io/mifos/core/lang/ApplicationName.java b/src/main/java/io/mifos/core/lang/ApplicationName.java
index d984eb6..c3da900 100644
--- a/src/main/java/io/mifos/core/lang/ApplicationName.java
+++ b/src/main/java/io/mifos/core/lang/ApplicationName.java
@@ -41,6 +41,10 @@ public class ApplicationName {
   }
 
   static ApplicationName parse(final String springApplicationNameString) {
+    if (springApplicationNameString.length() > 64) {
+      throw new IllegalArgumentException("Spring application name strings for mifos io applications
should be 64 characters or less.");
+    }
+
     final Pattern applicationNamePattern = Pattern.compile(
         "^(/??(?<name>\\p{Lower}[\\p{Lower}_]+)(?:-v(?<version>\\d[\\d\\._]*))?)$");
 
diff --git a/src/test/java/io/mifos/core/lang/validation/ValidApplicationNameTest.java b/src/test/java/io/mifos/core/lang/validation/ValidApplicationNameTest.java
index 31613d2..50481d7 100644
--- a/src/test/java/io/mifos/core/lang/validation/ValidApplicationNameTest.java
+++ b/src/test/java/io/mifos/core/lang/validation/ValidApplicationNameTest.java
@@ -44,6 +44,19 @@ public class ValidApplicationNameTest {
   }
 
   @Test
+  public void tooLongAppplicationName()
+  {
+    final StringBuilder stringBuilder = new StringBuilder();
+    for (int i = 0; i < 65 -3; i++) {
+      stringBuilder.append("b");
+    }
+    stringBuilder.append("-v1");
+
+    final AnnotatedClass annotatedInstance = new AnnotatedClass(stringBuilder.toString());
+    Assert.assertFalse(isValid(annotatedInstance));
+  }
+
+  @Test
   public void nullAppplicationName()
   {
     final AnnotatedClass annotatedInstance = new AnnotatedClass(null);

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message