summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml4
-rw-r--r--src/main/docker/frontend/nginx/nginx.conf2
-rw-r--r--src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java7
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java4
-rw-r--r--src/main/resources/application.properties12
-rw-r--r--src/main/resources/clds/aaf/org.onap.clamp.keyfile54
-rw-r--r--src/main/resources/clds/aaf/org.onap.clamp.p12bin4107 -> 4147 bytes
-rw-r--r--src/main/resources/clds/aaf/ssl/clamp.key54
-rw-r--r--src/main/resources/clds/aaf/ssl/clamp.pem80
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java155
-rw-r--r--src/test/java/org/onap/clamp/clds/model/jsontype/JsonTypeDescriptorTest.java96
-rw-r--r--src/test/java/org/onap/clamp/loop/DcaeComponentTest.java61
-rw-r--r--src/test/java/org/onap/clamp/loop/ExternalComponentStateTest.java82
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java34
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyComponentTest.java246
-rw-r--r--ui-react/src/LoopUI.test.js171
-rw-r--r--ui-react/src/NotFound.test.js36
-rw-r--r--ui-react/src/OnapClamp.test.js36
-rw-r--r--ui-react/src/__snapshots__/LoopUI.test.js.snap154
-rw-r--r--ui-react/src/__snapshots__/NotFound.test.js.snap26
-rw-r--r--ui-react/src/__snapshots__/OnapClamp.test.js.snap176
-rw-r--r--version.properties2
22 files changed, 1343 insertions, 149 deletions
diff --git a/pom.xml b/pom.xml
index c0f31e933..cce555d90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.clamp</groupId>
<artifactId>clds</artifactId>
- <version>4.1.3-SNAPSHOT</version>
+ <version>4.1.4-SNAPSHOT</version>
<name>clamp</name>
@@ -397,7 +397,7 @@
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
- <version>2.1.10</version>
+ <version>2.1.15</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
diff --git a/src/main/docker/frontend/nginx/nginx.conf b/src/main/docker/frontend/nginx/nginx.conf
index 5bcac5cfc..e18c1e831 100644
--- a/src/main/docker/frontend/nginx/nginx.conf
+++ b/src/main/docker/frontend/nginx/nginx.conf
@@ -4,8 +4,10 @@ server {
ssl_protocols TLSv1.2;
ssl_certificate /etc/ssl/clamp.pem;
ssl_certificate_key /etc/ssl/clamp.key;
+ ssl_verify_client optional_no_ca;
location /restservices/clds/ {
proxy_pass https://clamp-backend:8443;
+ proxy_set_header X-SSL-Cert $ssl_client_escaped_cert;
}
location / {
diff --git a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
index cd141ae77..68544de67 100644
--- a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
+++ b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
@@ -46,6 +46,7 @@ import javax.servlet.http.HttpServletRequest;
import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.filter.CadiFilter;
+import org.onap.clamp.clds.util.ResourceFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
@@ -150,13 +151,17 @@ public class ClampCadiFilter extends CadiFilter {
X509Certificate cert = (X509Certificate) certificateFactory
.generateCertificate(new ByteArrayInputStream(
URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes()));
+ X509Certificate caCert = (X509Certificate) certificateFactory
+ .generateCertificate(new ByteArrayInputStream(ResourceFileUtil.getResourceAsString("clds/aaf/ssl/ca-certs.pem").getBytes()));
+
X509Certificate[] certifArray = ((X509Certificate[]) request
.getAttribute("javax.servlet.request.X509Certificate"));
if (certifArray == null) {
- certifArray = new X509Certificate[] { cert };
+ certifArray = new X509Certificate[] { cert, caCert };
request.setAttribute("javax.servlet.request.X509Certificate", certifArray);
} else {
certifArray[0] = cert;
+ certifArray[1] = caCert;
}
}
diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
index 9321423a9..44ee52262 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
@@ -52,6 +52,8 @@ public class PolicyComponent extends ExternalComponent {
"The policies defined have been created but NOT deployed on the policy engine", 50);
public static final ExternalComponentState SENT_AND_DEPLOYED = new ExternalComponentState("SENT_AND_DEPLOYED",
"The policies defined have been created and deployed on the policy engine", 10);
+ public static final ExternalComponentState UNKNOWN = new ExternalComponentState("UNKNOWN",
+ "The current status is not clear. Need to regresh the status to get the current status.", 0);
/**
* Default constructor.
@@ -62,7 +64,7 @@ public class PolicyComponent extends ExternalComponent {
* on by one, each time we increase the level we can't decrease it anymore.
* That's why it starts with the lowest one SENT_AND_DEPLOYED.
*/
- super(SENT_AND_DEPLOYED);
+ super(UNKNOWN);
}
@Override
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 64121c947..3ac6fa255 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -244,11 +244,11 @@ clamp.config.cadi.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
clamp.config.cadi.cadiLoglevel=DEBUG
clamp.config.cadi.cadiLatitude=10
clamp.config.cadi.cadiLongitude=10
-clamp.config.cadi.aafLocateUrl=https://10.0.0.106:31111
-clamp.config.cadi.cadiKeystorePassword=enc:V_kq_EwDNb4itWp_lYfDGXIWJzemHGkhkZOxAQI9IHs
-clamp.config.cadi.cadiTruststorePassword=enc:Mj0YQqNCUKbKq2lPp1kTFQWeqLxaBXKNwd5F1yB1ukf
-#clamp.config.cadi.oauthTokenUrl=https://AAF_LOCATE_URL/AAF_NS.token:2.0/token
-#clamp.config.cadi.oauthIntrospectUrll=https://AAF_LOCATE_URL/AAF_NS.introspect:2.0/introspect
+clamp.config.cadi.aafLocateUrl=https://aaf-locate:8095
+clamp.config.cadi.cadiKeystorePassword=enc:WWCxchk4WGBNSvuzLq3MLjMs5ObRybJtts5AI0XD1Vc
+clamp.config.cadi.cadiTruststorePassword=enc:iDnPBBLq_EMidXlMa1FEuBR8TZzYxrCg66vq_XfLHdJ
+clamp.config.cadi.oauthTokenUrl= https://AAF_LOCATE_URL/locate/onap.org.osaaf.aaf.token:2.1/token
+clamp.config.cadi.oauthIntrospectUrll=https://AAF_LOCATE_URL/locate/onap.org.osaaf.aaf.introspect:2.1/introspect
clamp.config.cadi.aafEnv=DEV
clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.service:2.1
-clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US
+clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US
diff --git a/src/main/resources/clds/aaf/org.onap.clamp.keyfile b/src/main/resources/clds/aaf/org.onap.clamp.keyfile
index 45cdcb602..c2521fc81 100644
--- a/src/main/resources/clds/aaf/org.onap.clamp.keyfile
+++ b/src/main/resources/clds/aaf/org.onap.clamp.keyfile
@@ -1,27 +1,27 @@
-HTQLJHUg5Du0VM7wHY5cBMTgupk6ujhSoAgx5BTHp9wt9CoWvD72ScIciyldEH9R2QZIL9ZvpVo0
-h2o-hSQueaVjPcIFUhVIl4HWmNC6I2YAlNkwy3VMl1g9otKaOTgo3ChsFUVq7ACIrcr2977wo4B_
-FeHa0lInuaLoEjHMP1fszTWYBBx9oY3K9s-9MQQyCo6bFV-4L733sPeE60j20FWoygUwvIqxp3Pc
-Bmnm1AtcrhGH0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Q2rteDUG1njr2R1_V_MyQuoJjdfbIkPG
+4eF0QzlSMdbkeprdQxSfV5YT-yPpkBxSsCMMM43sKm4Hy7_CUdvp4Iayrp3vtK3oYMuCGi6qTadz
+KzxfTf8meKan3eMZW4RLByyniH5nQnX_KGfBly05AmFyVH_j0fyOg-48kDhtEKeqmDnP4C01jOID
+Ip_AKaB6e0GwsHzVTLZOklHwu_qzsaTzchBOG_dJJju7bxY7qv78Pa92wZIP311gSCVbc-gxxbsR
+qI555twmYEoasFm4xz10OYDOkvM1E1Rtxu3ymRLZpe6AoyFBVzEW7Dncdw7O98dKcgrp8ZlQ_8Wg
+5zZH0Cic7xnIZ0bNZyQXw56CSUiXVWuwVY3e0djXP3F-FO5gP8VTxbpW4C0t6McXAOlvSEfFKxN7
+u6OBeOKwjrtHaJk2ghF8MUcpDXanhbAgHez9larGlscCkgvoRLNaRH9GIdSVgY3HtNhJRaJIq01S
+OGeBjC5J4o-nTrqRFkwyDAYcPL373eYX1dBFFVHR-4q50H9m_zMxZHXETafxzV4DT3Qi8Sxh3uaS
+ZX7mRaNaOE0uC1n87_IZ9WhrwIQaZng2lnd9yZ-4rx8fB8WA8KQzifzvHAcMb_HV10JWGaz5A2Rm
+EXDsfexQC6CqYg5rdzzlNWDPNlHy5ubyz7fRXZ99uIwBY9aJcvCXCiEXJkC6utj3NcXQrJmk \ No newline at end of file
diff --git a/src/main/resources/clds/aaf/org.onap.clamp.p12 b/src/main/resources/clds/aaf/org.onap.clamp.p12
index b3c69efea..dc24567b9 100644
--- a/src/main/resources/clds/aaf/org.onap.clamp.p12
+++ b/src/main/resources/clds/aaf/org.onap.clamp.p12
Binary files differ
diff --git a/src/main/resources/clds/aaf/ssl/clamp.key b/src/main/resources/clds/aaf/ssl/clamp.key
index fcf68bfa2..af847d59a 100644
--- a/src/main/resources/clds/aaf/ssl/clamp.key
+++ b/src/main/resources/clds/aaf/ssl/clamp.key
@@ -1,32 +1,32 @@
Bag Attributes
friendlyName: clamp@clamp.onap.org
- localKeyID: 54 69 6D 65 20 31 35 35 33 37 38 37 35 31 38 33 30 33
+ localKeyID: 54 69 6D 65 20 31 35 37 31 30 36 38 34 31 31 38 30 37
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
-MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC4nLg3HAYzgJTr
-C9WdZypwz0UzcQcCFXwEUUA8StwtMwx0OahJiEJRdFY6fmydq4MzFgZ6HQt/M7dY
-0l8phLHpGTVdrFMgW8yZer8bwNcSSiPVRy8j0s8lBHdR+KofG+yA19xg6lCYDX78
-yfeA2jZ52FhVWavyGHS4whWlw8T1EGbZZqXZCFgc7zHjUXuG1mo2ropppJkouf9g
-WEH2Vx16YiosgZzftRW1N3KJ7JozcEtS/j4w/pNyS7HOQDWWGTDk6Us4bt8Zg4gd
-1FeID0FmnEEGRKP+XscsGNwMd06MBsCAOutHkpFtS+UT3cr8xIKewL7uPq24X3ke
-W148togFAgMBAAECggEATncV+R5pKFS7dteV2IvzxvTh1cZxkxoslu0t3zJ2OKPc
-5D1pYK+QeGx5Be2cHru6TOlMoXRc4ZjKke8AUXY74/Y573GB91vtL0KznYkuIHDw
-oALcb153eqVWTbniHMzSjcSxv2N4E9iQo8L39oVI6CrjCIvPgFuSqMCdUNJPkVTI
-4nsarTfLK4fzi7IbWzi9JdE1QRNIxcCMcYJRnLZMdneMLBleR0UL82Xc2KOy5SEt
-zyKYCQ8zS247FKolnOrDkhKxXI5fzdDpRK5AQSsAykUPWlYq7pzKjY/dU9rMRohx
-YSltFjPZ3sQ3UKqqIqhZS+GoVuZoc925WyhViPsqtQKBgQDsL4LFfPWN8nnsusQp
-VR3T7HvvwXuEVAydlaJMwZU0cRYN+L7RHHjDoXZZrNJDIDzNoWnBLKRGx3mtLmgJ
-9Pa6SxN6Oc8oo6jzv2D59g1PVjNOMOYTCTb/2Xum4LMLaeeF57HkWxzeA3Ws47++
-gXwzQpbE90tp1Ys4uXD3Joivv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ck/LqEv9p3G069QheUMb
+ejGiCG+d+kN232e8Y4O/5KiYEE9tHU7gQCZc3Oj1AoGBAI2QyoAJlM0jREsEft7c
+L+5kcV+VulyMYEFycSy6KziUKxVh+VMk5Eo6UhXo6m4x37tg/D8uK/tkeJdWw00N
+dXLsUcDEacZyF8UfRsrscmiBURu0+9S/5+ncSX6s18HHGL7n2io+PX/ie2neO7q1
+fj50Aj03dg1TrgMTx2g6e85Y
-----END PRIVATE KEY-----
diff --git a/src/main/resources/clds/aaf/ssl/clamp.pem b/src/main/resources/clds/aaf/ssl/clamp.pem
index ccb0097df..22f4541a4 100644
--- a/src/main/resources/clds/aaf/ssl/clamp.pem
+++ b/src/main/resources/clds/aaf/ssl/clamp.pem
@@ -1,64 +1,32 @@
Bag Attributes
friendlyName: clamp@clamp.onap.org
- localKeyID: 54 69 6D 65 20 31 35 35 33 37 38 37 35 31 38 33 30 33
-subject=CN = clamp, emailAddress = , OU = clamp@clamp.onap.org, OU = OSAAF, O = ONAP, C = US
+ localKeyID: 54 69 6D 65 20 31 35 37 31 30 36 38 34 31 31 38 30 37
+subject=CN = clamp, emailAddress = mark.d.manager@people.osaaf.com, OU = clamp@clamp.onap.org:DEV, OU = OSAAF, O = ONAP, C = US
issuer=C = US, O = ONAP, OU = OSAAF, CN = intermediateCA_9
-----BEGIN CERTIFICATE-----
-MIIEKDCCAxCgAwIBAgIIWY+5kgf/UG4wDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
+MIIETDCCAzSgAwIBAgIIGF6ukzqwlGIwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp
-bnRlcm1lZGlhdGVDQV85MB4XDTE5MDMyMTE2MTY1OFoXDTIwMDMyMTE2MTY1OFow
-bDEOMAwGA1UEAwwFY2xhbXAxDzANBgkqhkiG9w0BCQEWADEdMBsGA1UECwwUY2xh
-bXBAY2xhbXAub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EPiYPI0Lr3Lsay1F7f6cvDT4+EYzBLMFuwCvpcnHgSMS
-4fFj2ROmUG2+CC23B88Q0WNxjLPq/CrmHZZBsqwruPJ0cSuCQxfshTQ6uZhcjtu8
-6TRYkIcL0x9r/AHP
------END CERTIFICATE-----
-Bag Attributes
- friendlyName: CN=intermediateCA_9,OU=OSAAF,O=ONAP,C=US
-subject=C = US, O = ONAP, OU = OSAAF, CN = intermediateCA_9
-
-issuer=OU = OSAAF, O = ONAP, C = US
-
------BEGIN CERTIFICATE-----
-MIIEdTCCAl2gAwIBAgIBBzANBgkqhkiG9w0BAQsFADAsMQ4wDAYDVQQLDAVPU0FB
-RjENMAsGA1UECgwET05BUDELMAkGA1UEBhMCVVMwHhcNMTgwODE3MTg1MTM3WhcN
-MjMwODE3MTg1MTM3WjBHMQswCQYDVQQGEwJVUzENMAsGA1UECgwET05BUDEOMAwG
-A1UECwwFT1NBQUYxGTAXBgNVBAMMEGludGVybWVkaWF0ZUNBXzkwggEiMA0GCSqG
-SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCv0HHUkba3uNtNI3jPKimUcd6RNwmhSCJL
-neMWpnjqp5/A+HCKyNsEaT4y177hNLmCm/aMm1u2JIfikc+8wEqLCSBBPz+P0h+d
-o+sZ7U+4oeQizdYYpEdzHJ2SieHHa8vtu80rU3nO2NEIkuYC20HcKSEtl8fFKsk3
-nqlhY+tGfYJPTXcDOQAO40BTcgat3C3uIJHkWJJ4RivunE4LEuRv9QyKgAw7rkJV
-v+f7guqpZlXy6dzAkuU7XULWcgo55MkZlssoiErMvEZJad5aWKvRY3g7qUjaQ6wO
-15wOAUoRBW96eeZZbytgn8kybcBy++Ue49gPtgm1MF/KlAsp0MD5AgMBAAGjgYYw
-gYMwHQYDVR0OBBYEFIH3mVsQuciM3vNSXupOaaBDPqzdMB8GA1UdIwQYMBaAFFNV
-M/JL69BRscF4msEoMXvv6u1JMBIGA1UdEwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/
-BAQ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xq7ErSknND60NYit8rz9lWDDrNNKVF+8iFpoTb17V8e3C
-----END CERTIFICATE-----
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
index 8745cc5d2..072d57712 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
@@ -23,10 +23,13 @@
package org.onap.clamp.clds.it;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.IOException;
import java.io.InputStream;
@@ -35,6 +38,7 @@ import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.NotAuthorizedException;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +48,6 @@ import org.mockito.Mockito;
import org.onap.clamp.clds.model.CldsInfo;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.clds.util.ResourceFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -66,15 +69,12 @@ public class CldsServiceItCase {
@Autowired
private CldsService cldsService;
- private String bpmnText;
- private String imageText;
- private String bpmnPropText;
- private String docText;
- private Authentication authentication;
- private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
private LoggingUtils util;
-
+ private SecurityContext securityContext = mock(SecurityContext.class);
+ private Authentication auth = Mockito.mock(Authentication.class);
+ private UserDetails userDetails = Mockito.mock(UserDetails.class);
+ private List<GrantedAuthority> authorityList = new LinkedList<GrantedAuthority>();
/**
* Setup the variable before the tests execution.
*
@@ -82,20 +82,6 @@ public class CldsServiceItCase {
*/
@Before
public void setupBefore() throws IOException {
- bpmnText = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/tca-template.xml");
- imageText = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/tca-img.xml");
- bpmnPropText = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-properties.json");
- docText = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/doc-text.yaml");
-
- authList.add(new SimpleGrantedAuthority("permission-type-cl-manage|dev|*"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|read"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|update"));
- authList.add(new SimpleGrantedAuthority("permission-type-template|dev|read"));
- authList.add(new SimpleGrantedAuthority("permission-type-template|dev|update"));
- authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl-event|dev|*"));
- authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
-
util = Mockito.mock(LoggingUtils.class);
Mockito.doNothing().when(util).entering(Matchers.any(HttpServletRequest.class), Matchers.any(String.class));
cldsService.setLoggingUtil(util);
@@ -104,12 +90,9 @@ public class CldsServiceItCase {
@Test
public void testCldsInfoNotAuthorized() {
- SecurityContext securityContext = Mockito.mock(SecurityContext.class);
- Authentication localAuth = Mockito.mock(Authentication.class);
- UserDetails userDetails = Mockito.mock(UserDetails.class);
Mockito.when(userDetails.getUsername()).thenReturn("admin");
- Mockito.when(securityContext.getAuthentication()).thenReturn(localAuth);
- Mockito.when(localAuth.getPrincipal()).thenReturn(userDetails);
+ Mockito.when(securityContext.getAuthentication()).thenReturn(auth);
+ Mockito.when(auth.getPrincipal()).thenReturn(userDetails);
cldsService.setSecurityContext(securityContext);
CldsInfo cldsInfo = cldsService.getCldsInfo();
@@ -121,7 +104,17 @@ public class CldsServiceItCase {
@Test
public void testCldsInfoAuthorized() throws Exception {
- SecurityContext securityContext = Mockito.mock(SecurityContext.class);
+ Authentication authentication;
+ List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
+ authList.add(new SimpleGrantedAuthority("permission-type-cl-manage|dev|*"));
+ authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|read"));
+ authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|update"));
+ authList.add(new SimpleGrantedAuthority("permission-type-template|dev|read"));
+ authList.add(new SimpleGrantedAuthority("permission-type-template|dev|update"));
+ authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
+ authList.add(new SimpleGrantedAuthority("permission-type-cl-event|dev|*"));
+ authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
+
Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
cldsService.setSecurityContext(securityContext);
@@ -138,4 +131,110 @@ public class CldsServiceItCase {
assertEquals(cldsInfo.getCldsVersion(), prop.getProperty("clds.version"));
assertEquals(cldsInfo.getUserName(), "admin");
}
+
+ @Test(expected = NotAuthorizedException.class)
+ public void isAuthorizedForVfTestNotAuthorized1() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test(expected = NotAuthorizedException.class)
+ public void isAuthorizedForVfTestNotAuthorized2() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|prod|*"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test(expected = NotAuthorizedException.class)
+ public void isAuthorizedForVfTestNotAuthorized3() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|testId2"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void isAuthorizedForVfTestNotAuthorized4() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ when(securityContext.getAuthentication()).thenReturn(null);
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test
+ public void isAuthorizedForVfTest1() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|*|*"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test
+ public void isAuthorizedForVfTest2() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test
+ public void isAuthorizedForVfTest3() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|testId"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test
+ public void isAuthorizedForVfTest4() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ authorityList.add(new SimpleGrantedAuthority("permission-type-filter-vf|*|testId"));
+ when((List<GrantedAuthority>)auth.getAuthorities()).thenReturn(authorityList);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+
+ cldsService.setSecurityContext(securityContext);
+ boolean res = cldsService.isAuthorizedForVf("testId");
+ assertThat(res).isTrue();
+ }
+
+ @Test
+ public void getUserIdTest() throws Exception {
+ when(userDetails.getUsername()).thenReturn("testName");
+ when(auth.getPrincipal()).thenReturn(userDetails);
+ when(securityContext.getAuthentication()).thenReturn(auth);
+
+ cldsService.setSecurityContext(securityContext);
+ assertThat(cldsService.getUserId()).isEqualTo("testName");
+ }
}
diff --git a/src/test/java/org/onap/clamp/clds/model/jsontype/JsonTypeDescriptorTest.java b/src/test/java/org/onap/clamp/clds/model/jsontype/JsonTypeDescriptorTest.java
new file mode 100644
index 000000000..560f54cf4
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/jsontype/JsonTypeDescriptorTest.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model.jsontype;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.JsonObject;
+
+import org.hibernate.HibernateException;
+import org.junit.Test;
+import org.onap.clamp.dao.model.jsontype.JsonTypeDescriptor;
+
+public class JsonTypeDescriptorTest {
+
+ private JsonTypeDescriptor descriptor = new JsonTypeDescriptor();
+
+ @Test
+ public void testFromString() {
+ JsonObject object = new JsonObject();
+ object.addProperty("one","oneValue");
+ JsonObject child = new JsonObject();
+ child.addProperty("two","twoValue");
+ object.add("child",child);
+
+ JsonObject jsonResult = descriptor.fromString("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}");
+
+ assertThat(jsonResult).isEqualTo(object);
+ }
+
+ @Test
+ public void testUnwrap() {
+ JsonObject res1 = descriptor.unwrap(null, null, null);
+ assertThat(res1).isNull();
+
+ JsonObject object = new JsonObject();
+ object.addProperty("one","oneValue");
+ JsonObject child = new JsonObject();
+ child.addProperty("two","twoValue");
+ object.add("child",child);
+ String res2 = descriptor.unwrap(object, String.class, null);
+ assertThat(res2.replace("\n", "").replace(" ", ""))
+ .isEqualTo("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}");
+
+ Object res3 = descriptor.unwrap(object, JsonObject.class, null);
+ String res3Str = ((String) res3).replace(" ", "").replace("\\n", "").replace("\\", "")
+ .replace("\"{", "{").replace("}\"", "}");
+ assertThat(res3Str).isEqualTo("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void testUnwrapExpectationThrown() {
+ JsonObject object = new JsonObject();
+ object.addProperty("one","oneValue");
+
+ descriptor.unwrap(object, Integer.class, null);
+ }
+
+ @Test
+ public void testWrap() {
+ JsonObject res1 = descriptor.wrap(null, null);
+ assertThat(res1).isNull();
+
+ JsonObject object = new JsonObject();
+ object.addProperty("one","oneValue");
+ JsonObject child = new JsonObject();
+ child.addProperty("two","twoValue");
+ object.add("child",child);
+ JsonObject res2 = descriptor.wrap("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}", null);
+ assertThat(res2).isEqualTo(object);
+ }
+
+ @Test(expected = HibernateException.class)
+ public void testWrapExpectationThrown() {
+ descriptor.wrap(1, null);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
index 0a3c1e167..557fdcecf 100644
--- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
@@ -31,9 +31,13 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.HashSet;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse;
import org.onap.clamp.loop.components.external.DcaeComponent;
+import org.onap.clamp.loop.components.external.ExternalComponentState;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
public class DcaeComponentTest {
@@ -90,4 +94,61 @@ public class DcaeComponentTest {
assertThat(unDeploymentPayload).isEqualTo(expectedPayload);
}
+ @Test
+ public void computeStateTest() throws IOException {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ Mockito.when(exchange2.getProperty("dcaeResponse")).thenReturn(null);
+
+ DcaeComponent dcae = new DcaeComponent();
+
+ // initial state
+ ExternalComponentState state = dcae.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("BLUEPRINT_DEPLOYED");
+
+ // OperationalType = install
+ DcaeOperationStatusResponse dcaeResponse = Mockito.mock(DcaeOperationStatusResponse.class);
+ Mockito.when(dcaeResponse.getOperationType()).thenReturn("install");
+
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("succeeded");
+ Mockito.when(exchange2.getProperty("dcaeResponse")).thenReturn(dcaeResponse);
+ ExternalComponentState state2 = dcae.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("MICROSERVICE_INSTALLED_SUCCESSFULLY");
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("processing");
+ ExternalComponentState state3 = dcae.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("PROCESSING_MICROSERVICE_INSTALLATION");
+
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("failed");
+ ExternalComponentState state4 = dcae.computeState(exchange);
+ assertThat(state4.getStateName()).isEqualTo("MICROSERVICE_INSTALLATION_FAILED");
+
+ // OperationalType = uninstall
+ Mockito.when(dcaeResponse.getOperationType()).thenReturn("uninstall");
+
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("succeeded");
+ Mockito.when(exchange2.getProperty("dcaeResponse")).thenReturn(dcaeResponse);
+ ExternalComponentState state5 = dcae.computeState(exchange);
+ assertThat(state5.getStateName()).isEqualTo("MICROSERVICE_UNINSTALLED_SUCCESSFULLY");
+
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("processing");
+ ExternalComponentState state6 = dcae.computeState(exchange);
+ assertThat(state6.getStateName()).isEqualTo("PROCESSING_MICROSERVICE_UNINSTALLATION");
+
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("failed");
+ ExternalComponentState state7 = dcae.computeState(exchange);
+ assertThat(state7.getStateName()).isEqualTo("MICROSERVICE_UNINSTALLATION_FAILED");
+
+ // error cases
+ Mockito.when(dcaeResponse.getOperationType()).thenReturn("whatever");
+ ExternalComponentState state8 = dcae.computeState(exchange);
+ assertThat(state8.getStateName()).isEqualTo("IN_ERROR");
+
+ Mockito.when(dcaeResponse.getOperationType()).thenReturn("install");
+ Mockito.when(dcaeResponse.getStatus()).thenReturn("anythingelse");
+ ExternalComponentState state9 = dcae.computeState(exchange);
+ assertThat(state9.getStateName()).isEqualTo("IN_ERROR");
+ }
}
diff --git a/src/test/java/org/onap/clamp/loop/ExternalComponentStateTest.java b/src/test/java/org/onap/clamp/loop/ExternalComponentStateTest.java
new file mode 100644
index 000000000..34fcc077f
--- /dev/null
+++ b/src/test/java/org/onap/clamp/loop/ExternalComponentStateTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+import org.onap.clamp.loop.components.external.ExternalComponentState;
+
+public class ExternalComponentStateTest {
+ private ExternalComponentState state = new ExternalComponentState("NOT_SENT",
+ "The policies defined have NOT yet been created on the policy engine", 90);
+
+ @Test
+ public void generalTest() {
+ assertThat(state.toString()).isEqualTo("NOT_SENT");
+ state.setLevel(70);
+ assertThat(state.getLevel()).isEqualTo(70);
+ }
+
+ @Test
+ public void equalsTest() {
+ assertThat(state.equals(null)).isEqualTo(false);
+
+ ExternalComponentState state2 = new ExternalComponentState("NOT_SENT",
+ "The policies defined have NOT yet been created on the policy engine", 90);
+ assertThat(state.equals(state2)).isEqualTo(true);
+
+ assertThat(state.equals(12)).isEqualTo(false);
+
+ state2.setLevel(70);
+ assertThat(state.equals(state2)).isEqualTo(true);
+
+ ExternalComponentState state3 = new ExternalComponentState("SENT",
+ "The policies defined have NOT yet been created on the policy engine", 90);
+ assertThat(state.equals(state3)).isEqualTo(false);
+
+ ExternalComponentState state4 = new ExternalComponentState(null,
+ "The policies defined have NOT yet been created on the policy engine", 90);
+ ExternalComponentState state5 = new ExternalComponentState(null,
+ "The policies defined have NOT yet been", 50);
+ assertThat(state4.equals(state3)).isEqualTo(false);
+ assertThat(state4.equals(state5)).isEqualTo(true);
+ }
+
+ @Test
+ public void compareToTest() {
+ ExternalComponentState state2 = new ExternalComponentState("NOT_SENT",
+ "The policies defined have NOT yet been created on the policy engine", 90);
+ assertThat(state.compareTo(state2)).isEqualTo(0);
+
+ ExternalComponentState state3 = new ExternalComponentState("SENT",
+ "The policies defined have NOT yet been created on the policy engine", 50);
+ assertThat(state.compareTo(state3)).isEqualTo(1);
+
+ ExternalComponentState state4 = new ExternalComponentState(null,
+ "The policies defined have NOT yet been created on the policy engine", 100);
+ assertThat(state.compareTo(state4)).isEqualTo(-1);
+
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index 8add1a7be..1fedc9abe 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -319,6 +319,40 @@ public class LoopServiceTestItCase {
assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse();
}
+ @Test
+ @Transactional
+ public void testUpdateLoopState() {
+ saveTestLoopToDb();
+ Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME);
+ loopService.updateLoopState(loop, "SUBMITTED");
+ Loop updatedLoop = loopService.getLoop(EXAMPLE_LOOP_NAME);
+ assertThat(updatedLoop.getLastComputedState()).isEqualTo(LoopState.SUBMITTED);
+ }
+
+ @Test
+ @Transactional
+ public void testUpdateDcaeDeploymentFields() {
+ saveTestLoopToDb();
+ Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME);
+ loopService.updateDcaeDeploymentFields(loop,"CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85",
+ "https4://deployment-handler.onap:8443");
+ loop = loopService.getLoop(EXAMPLE_LOOP_NAME);
+ assertThat(loop.getDcaeDeploymentId()).isEqualTo("CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85");
+ assertThat(loop.getDcaeDeploymentStatusUrl()).isEqualTo("https4://deployment-handler.onap:8443");
+ }
+
+ @Test
+ @Transactional
+ public void testUpdateMicroservicePolicy() {
+ saveTestLoopToDb();
+ assertThat(microServicePolicyService.isExisting("policyName")).isFalse();
+ MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "",
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy);
+ assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
+ }
+
private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) {
return new Loop(loopName, loopBlueprint, loopSvg);
}
diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
new file mode 100644
index 000000000..e822dfb1a
--- /dev/null
+++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
@@ -0,0 +1,246 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.clamp.loop.components.external.ExternalComponentState;
+import org.onap.clamp.loop.components.external.PolicyComponent;
+
+public class PolicyComponentTest {
+
+ /**
+ * Test the computeState method.
+ * oldState newState expectedFinalState
+ * NOT_SENT SENT_AND_DEPLOYED NOT_SENT
+ * NOT_SENT SENT NOT_SENT
+ * NOT_SENT NOT_SENT NOT_SENT
+ * NOT_SENT IN_ERROR IN_ERROR
+ */
+ @Test
+ public void computeStateTestOriginalStateUnknown() {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ // policy found + deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ PolicyComponent policy = new PolicyComponent();
+
+ ExternalComponentState state = policy.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("SENT_AND_DEPLOYED");
+ // policy found + not deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state2 = policy.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("SENT");
+ // policy not found + not deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state4 = policy.computeState(exchange);
+ assertThat(state4.getStateName()).isEqualTo("NOT_SENT");
+ // policy not found + deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state3 = policy.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("IN_ERROR");
+ }
+ /**
+ * Test the computeState method.
+ * oldState newState expectedFinalState
+ * NOT_SENT SENT_AND_DEPLOYED NOT_SENT
+ * NOT_SENT SENT NOT_SENT
+ * NOT_SENT NOT_SENT NOT_SENT
+ * NOT_SENT IN_ERROR IN_ERROR
+ */
+ @Test
+ public void computeStateTestOriginalStateNotSent() {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ // policy found + deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ PolicyComponent policy = new PolicyComponent();
+ ExternalComponentState notSent = new ExternalComponentState("NOT_SENT",
+ "The policies defined have NOT yet been created on the policy engine", 90);
+ policy.setState(notSent);
+ ExternalComponentState state = policy.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("NOT_SENT");
+ // policy found + not deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state2 = policy.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("NOT_SENT");
+ // policy not found + not deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state4 = policy.computeState(exchange);
+ assertThat(state4.getStateName()).isEqualTo("NOT_SENT");
+ // policy not found + deployed
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state3 = policy.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("IN_ERROR");
+ }
+
+
+ /**
+ * Test the computeState method.
+ * oldState newState expectedFinalState
+ * SENT SENT SENT
+ * SENT SENT_AND_DEPLOYED SENT
+ * SENT IN_ERROR IN_ERROR
+ * SENT NOT_SENT NOT_SENT
+ */
+ @Test
+ public void computeStateTestOriginalStateSent() throws IOException {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ PolicyComponent policy = new PolicyComponent();
+ ExternalComponentState sent = new ExternalComponentState("SENT",
+ "The policies defined have been created but NOT deployed on the policy engine", 50);
+ policy.setState(sent);
+ // new policy state SENT
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state = policy.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("SENT");
+ // new policy state SENT_AND_DEPLOYED
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state2 = policy.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("SENT");
+ // new policy state IN_ERROR
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state3 = policy.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("IN_ERROR");
+ // new policy state NOT_SENT
+ policy.setState(sent);
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state4 = policy.computeState(exchange);
+ assertThat(state4.getStateName()).isEqualTo("NOT_SENT");
+ }
+
+ /**
+ * Test the computeState method.
+ * oldState newState expectedFinalState
+ * SENT_AND_DEPLOYED SENT_AND_DEPLOYED SENT_AND_DEPLOYED
+ * SENT_AND_DEPLOYED SENT SENT
+ * SENT_AND_DEPLOYED IN_ERROR IN_ERROR
+ * SENT_AND_DEPLOYED NOT_SENT NOT_SENT
+ */
+ @Test
+ public void computeStateTestOriginalStateSentAndDeployed() throws IOException {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ PolicyComponent policy = new PolicyComponent();
+ ExternalComponentState sendDeployed = new ExternalComponentState("SENT_AND_DEPLOYED",
+ "The policies defined have been created and deployed on the policy engine", 10);
+ policy.setState(sendDeployed);
+ // new policy state SENT_AND_DEPLOYED
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state = policy.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("SENT_AND_DEPLOYED");
+ // new policy state SENT
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state2 = policy.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("SENT");
+ // new policy state IN_ERROR
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state3 = policy.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("IN_ERROR");
+ // new policy state NOT_SENT
+ policy.setState(sendDeployed);
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state4 = policy.computeState(exchange);
+ assertThat(state4.getStateName()).isEqualTo("NOT_SENT");
+ }
+
+
+ /**
+ * Test the computeState method.
+ * oldState newState expectedFinalState
+ * IN_ERROR SENT_AND_DEPLOYED IN_ERROR
+ * IN_ERROR SENT IN_ERROR
+ * IN_ERROR IN_ERROR IN_ERROR
+ * IN_ERROR NOT_SENT IN_ERROR
+ */
+ @Test
+ public void computeStateTestOriginalStateInError() throws IOException {
+ Exchange exchange = Mockito.mock(Exchange.class);
+ Message message = Mockito.mock(Message.class);
+ Exchange exchange2 = Mockito.mock(Exchange.class);
+ Mockito.when(exchange.getIn()).thenReturn(message);
+ Mockito.when(message.getExchange()).thenReturn(exchange2);
+ PolicyComponent policy = new PolicyComponent();
+ ExternalComponentState inError = new ExternalComponentState("IN_ERROR",
+ "There was an error during the sending to policy, the policy engine may be corrupted or inconsistent",
+ 100);
+ policy.setState(inError);
+ // new policy state SENT_AND_DEPLOYED
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state = policy.computeState(exchange);
+ assertThat(state.getStateName()).isEqualTo("IN_ERROR");
+ // new policy state SENT
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(true);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state2 = policy.computeState(exchange);
+ assertThat(state2.getStateName()).isEqualTo("IN_ERROR");
+ // new policy state IN_ERROR
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(true);
+ ExternalComponentState state3 = policy.computeState(exchange);
+ assertThat(state3.getStateName()).isEqualTo("IN_ERROR");
+ // new policy state NOT_SENT
+ Mockito.when(exchange2.getProperty("policyFound")).thenReturn(false);
+ Mockito.when(exchange2.getProperty("policyDeployed")).thenReturn(false);
+ ExternalComponentState state4 = policy.computeState(exchange);
+
+ assertThat(state4.getStateName()).isEqualTo("IN_ERROR");
+ }
+}
diff --git a/ui-react/src/LoopUI.test.js b/ui-react/src/LoopUI.test.js
new file mode 100644
index 000000000..e28096bd4
--- /dev/null
+++ b/ui-react/src/LoopUI.test.js
@@ -0,0 +1,171 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import LoopUI from './LoopUI';
+
+import LoopCache from './api/LoopCache';
+import LoopActionService from './api/LoopActionService';
+import LoopService from './api/LoopService';
+
+describe('Verify LoopUI', () => {
+ beforeEach(() => {
+ fetch.resetMocks();
+ fetch.mockImplementation(() => {
+ return Promise.resolve({
+ ok: true,
+ status: 200,
+ text: () => "testUser"
+
+ });
+ });
+ })
+
+ const loopCache = new LoopCache({
+ "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca",
+ "components": {
+ "POLICY": {
+ "componentState": {
+ "stateName": "UNKNOWN",
+ "description": "The policies defined have NOT yet been created on the policy engine"
+ }
+ },
+ "DCAE": {
+ "componentState": {
+ "stateName": "BLUEPRINT_DEPLOYED",
+ "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
+ }
+ }
+ }
+ });
+
+ it('Test the render method', async () => {
+ const flushPromises = () => new Promise(setImmediate);
+
+ const component = shallow(<LoopUI />)
+ component.setState({
+ loopName: "testLoopName",
+ showAlert: false
+ });
+ await flushPromises();
+ expect(component).toMatchSnapshot();
+ });
+
+ test('Test closeLoop method', () => {
+ const historyMock = { push: jest.fn() };
+ const component = shallow(<LoopUI history={historyMock}/>)
+ const instance = component.instance();
+ instance.closeLoop();
+
+ expect(component.state('loopName')).toEqual("Empty (NO loop loaded yet)");
+ expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
+ })
+
+ test('Test logout method', async () => {
+ const flushPromises = () => new Promise(setImmediate);
+ const component = shallow(<LoopUI />)
+ const instance = component.instance();
+ instance.logout();
+ await flushPromises();
+ expect(component.state('userName')).toEqual("testUser");
+ })
+
+ test('Test loadLoop method refresh suc', async () => {
+ const historyMock = { push: jest.fn() };
+ LoopService.getLoop = jest.fn().mockImplementation(() => {
+ return Promise.resolve({
+ ok: true,
+ status: 200,
+ text: () => {}
+ });
+ });
+
+ LoopActionService.refreshStatus = jest.fn().mockImplementation(() => {
+ return Promise.resolve({name: "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca"});
+ });
+
+ const flushPromises = () => new Promise(setImmediate);
+ const component = shallow(<LoopUI history={historyMock}/>)
+ const instance = component.instance();
+ instance.loadLoop("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
+
+ await flushPromises();
+
+ const resLoopCache = instance.getLoopCache();
+
+ expect(resLoopCache.getComponentStates()).toBeUndefined();
+ expect(component.state('loopName')).toEqual("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
+ })
+
+ test('Test loadLoop method refresh fail', async () => {
+ const historyMock = { push: jest.fn() };
+ LoopService.getLoop = jest.fn().mockImplementation(() => {
+ return Promise.resolve({
+ name: "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca",
+ "components": {
+ "POLICY": {
+ "componentState": {
+ "stateName": "UNKNOWN",
+ "description": "The policies defined have NOT yet been created on the policy engine"
+ }
+ },
+ "DCAE": {
+ "componentState": {
+ "stateName": "BLUEPRINT_DEPLOYED",
+ "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
+ }
+ }
+ }});
+ });
+
+ LoopActionService.refreshStatus = jest.fn().mockImplementation(() => {
+ return Promise.reject({error: "whatever"});
+ });
+
+ const flushPromises = () => new Promise(setImmediate);
+ const component = shallow(<LoopUI history={historyMock}/>)
+ const instance = component.instance();
+ instance.loadLoop("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
+
+ await flushPromises();
+
+ const resLoopCache = instance.getLoopCache();
+
+ expect(resLoopCache).toEqual(loopCache);
+ expect(component.state('loopName')).toEqual("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
+ })
+
+ test('Test alert methods', () => {
+ const component = shallow(<LoopUI />)
+ expect(component.state('showAlert')).toEqual(false);
+
+ const instance = component.instance();
+ instance.showAlert("testAlert");
+ expect(component.state('showAlert')).toEqual(true);
+ expect(component.state('showMessage')).toEqual("testAlert");
+
+ instance.disableAlert();
+
+ expect(component.state('showAlert')).toEqual(false);
+ })
+});
diff --git a/ui-react/src/NotFound.test.js b/ui-react/src/NotFound.test.js
new file mode 100644
index 000000000..3a5fc107d
--- /dev/null
+++ b/ui-react/src/NotFound.test.js
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import NotFound from './NotFound';
+
+describe('Verify OnapClamp', () => {
+
+ it('Test the render method', () => {
+
+ const component = shallow(<NotFound />)
+
+ expect(component).toMatchSnapshot();
+ });
+
+});
diff --git a/ui-react/src/OnapClamp.test.js b/ui-react/src/OnapClamp.test.js
new file mode 100644
index 000000000..c3336a9ab
--- /dev/null
+++ b/ui-react/src/OnapClamp.test.js
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import OnapClamp from './OnapClamp';
+
+describe('Verify OnapClamp', () => {
+
+ it('Test the render method', () => {
+
+ const component = shallow(<OnapClamp />)
+
+ expect(component).toMatchSnapshot();
+ });
+
+});
diff --git a/ui-react/src/__snapshots__/LoopUI.test.js.snap b/ui-react/src/__snapshots__/LoopUI.test.js.snap
new file mode 100644
index 000000000..ecf439e4e
--- /dev/null
+++ b/ui-react/src/__snapshots__/LoopUI.test.js.snap
@@ -0,0 +1,154 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Verify LoopUI Test the render method 1`] = `
+<styled.div
+ id="main_div"
+>
+ <Route
+ path="/operationalPolicyModal"
+ render={[Function]}
+ />
+ <Route
+ path="/configurationPolicyModal/:componentName"
+ render={[Function]}
+ />
+ <Route
+ path="/openLoop"
+ render={[Function]}
+ />
+ <Route
+ path="/loopProperties"
+ render={[Function]}
+ />
+ <Route
+ path="/userInfo"
+ render={[Function]}
+ />
+ <Route
+ path="/closeLoop"
+ render={[Function]}
+ />
+ <Route
+ path="/submit"
+ render={[Function]}
+ />
+ <Route
+ path="/stop"
+ render={[Function]}
+ />
+ <Route
+ path="/restart"
+ render={[Function]}
+ />
+ <Route
+ path="/delete"
+ render={[Function]}
+ />
+ <Route
+ path="/undeploy"
+ render={[Function]}
+ />
+ <Route
+ path="/deploy"
+ render={[Function]}
+ />
+ <Route
+ path="/refreshStatus"
+ render={[Function]}
+ />
+ <Route
+ path="/logout"
+ render={[Function]}
+ />
+ <GlobalStyleComponent />
+ <Alert
+ closeLabel="Close alert"
+ dismissible={true}
+ onClose={[Function]}
+ show={false}
+ transition={
+ Object {
+ "$$typeof": Symbol(react.forward_ref),
+ "defaultProps": Object {
+ "appear": false,
+ "in": false,
+ "mountOnEnter": false,
+ "timeout": 300,
+ "unmountOnExit": false,
+ },
+ "displayName": "Fade",
+ "render": [Function],
+ }
+ }
+ variant="danger"
+ />
+ <Navbar
+ collapseOnSelect={false}
+ expand={true}
+ variant="light"
+ >
+ <NavbarBrand>
+ <img
+ alt=""
+ height="50px"
+ src={null}
+ width="234px"
+ />
+ <styled.a>
+ CLAMP
+ </styled.a>
+ </NavbarBrand>
+ <NavbarToggle
+ aria-controls="responsive-navbar-nav"
+ label="Toggle navigation"
+ />
+ <MenuBar
+ loopName="testLoopName"
+ />
+ <NavbarText>
+ <styled.a>
+ Signed in as:
+ </styled.a>
+ <Styled(Link)
+ to="/userInfo"
+ >
+ testUser
+ </Styled(Link)>
+ <Styled(Link)
+ to="/logout/"
+ >
+ (logout)
+ </Styled(Link)>
+ </NavbarText>
+ </Navbar>
+ <styled.div>
+ <styled.div>
+ Loop Viewer -
+ testLoopName
+ </styled.div>
+ <styled.div>
+ <withRouter(LoopViewSvg)
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ <LoopStatus
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ <LoopLogs
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ </styled.div>
+ </styled.div>
+</styled.div>
+`;
diff --git a/ui-react/src/__snapshots__/NotFound.test.js.snap b/ui-react/src/__snapshots__/NotFound.test.js.snap
new file mode 100644
index 000000000..86bcfd1c4
--- /dev/null
+++ b/ui-react/src/__snapshots__/NotFound.test.js.snap
@@ -0,0 +1,26 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Verify OnapClamp Test the render method 1`] = `
+<div
+ id="main"
+>
+ <div
+ class="divRow"
+ >
+ <b>
+ Page Not Found!
+ </b>
+ </div>
+ <div
+ class="divRow"
+ >
+ Please cick
+ <a
+ href="/"
+ >
+ here
+ </a>
+ to go back to the main page.
+ </div>
+</div>
+`;
diff --git a/ui-react/src/__snapshots__/OnapClamp.test.js.snap b/ui-react/src/__snapshots__/OnapClamp.test.js.snap
new file mode 100644
index 000000000..751c94b3b
--- /dev/null
+++ b/ui-react/src/__snapshots__/OnapClamp.test.js.snap
@@ -0,0 +1,176 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Verify OnapClamp Test the render method 1`] = `
+<ThemeProvider
+ theme={
+ Object {
+ "backgroundColor": "#eeeeee",
+ "fontDanger": "#eb238e",
+ "fontDark": "#888888",
+ "fontFamily": "Arial, Sans-serif",
+ "fontHighlight": "#ffff00",
+ "fontLight": "#ffffff",
+ "fontNormal": "black",
+ "fontSize": "16px",
+ "fontWarning": "#eb238e",
+ "loopViewerBackgroundColor": "white",
+ "loopViewerFontColor": "yellow",
+ "loopViewerHeaderBackgroundColor": "#337ab7",
+ "loopViewerHeaderFontColor": "white",
+ "menuBackgroundColor": "white",
+ "menuFontColor": "black",
+ "menuHighlightedBackgroundColor": "#337ab7",
+ "menuHighlightedFontColor": "white",
+ }
+ }
+>
+ <styled.div
+ id="main_div"
+ >
+ <Route
+ path="/operationalPolicyModal"
+ render={[Function]}
+ />
+ <Route
+ path="/configurationPolicyModal/:componentName"
+ render={[Function]}
+ />
+ <Route
+ path="/openLoop"
+ render={[Function]}
+ />
+ <Route
+ path="/loopProperties"
+ render={[Function]}
+ />
+ <Route
+ path="/userInfo"
+ render={[Function]}
+ />
+ <Route
+ path="/closeLoop"
+ render={[Function]}
+ />
+ <Route
+ path="/submit"
+ render={[Function]}
+ />
+ <Route
+ path="/stop"
+ render={[Function]}
+ />
+ <Route
+ path="/restart"
+ render={[Function]}
+ />
+ <Route
+ path="/delete"
+ render={[Function]}
+ />
+ <Route
+ path="/undeploy"
+ render={[Function]}
+ />
+ <Route
+ path="/deploy"
+ render={[Function]}
+ />
+ <Route
+ path="/refreshStatus"
+ render={[Function]}
+ />
+ <Route
+ path="/logout"
+ render={[Function]}
+ />
+ <GlobalStyleComponent />
+ <Alert
+ closeLabel="Close alert"
+ dismissible={true}
+ onClose={[Function]}
+ show={false}
+ transition={
+ Object {
+ "$$typeof": Symbol(react.forward_ref),
+ "defaultProps": Object {
+ "appear": false,
+ "in": false,
+ "mountOnEnter": false,
+ "timeout": 300,
+ "unmountOnExit": false,
+ },
+ "displayName": "Fade",
+ "render": [Function],
+ }
+ }
+ variant="danger"
+ />
+ <Navbar
+ collapseOnSelect={false}
+ expand={true}
+ variant="light"
+ >
+ <NavbarBrand>
+ <img
+ alt=""
+ height="50px"
+ src={null}
+ width="234px"
+ />
+ <styled.a>
+ CLAMP
+ </styled.a>
+ </NavbarBrand>
+ <NavbarToggle
+ aria-controls="responsive-navbar-nav"
+ label="Toggle navigation"
+ />
+ <MenuBar
+ loopName="Empty (NO loop loaded yet)"
+ />
+ <NavbarText>
+ <styled.a>
+ Signed in as:
+ </styled.a>
+ <Styled(Link)
+ to="/userInfo"
+ />
+ <Styled(Link)
+ to="/logout/"
+ >
+ (logout)
+ </Styled(Link)>
+ </NavbarText>
+ </Navbar>
+ <styled.div>
+ <styled.div>
+ Loop Viewer -
+ Empty (NO loop loaded yet)
+ </styled.div>
+ <styled.div>
+ <withRouter(LoopViewSvg)
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ <LoopStatus
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ <LoopLogs
+ loopCache={
+ LoopCache {
+ "loopJsonCache": Object {},
+ }
+ }
+ />
+ </styled.div>
+ </styled.div>
+ </styled.div>
+</ThemeProvider>
+`;
diff --git a/version.properties b/version.properties
index d611b206b..941cd1d65 100644
--- a/version.properties
+++ b/version.properties
@@ -27,7 +27,7 @@
major=4
minor=1
-patch=3
+patch=4
base_version=${major}.${minor}.${patch}