From 85b715af5f4181ab9249f614d577adbdb2d2d987 Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 08:57:14 -0500 Subject: [PATCH 1/7] issue 476 - globalization updates - travis changes Signed-off-by: Sadiyah Faruk --- .travis.yml | 6 ++---- src/main/resources/messages_es.txt | 2 +- src/main/resources/messages_it.txt | 2 +- ...{messages_pt_BR.txt => messages_pt_br.txt} | 0 ...{messages_zh_CN.txt => messages_zh_cn.txt} | 0 ...{messages_zh_TW.txt => messages_zh_tw.txt} | 0 .../com/horizon/exchangeapi/NodesRoutes.scala | 3 ++- .../com/horizon/exchangeapi/NodesSuite.scala | 19 ++++++++++++++++++- 8 files changed, 24 insertions(+), 8 deletions(-) rename src/main/resources/{messages_pt_BR.txt => messages_pt_br.txt} (100%) rename src/main/resources/{messages_zh_CN.txt => messages_zh_cn.txt} (100%) rename src/main/resources/{messages_zh_TW.txt => messages_zh_tw.txt} (100%) diff --git a/.travis.yml b/.travis.yml index 606d737c..e8e989ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: +- docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network $DOCKER_NETWORK --name postgres postgres @@ -43,7 +44,4 @@ script: # Note: this does NOT run the IBM/OCP cloud tests or the multi-tenancy tests (because this travis script would have to stand up an OCP instance). Those tests must be run in your own dev environment. - make test -after_success: -- '{ test $TRAVIS_PULL_REQUEST = ''false'' && [[ ! "$TRAVIS_COMMIT_MESSAGE" =~ "--skip-push" ]] && - echo "$DOCKER_HUB_PASS" | docker login -u="$DOCKER_HUB_USER" --password-stdin && make docker-push-only; } || - echo ''Skipping the push''' + diff --git a/src/main/resources/messages_es.txt b/src/main/resources/messages_es.txt index f4d0bd36..20c9056e 100644 --- a/src/main/resources/messages_es.txt +++ b/src/main/resources/messages_es.txt @@ -334,7 +334,7 @@ no.access.to.org=El emisor de la llamada no tiene acceso a la organización: {0} invalid.account.id=ID de cuenta no válido account.id.not.assigned.to.caller=No se ha asignado ID de cuenta al emisor de la llamada account.id.invalid.or.not.assigned=El ID de cuenta no es válido o no se ha asignado al emisor de la llamada -user.cannot.be.in.root.org=En la organización raíz solo pueden existir el usuario raíz y los administradores de hub +user.cannot.be.in.root.org=En la organización raíz solo pueden existir el usuario root y los administradores de hub creating.updating.superuser.not.allowed=No se permite la creación o actualización del usuario root cannot.delete.root.user=No se puede suprimir el usuario root de Exchange cannot.delete.root.org=No se puede suprimir la organización raíz de Exchange diff --git a/src/main/resources/messages_it.txt b/src/main/resources/messages_it.txt index f72aa094..6fd4770c 100644 --- a/src/main/resources/messages_it.txt +++ b/src/main/resources/messages_it.txt @@ -327,7 +327,7 @@ dockauth.must.be.int=dockauthid deve essere un numero intero: {1} only.super.users.make.hub.admins=Questo utente non dispone delle autorizzazioni per creare Admin hub org.limits.cannot.be.over.exchange.limits=I limiti specifici dell''organizzazione non possono essere superiori al limite Exchange globale. Limite organizzazione: {0}; limite Exchange: {1} exchange.server.operating.normally=Server Exchange in funzione normalmente -hub.admins.in.root.org=Gli utenti Admin Hub Admin devono essere creati nell''organizzazione root +hub.admins.in.root.org=Gli utenti Admin Hub devono essere creati nell''organizzazione root hub.admins.only.view.admins=Gli utenti Admin Hub possono visualizzare solo gli utenti admin dell''organizzazione hub.admins.only.write.admins=Gli utenti Admin Hub possono solo creare o aggiornare gli utenti admin hub o admin dell''organizzazione no.access.to.org=Il chiamante non dispone di accesso all''organizzazione: {0} diff --git a/src/main/resources/messages_pt_BR.txt b/src/main/resources/messages_pt_br.txt similarity index 100% rename from src/main/resources/messages_pt_BR.txt rename to src/main/resources/messages_pt_br.txt diff --git a/src/main/resources/messages_zh_CN.txt b/src/main/resources/messages_zh_cn.txt similarity index 100% rename from src/main/resources/messages_zh_CN.txt rename to src/main/resources/messages_zh_cn.txt diff --git a/src/main/resources/messages_zh_TW.txt b/src/main/resources/messages_zh_tw.txt similarity index 100% rename from src/main/resources/messages_zh_TW.txt rename to src/main/resources/messages_zh_tw.txt diff --git a/src/main/scala/com/horizon/exchangeapi/NodesRoutes.scala b/src/main/scala/com/horizon/exchangeapi/NodesRoutes.scala index 7c13c3c2..b0fcdedd 100644 --- a/src/main/scala/com/horizon/exchangeapi/NodesRoutes.scala +++ b/src/main/scala/com/horizon/exchangeapi/NodesRoutes.scala @@ -267,7 +267,8 @@ final case class PostNodeConfigStateRequest(org: String, url: String, configStat // Convert from struct back to string and return db action to update that val newRegSvcsString: String = write(newRegSvcs) - (for { d <- NodesTQ.rows if d.id === id } yield (d.id,d.regServices,d.lastHeartbeat)).update((id, newRegSvcsString, Some(ApiTime.nowUTC))) + val nowTime = ApiTime.nowUTC + (for { d <- NodesTQ.rows if d.id === id } yield (d.id,d.regServices,d.lastHeartbeat,d.lastUpdated)).update((id, newRegSvcsString, Some(nowTime), nowTime)) } } diff --git a/src/test/scala/com/horizon/exchangeapi/NodesSuite.scala b/src/test/scala/com/horizon/exchangeapi/NodesSuite.scala index 6c59550d..f7e32cf0 100644 --- a/src/test/scala/com/horizon/exchangeapi/NodesSuite.scala +++ b/src/test/scala/com/horizon/exchangeapi/NodesSuite.scala @@ -745,11 +745,28 @@ class NodesSuite extends AnyFunSuite { assert(dev.registeredServices.exists(m => m.url == NETSPEEDSPEC && m.configState.contains("active"))) } - test("POST /orgs/"+orgid+"/nodes/"+nodeId+"/services_configstate - change config state of sdr reg svc") { + test("POST /orgs/"+orgid+"/nodes/"+nodeId+"/services_configstate - change config state of sdr reg svc and test lastUpdated field changed") { + val response1: HttpResponse[String] = Http(URL+"/nodes/"+nodeId).headers(ACCEPT).headers(USERAUTH).asString + info("code: "+response1.code) + assert(response1.code === HttpCode.OK.intValue) + val getDevResp = parse(response1.body).extract[GetNodesResponse] + assert(getDevResp.nodes.contains(orgnodeId)) + val dev = getDevResp.nodes(orgnodeId) + val initialLastUpdated = dev.lastUpdated + val input = PostNodeConfigStateRequest(orgid, SDRSPEC_URL, "suspended") val response = Http(URL+"/nodes/"+nodeId+"/services_configstate").postData(write(input)).method("post").headers(CONTENT).headers(ACCEPT).headers(USERAUTH).asString info("code: "+response.code) assert(response.code === HttpCode.PUT_OK.intValue) + + val response2: HttpResponse[String] = Http(URL+"/nodes/"+nodeId).headers(ACCEPT).headers(USERAUTH).asString + info("code: "+response2.code) + assert(response2.code === HttpCode.OK.intValue) + val getDevResp2 = parse(response2.body).extract[GetNodesResponse] + assert(getDevResp2.nodes.contains(orgnodeId)) + val dev2 = getDevResp2.nodes(orgnodeId) + val newLastUpdated = dev2.lastUpdated + assert(newLastUpdated > initialLastUpdated) } test("POST /orgs/"+orgid+"/changes - verify " + nodeId + " services_configstate was created and stored") { From 665147e978aa6d26a5bb03cd4427bc3812028c64 Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 09:08:20 -0500 Subject: [PATCH 2/7] version and readme Signed-off-by: Sadiyah Faruk --- README.md | 6 ++++++ src/main/resources/version.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 785f823e..bdaacc46 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,12 @@ Now you can disable root by setting `api.root.enabled` to `false` in `/etc/horiz - detect if a pattern is updated with service that has userInput w/o default values, and give warning - Consider changing all creates to POST, and update (via put/patch) return codes to 200 +## Changes in 2.65.0 + +- Updating `lastUpdated` field of node on `POST /services_configstate` route +- New translation files, and file name fixes +- travis.yml updates + ## Changes in 2.64.0 - Patch added to fix for issue 448. Missed one log message. diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index eeb32fad..dbdd4f38 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -2.64.0 \ No newline at end of file +2.65.0 \ No newline at end of file From 080cb965b344b57f1e27a3a96af3bfa05942ef7f Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 10:19:33 -0500 Subject: [PATCH 3/7] travis changes for PR Signed-off-by: Sadiyah Faruk --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8e989ea..3918d728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: -- docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" +- '{ test $TRAVIS_PULL_REQUEST = ''false'' && docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" } || echo ''This is a PR, skipping the login''' - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network $DOCKER_NETWORK --name postgres postgres From 4dc9a48c620eda28f159f963fc9ab63a4dace73b Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 10:45:03 -0500 Subject: [PATCH 4/7] just trying things now Signed-off-by: Sadiyah Faruk --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3918d728..1f3bd748 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,10 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: -- '{ test $TRAVIS_PULL_REQUEST = ''false'' && docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" } || echo ''This is a PR, skipping the login''' +- if : $TRAVIS_PULL_REQUEST = ''false'' + docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" + else: + echo ''This is a PR, skipping the login''' - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network $DOCKER_NETWORK --name postgres postgres From 14b996a508b3c8236f71d23473dbfaaff9397026 Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 11:05:57 -0500 Subject: [PATCH 5/7] travis tests not running Signed-off-by: Sadiyah Faruk --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f3bd748..0e9c0982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,9 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: -- if : $TRAVIS_PULL_REQUEST = ''false'' +- if : branch = master AND fork = false docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" - else: +- else : echo ''This is a PR, skipping the login''' - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network From 9921dc919534209d24c10a55d62f853a41cc78cb Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 11:23:49 -0500 Subject: [PATCH 6/7] travis tests not running Signed-off-by: Sadiyah Faruk --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e9c0982..55a3cfd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,10 +26,7 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: -- if : branch = master AND fork = false - docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS" -- else : - echo ''This is a PR, skipping the login''' +- ($TRAVIS_PULL_REQUEST = ''false'') AND (docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS") OR (echo ''This is a PR, skipping the login'') - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network $DOCKER_NETWORK --name postgres postgres From 9d1e080130c8c9fcd551a5dbd710d7553d1793c3 Mon Sep 17 00:00:00 2001 From: Sadiyah Faruk Date: Tue, 9 Mar 2021 11:56:19 -0500 Subject: [PATCH 7/7] travis syntax error Signed-off-by: Sadiyah Faruk --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 55a3cfd8..5c4e32d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce || true before_script: -- ($TRAVIS_PULL_REQUEST = ''false'') AND (docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS") OR (echo ''This is a PR, skipping the login'') +- ($TRAVIS_PULL_REQUEST = ''false'') && (docker login -u="$DOCKER_HUB_USER" -p="$DOCKER_HUB_PASS") || (echo ''This is a PR, skipping the login'') - make .docker-network - docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=$POSTGRES_DB -e POSTGRES_USER=$POSTGRES_USER --network $DOCKER_NETWORK --name postgres postgres