diff --git a/ApplyIFixes.sh b/ApplyIFixes.sh deleted file mode 100755 index 1d70c26..0000000 --- a/ApplyIFixes.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Check if any iFix's are to be applied. - -if [ -z $1 ]; then - echo "No iFix's being used skipping this phase." - exit 0 # No iFix specified -else # Create array of iFix's to loop through by removing commas from input. - IFIX_LIST_ARRAY=$(echo $1 | tr ',' ' ') - echo "iFix's being applied: ${IFIX_LIST_ARRAY}" -fi - -for ifixlink in $IFIX_LIST_ARRAY -do - # Make temporary fix directory - mkdir ./fix - cd fix - - # Download and unzip iFix tar file. - curl -Ls $ifixlink | tar -xz - - # Execute install command - ifixname="${ifixlink##*/}" - ifixname="${ifixname%.tar*}" - - ./mqsifixinst.sh /opt/ibm/ace-12 install $ifixname - - # Delete directory - cd .. - rm -rf ./fix - - rm -rf /opt/ibm/ace-12/fix-backups.12.0.1.0 - rm /opt/ibm/ace-12/mqsifixinst.log - rm /opt/ibm/ace-12/mqsifixinst.sh - - # We explicitly screen out /tools and TransformationAdvisor, so let's make sure to clean up after any iFixes that put them back - rm -rf /opt/ibm/ace-12/tools /opt/ibm/ace-12/server/bin/TADataCollector.sh /opt/ibm/ace-12/server/transformationAdvisor -done diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index c15aeb0..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,81 +0,0 @@ -# Change log - -## 12.0.3.0-r2 - -**Updates** - -* Ability to override Statistics->Resource in server.conf.yaml -* Improved the logging for metrics when authentication is not enabled -* Includes IT39515 -* Includes IT39573 -* Includes IT39917 -* Remove need for python -* Fix for CVE-2022-21698 - -## 12.0.3.0-r1 - -**Updates** - -* Fix bug with capitlisation on "insecureSsl" for barAuth json - -## 11.0.0.6.1 (2019-11-20) - -**Updates**: - -* Updated kubectl to version v1.16.0 -* Updated MQ to version 9.1.3.0-r3 -* Added support for hostname and port overrides when routes are defined -* Created ACE roles for five different access levels: admin, operator, viewer, editor, and audit - -## 11.0.0.6 (2019-10-30) - -**Changes**: - -* Updated to use the 11.0.0.6 build -* Support metrics when Integration Server is using TLS - -## 11.0.0.5.1 (2019-09-24) - -**Updates**: - -* New image that includes an MQ client -* Supports MQ 9.1.3 images -* Support for defining custom ports -* Support for running switches -* Ability to set up operator, editor, and audit users for the ACE web UI, in addition to admin and viewer users -* Support for LEL User Exit files - -## 11.0.0.5 (2019-07-05) - -**Breaking changes**: - -* When using MQ, the UID of the mqm user is now 888. You need to run the container with an entrypoint of `runmqserver -i` under the root user to update any existing files. -* MQSC files supplied will be verified before being run. Files containing invalid MQSC will cause the container to fail to start - -**Updates**: - -* Security fixes -* Web console added to production image -* Container built on RedHat host (UBI) -* Includes MQ 9.1.2 -* Supports configuring agent files -* Supports installing additional config files using extensions.zip - -## 11.0.0.3 (2019-02-04) - -**Other changes**: - -* Provides samples for building image with MQ Client -* Code to generate RHEL based images -* Fix for overriding the hostname and port for RestAPI in the UI / Swagger Docs. - -## 11.0.0.2 (2018-11-20) - -**Updates**: - -* Updated to support 11.0.0.2 runtime -* Updated to support ICP platform - -## 11.0.0.0 (2019-10-08) - -* Initial version diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..662d590 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Build and run: +# +# docker build -t ace:12.0.2.0 -f Dockerfile . +# docker run -e LICENSE=accept -p 7600:7600 -p 7800:7800 --rm -ti ace:12.0.2.0 +# +# Can also mount a volume for the work directory: +# +# docker run -e LICENSE=accept -v /what/ever/dir:/home/aceuser/ace-server -p 7600:7600 -p 7800:7800 --rm -ti ace:12.0.2.0 +# +# This might require a local directory with the right permissions, or changing the userid further down . . . + +FROM registry.access.redhat.com/ubi8/ubi-minimal as builder + +RUN microdnf update && microdnf install util-linux curl tar + +ARG USERNAME +ARG PASSWORD +ARG DOWNLOAD_URL=http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/integration/12.0.2.0-ACE-LINUX64-DEVELOPER.tar.gz + +RUN mkdir -p /opt/ibm/ace-12 \ + && if [ -z $USERNAME ]; then curl ${DOWNLOAD_URL}; else curl -u "${USERNAME}:${PASSWORD}" ${DOWNLOAD_URL}; fi | \ + tar zx --absolute-names --exclude ace-12.\*/tools --exclude ace-12.\*/server/bin/TADataCollector.sh --exclude ace-12.\*/server/transformationAdvisor/ta-plugin-ace.jar --strip-components 1 --directory /opt/ibm/ace-12 + +FROM registry.access.redhat.com/ubi8/ubi-minimal + +RUN microdnf update && microdnf install findutils util-linux && microdnf clean all + +# Force reinstall tzdata package to get zoneinfo files +RUN microdnf reinstall tzdata -y + +# Prevent errors about having no terminal when using apt-get +ENV DEBIAN_FRONTEND noninteractive + +# Install ACE v12.0.2.0 and accept the license +COPY --from=builder /opt/ibm/ace-12 /opt/ibm/ace-12 +RUN /opt/ibm/ace-12/ace make registry global accept license deferred \ + && useradd --uid 1001 --create-home --home-dir /home/aceuser --shell /bin/bash -G mqbrkrs aceuser \ + && su - aceuser -c "export LICENSE=accept && . /opt/ibm/ace-12/server/bin/mqsiprofile && mqsicreateworkdir /home/aceuser/ace-server" \ + && echo ". /opt/ibm/ace-12/server/bin/mqsiprofile" >> /home/aceuser/.bashrc + +COPY git.commit* /home/aceuser/ + +# Add required license as text file in Liceses directory (GPL, MIT, APACHE, Partner End User Agreement, etc) +COPY /licenses/ /licenses/ + +# aceuser +USER 1001 + +# Expose ports. 7600, 7800, 7843 for ACE; +EXPOSE 7600 7800 7843 + +# Set entrypoint to run the server +ENTRYPOINT ["bash", "-c", ". /opt/ibm/ace-12/server/bin/mqsiprofile && IntegrationServer -w /home/aceuser/ace-server"] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 14b6796..0000000 --- a/LICENSE +++ /dev/null @@ -1,909 +0,0 @@ -The translated license terms can be viewed here: https://www-03.ibm.com/software/sla/sladb.nsf/searchlis/?searchview&searchorder=4&searchmax=0&query=(App+Connect+Enterprise+V11.0.0.5) - -LICENSE INFORMATION - -The Programs listed below are licensed under the following License Information terms and conditions in addition to the Program license terms previously agreed to by Client and IBM. If Client does not have previously agreed to license terms in effect for the Program, the International Program License Agreement (Z125-3301-14) applies. - -Program Name (Program Number): -IBM App Connect Enterprise V11.0.0.5 (5724-J05) - -The following standard terms apply to Licensee's use of the Program. - -Limited use right - -As described in the International Program License Agreement ("IPLA") and this License Information, IBM grants Licensee a limited right to use the Program. This right is limited to the level of Authorized Use, such as a Processor Value Unit ("PVU"), a Resource Value Unit ("RVU"), a Value Unit ("VU"), or other specified level of use, paid for by Licensee as evidenced in the Proof of Entitlement. Licensee's use may also be limited to a specified machine, or only as a Supporting Program, or subject to other restrictions. As Licensee has not paid for all of the economic value of the Program, no other use is permitted without the payment of additional fees. In addition, Licensee is not authorized to use the Program to provide commercial IT services to any third party, to provide commercial hosting or timesharing, or to sublicense, rent, or lease the Program unless expressly provided for in the applicable agreements under which Licensee obtains authorizations to use the Program. Additional rights may be available to Licensee subject to the payment of additional fees or under different or supplementary terms. IBM reserves the right to determine whether to make such additional rights available to Licensee. - -Specifications - -Program's specifications can be found in the collective Description and Technical Information sections of the Program's Announcement Letters. - -Prohibited Uses - -Licensee may not use or authorize others to use the Program if failure of the Program could lead to death, bodily injury, or property or environmental damage. - -Bundled Programs - -Licensee is authorized to install and use the Bundled Programs identified below. A Bundled Program may be accompanied by license terms, and those terms, if any, apply to Licensee's use of that Bundled Program. In the event of conflict, the terms in this License Information document supersede the Bundled Program's terms. The Principal Program and any Bundled Programs are all part of the Program, as a whole. Therefore, Licensee must obtain sufficient entitlements to the Program, as a whole, to cover Licensee's installation and use of all of the Bundled Programs, unless separate entitlements are provided within this License Information document. For example, if this Program were licensed on a PVU (Processor Value Unit) basis and Licensee were to install the Principal Program or a Bundled Program on a 100 PVU machine (physical or virtual) and another Bundled Program on a second 100 PVU machine, Licensee would be required to obtain 200 PVU entitlements to the Program. - -Bundled Programs: -- IBM App Connect Professional V7.5.2.0 - -Supporting Programs - -Licensee is authorized to install and use the Supporting Programs identified below. Licensee is authorized to install and use such Supporting Programs only to support Licensee's use of the Principal Program under this Agreement. The phrase "to support Licensee's use" would only include those uses that are necessary or otherwise directly related to a licensed use of the Principal Program or another Supporting Program. The Supporting Programs may not be used for any other purpose. A Supporting Program may be accompanied by license terms, and those terms, if any, apply to Licensee's use of that Supporting Program. In the event of conflict, the terms in this License Information document supersede the Supporting Program's terms. Licensee must obtain sufficient entitlements to the Program, as a whole, to cover Licensee's installation and use of all of the Supporting Programs, unless separate entitlements are provided within this License Information document. For example, if this Program were licensed on a PVU (Processor Value Unit) basis and Licensee were to install the Principal Program or a Supporting Program on a 100 PVU machine (physical or virtual) and another Supporting Program on a second 100 PVU machine, Licensee would be required to obtain 200 PVU entitlements to the Program. - -Supporting Programs: -- IBM Support Assistant Data Collector V2.0.1 -- IBM WebSphere Adapter for JD Edwards EnterpriseOne V7.5 -- IBM WebSphere Adapter for PeopleSoft Enterprise V7.5 -- IBM WebSphere Adapter for SAP Software V7.5 -- IBM WebSphere Adapter for Siebel Business Applications V7.5 -- IBM MQ Advanced V9.0 -- IBM Data Server Driver Package V11.1 -- IBM MQ Advanced V9.1 - -Non-Production Limitation - -If the Program is designated as "Non-Production", the Program can only be deployed as part of the Licensee's internal development and test environment for internal non-production activities, including but not limited to testing, performance tuning, fault diagnosis, internal benchmarking, staging, quality assurance activity and/or developing internally used additions or extensions to the Program using published application programming interfaces. Licensee is not authorized to use any part of the Program for any other purposes without acquiring the appropriate production entitlements. - -Separately Licensed Code - -The provisions of this paragraph do not apply to the extent they are held to be invalid or unenforceable under the law that governs this license. Each of the components listed below is considered "Separately Licensed Code". IBM Separately Licensed Code is licensed to Licensee under the terms of the applicable third party license agreement(s) set forth in the NON_IBM_LICENSE file(s) that accompanies the Program. Notwithstanding any of the terms in the Agreement, or any other agreement Licensee may have with IBM, the terms of such third party license agreement(s) governs Licensee's use of all Separately Licensed Code unless otherwise noted below. - -Future Program updates or fixes may contain additional Separately Licensed Code. Such additional Separately Licensed Code and related licenses are listed in another NON_IBM_LICENSE file that accompanies the Program update or fix. Licensee acknowledges that Licensee has read and agrees to the license agreements contained in the NON_IBM_LICENSE file(s). If Licensee does not agree to the terms of these third party license agreements, Licensee may not use the Separately Licensed Code. - -For Programs acquired under the International Program License Agreement ("IPLA") or International Program License Agreement for Non Warranted Program ("ILAN") and Licensee is the original licensee of the Program, if Licensee does not agree with the third party license agreements, Licensee may return the Program in accordance with the terms of, and within the specified time frames stated in, the "Money-back Guarantee" section of the IPLA or ILAN IBM Agreement. - -Note: Notwithstanding any of the terms in the third party license agreement, the Agreement, or any other agreement Licensee may have with IBM: -(a) IBM provides this Separately Licensed Code to Licensee WITHOUT WARRANTIES OF ANY KIND; -(b) IBM DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF TITLE, NON-INFRINGEMENT OR INTERFERENCE AND THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE SEPARATELY LICENSED CODE; -(c) IBM is not liable to Licensee, and will not defend, indemnify, or hold Licensee harmless for any claims arising from or related to the Separately Licensed Code; and -(d) IBM is not liable for any direct, indirect, incidental, special, exemplary, punitive or consequential damages including, but not limited to, lost data, lost savings, and lost profits, with respect to the Separately Licensed Code. - -Notwithstanding these exclusions, in Germany and Austria, IBM's warranty and liability for the Separately Licensed Code is governed only by the respective terms applicable for Germany and Austria in IBM license agreements. - -Note: IBM may provide limited support for some Separately Licensed Code. If such support is available, the details and any additional terms related to such support will be set forth in the License Information document. - -The following are Separately Licensed Code: -The Program includes some or all of the following licensed to you as Separately Licensed Code. -1. CC-BY-3.0 - spdx-exceptions(node) , spdx-expression-parse -2. CC0-1.0 - spdx-license-ids(node) , lodash.fill , lodash.intersection , lodash.partialright , libnpx make-fetch-happen spdx-license-ids spdx-license-ids -3. Ubuntu -4. Red Hat Enterprise Linux (RHEL) -5.Red Hat Universal Base Image v7.0 -=================================================================== -1. spdx-exceptions(node) , spdx-expression-parse -License for CreativeCommons-by-3.0 -=================================================================== -=================================================================== -2. spdx-license-ids(node) , lodash.fill , lodash.intersection , lodash.partialright , libnpx make-fetch-happen spdx-license-ids spdx-license-ids -License for Creative Commons CC0-1.0 -=================================================================== -=================================================================== -3. Ubuntu Operating System -=================================================================== -When IBM App Connect Enterprise is provided in a container format, license information for Ubuntu packages may be found in /usr/share/doc/${package}/copyright -========================================================================= -4.Red Hat Enterprise Linux Operating System -========================================================================= -When IBM App Connect Enterprise is provided in a container format, license information for Red Hat Enterprise Linux packages may be found in /usr/share/doc/${package} -========================================================================= -5.Red Hat Universal Base Image v7.0 -========================================================================= -Red Hat Universal Base Image v7.0 has been taken under EULA > https://www.redhat.com/licenses/eulas - -The Program maybe provided with third party software programs subject to their own license terms. The license terms either accompany the third party software programs or, in some instances, may be viewed at > https://access.redhat.com/containers/ -========================================================================= - -Redistributables - -If the Program includes components that are Redistributable, they will be identified in the REDIST file that accompanies the Program. In addition to the license rights granted in the Agreement, Licensee may distribute the Redistributables subject to the following terms: -1) Redistribution must be in object code form only and must conform to all directions, instruction and specifications in the Program's accompanying REDIST or documentation; -2) If the Program's accompanying documentation expressly allows Licensee to modify the Redistributables, such modification must conform to all directions, instruction and specifications in that documentation and these modifications, if any, must be treated as Redistributables; -3) Redistributables may be distributed only as part of Licensee's application that was developed using the Program ("Licensee's Application") and only to support Licensee's customers in connection with their use of Licensee's Application. Licensee's Application must constitute significant value add such that the Redistributables are not a substantial motivation for the acquisition by end users of Licensee's software product; -4) If the Redistributables include a Java Runtime Environment, Licensee must also include other non-Java Redistributables with Licensee's Application, unless the Application is designed to run only on general computer devices (for example, laptops, desktops and servers) and not on handheld or other pervasive devices (i.e., devices that contain a microprocessor but do not have computing as their primary purpose); -5) Licensee may not remove any copyright or notice files contained in the Redistributables; -6) Licensee must hold IBM, its suppliers or distributors harmless from and against any claim arising out of the use or distribution of Licensee's Application; -7) Licensee may not use the same path name as the original Redistributable files/modules; -8) Licensee may not use IBM's, its suppliers or distributors names or trademarks in connection with the marketing of Licensee's Application without IBM's or that supplier's or distributor's prior written consent; -9) IBM, its suppliers and distributors provide the Redistributables and related documentation without obligation of support and "AS IS", WITH NO WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTY OF TITLE, NON-INFRINGEMENT OR NON-INTERFERENCE AND THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE; -10) Licensee is responsible for all technical assistance for Licensee's Application and any modifications to the Redistributables; and -11) Licensee's license agreement with the end user of Licensee's Application must notify the end user that the Redistributables or their modifications may not be i) used for any purpose other than to enable Licensee's Application, ii) copied (except for backup purposes), iii) further distributed or transferred without Licensee's Application or iv) reverse assembled, reverse compiled, or otherwise translated except as specifically permitted by law and without the possibility of a contractual waiver. Furthermore, Licensee's license agreement must be at least as protective of IBM as the terms of this Agreement. - -Source Components and Sample Materials - -The Program may include some components in source code form ("Source Components") and other materials identified as Sample Materials. Licensee may copy and modify Source Components and Sample Materials for internal use only provided such use is within the limits of the license rights under this Agreement, provided however that Licensee may not alter or delete any copyright information or notices contained in the Source Components or Sample Materials. IBM provides the Source Components and Sample Materials without obligation of support and "AS IS", WITH NO WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTY OF TITLE, NON-INFRINGEMENT OR NON-INTERFERENCE AND THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -For Source Components and Sample Materials listed in a Program's REDIST file, Licensee may redistribute modified versions of those Source Components or Sample Materials consistent with the terms of this license and any instructions in the REDIST file. - -Third Party Operating Systems - -For the convenience of Licensee, the Program may be accompanied by a third party operating system. The operating system is not part of the Program, and is licensed directly by the operating system provider (e.g., Red Hat Inc., Novell Inc., etc.) to Licensee. IBM is not a party to the license between Licensee and the third party operating system provider, and includes the third party operating system "AS IS", without representation or warranty, express or implied, including any implied warranty of merchantability, fitness for a particular purpose or non-infringement. - -Third Party Data and Services - -The Program may contain links to or be used to access third party data services, databases, web services, software, or other third party content (all, "content"). Access to this content is provided "AS-IS", WITH NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING THE WARRANTY OF TITLE, NON-INFRINGEMENT OR NON-INTERFERENCE AND THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Access can be terminated by the relevant third parties at their sole discretion at any time. Licensee may be required to enter into separate agreements with the third parties for the access to or use of such content. IBM is not a party to any such separate agreements and as an express condition of this license Licensee agrees to comply with the terms of such separate agreements. - -The following units of measure may apply to Licensee's use of the Program. - -Processor Value Unit (PVU) - -Processor Value Unit (PVU) is a unit of measure by which the Program can be licensed. The number of PVU entitlements required is based on the processor technology (defined within the PVU Table by Processor Vendor, Brand, Type and Model Number at http://www.ibm.com/software/lotus/passportadvantage/pvu_licensing_for_customers.html) and the number of processors made available to the Program. IBM continues to define a processor, for the purpose of PVU-based licensing, to be each processor core on a chip. A dual-core processor chip, for example, has two processor cores. - -Licensee can deploy the Program using either Full Capacity licensing or Virtualization Capacity (Sub-Capacity) licensing according to the Passport Advantage Sub-Capacity Licensing Terms (see webpage below). If using Full Capacity licensing, Licensee must obtain PVU entitlements sufficient to cover all activated processor cores* in the physical hardware environment made available to or managed by the Program, except for those servers from which the Program has been permanently removed. If using Virtualization Capacity licensing, Licensee must obtain entitlements sufficient to cover all activated processor cores made available to or managed by the Program, as defined according to the Virtualization Capacity License Counting Rules at http://www.ibm.com/software/lotus/passportadvantage/Counting_Software_licenses_using_specific_virtualization_technologies.html. - -* An Activated processor core is a processor core that is available for use in a physical or virtual server, regardless of whether the capacity of the processor core can be or is limited through virtualization technologies, operating system commands, BIOS settings, or similar restrictions. - -Virtual Processor Core - -Virtual Processor Core is a unit of measure by which the Program can be licensed. A Server is a physical computer that is comprised of processing units, memory, and input/output capabilities and that executes requested procedures, commands, or applications for one or more users or client devices. Where racks, blade enclosures, or other similar equipment is being employed, each separable physical device (for example, a blade or a rack-mounted device) that has the required components is considered itself a separate Server. A Virtual Server is either a virtual computer created by partitioning the resources available to a physical Server or an unpartitioned physical Server. A Processor Core is a functional unit within a computing device that interprets and executes instructions. A Processor Core consists of at least an instruction control unit and one or more arithmetic or logic unit. A Virtual Processor Core is a Processor Core on a Virtual Server created by partitioning the resources available to a physical Server or an unpartitioned physical Server. Licensee must obtain entitlement for each Virtual Processor Core made available to the Program. - -For each physical Server, Licensee must have sufficient entitlements for the lesser of 1) the sum of all available Virtual Processor Cores on all Virtual Servers or 2) all available Processor Cores on the physical Server. - -In addition to the above, the following terms apply to Licensee's use of the Program. - -1. Components Not Used for Establishing Required Entitlements - -When determining the number of entitlements required for Licensee's installation or use of the Program, the installation or use of the following Program and components are not taken into consideration. In other words, Licensee may install and use the following Program and components, under the license terms, but these components are not used to determine the number of entitlements required for the Program. - -Use of the Program and Components when used for Development and Functional Test purposes: - -Under Development and Functional Test use, the Program or components can only be deployed as part of Licensee's internal development, unit, and functional testing environments. In functional test environments the developer can integrate their code with that of others on shared use machines, and that code can be tested in a test harness. Functional testing is limited to ensuring that the Program can be used to connect to local or remote endpoints, and that a sample of data sent between those endpoints is processed correctly. Licensee is not authorized to use the Program or components for system test, meaning integrated code is tested as a product, processing production workloads, simulating production workloads or testing the scalability of any code, application or system. - -2. Operation mode - -The Program is capable of running in different operational modes, with associated restrictions, which are detailed in the "Operation Modes" and the "Restrictions that apply in each operation mode" sections of the Program's Knowledge Center, which is provided by IBM in the English, Brazilian Portuguese, German, Japanese and Spanish languages. The term Execution Group (used below) is defined in the "Technical Overview" section of the Program's Knowledge Center. - -In Standard mode, all features are enabled for use with a single Execution Group. The number of message flows that Licensee can deploy is unlimited. - -By default, the Program runs in the Advanced mode; see the "Operation Modes" section of the Program's Information Center for details of how to change the Program's operational mode, using the 'mqsimode' command. - -The entitlement to use each operational mode must be acquired separately, and it is Licensee's obligation to ensure that the Program is not running in an operational mode with more functionality (or with fewer restrictions) than the operational mode entitlement which Licensee has acquired. - -3. Supporting Program Details - -IBM Support Assistant Data Collector -- Support: Nonsupported - -"Nonsupported" means the Supporting Program is provided without obligation of support and "AS IS", WITH NO WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTY OF TITLE, NON-INFRINGEMENT OR NON-INTERFERENCE AND THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -IBM Data Server Driver Package -- Use Limitation: Supported only on the IBM Cloud Private platform or on the IBM Kubernetes system platform and only for use with connecting to any version of IBM DB2 on a Linux, Unix or Windows platform. - -IBM MQ -- Entitlement: Ratio 1 VPC/1 VPC -- Entitlement: Ratio 1 PVU /1 PVU - -"Ratio n/m" means that Licensee receives some number ('n') entitlements of the indicated metric for the Supporting or Bundled Program for every specified number ('m') entitlements of the specified metric for the Program as a whole. The specified ratio does not apply to any entitlements for the Program that are not of the required metric type. The number of entitlements for the Supporting or Bundled Program is rounded up to a multiple of 'n'. For example, if a Program includes 100 PVUs for a Supporting or Bundled Program for every 500 PVUs obtained of the Principal Program and Licensee acquires 1,200 PVUs of the Program, Licensee may install the Supporting or Bundled Program and have processor cores available to or managed by it of up to 300 PVUs. Those PVUs would not need to be counted as part of the total PVU requirement for Licensee's installation of the Program on account of the installation of the Supporting or Bundled Program (although those PVUs might need to be counted for other reasons, such as the processor cores being made available to other components of the Program, as well). - -4. Bundled Program details - -IBM App Connect Professional -- Entitlement: Ratio 1 VPC/1 VPC -- Entitlement: Ratio 1 PVU /1 PVU - -"Ratio n/m" means that Licensee receives some number ('n') entitlements of the indicated metric for the Supporting or Bundled Program for every specified number ('m') entitlements of the specified metric for the Program as a whole. The specified ratio does not apply to any entitlements for the Program that are not of the required metric type. The number of entitlements for the Supporting or Bundled Program is rounded up to a multiple of 'n'. For example, if a Program includes 100 PVUs for a Supporting or Bundled Program for every 500 PVUs obtained of the Principal Program and Licensee acquires 1,200 PVUs of the Program, Licensee may install the Supporting or Bundled Program and have processor cores available to or managed by it of up to 300 PVUs. Those PVUs would not need to be counted as part of the total PVU requirement for Licensee's installation of the Program on account of the installation of the Supporting or Bundled Program (although those PVUs might need to be counted for other reasons, such as the processor cores being made available to other components of the Program, as well). - -5. Distributable Microsoft Code - -The distribution of the Program that is released for Microsoft Windows operating systems contains some distributable code (source code and DLLs) from Microsoft Corporation ('Microsoft Code'). - -Licensee may not exploit any distributable Microsoft Code (i.e., source code and DLLs), unless Licensee separately downloads (or otherwise properly obtains) its own copy of the Microsoft source and DLLs directly from Microsoft. Licensee will be subject to the terms and conditions of the Microsoft license that accompanies such Microsoft source code and DLLs (and not the terms and conditions of this license), which will apply to the use and distribution (if any) by Licensee of such material downloaded or otherwise by Licensee. - -The Program contains sample source code that is derived from the distributable Microsoft Code in source code form. Licensee must not include any such sample source code derived from distributable Microsoft Code in any malicious, deceptive or unlawful program. - -L/N: L-DFOX-BC9LDF -D/N: L-DFOX-BC9LDF -P/N: L-DFOX-BC9LDF - -International Program License Agreement - -Part 1 - General Terms - -BY DOWNLOADING, INSTALLING, COPYING, ACCESSING, CLICKING ON AN "ACCEPT" BUTTON, OR OTHERWISE USING THE PROGRAM, LICENSEE AGREES TO THE TERMS OF THIS AGREEMENT. IF YOU ARE ACCEPTING THESE TERMS ON BEHALF OF LICENSEE, YOU REPRESENT AND WARRANT THAT YOU HAVE FULL AUTHORITY TO BIND LICENSEE TO THESE TERMS. IF YOU DO NOT AGREE TO THESE TERMS, - -* DO NOT DOWNLOAD, INSTALL, COPY, ACCESS, CLICK ON AN "ACCEPT" BUTTON, OR USE THE PROGRAM; AND - -* PROMPTLY RETURN THE UNUSED MEDIA, DOCUMENTATION, AND PROOF OF ENTITLEMENT TO THE PARTY FROM WHOM IT WAS OBTAINED FOR A REFUND OF THE AMOUNT PAID. IF THE PROGRAM WAS DOWNLOADED, DESTROY ALL COPIES OF THE PROGRAM. - -1. Definitions - -"Authorized Use" - the specified level at which Licensee is authorized to execute or run the Program. That level may be measured by number of users, millions of service units ("MSUs"), Processor Value Units ("PVUs"), or other level of use specified by IBM. - -"IBM" - International Business Machines Corporation or one of its subsidiaries. - -"License Information" ("LI") - a document that provides information and any additional terms specific to a Program. The Program's LI is available at www.ibm.com/software/sla. The LI can also be found in the Program's directory, by the use of a system command, or as a booklet included with the Program. - -"Program" - the following, including the original and all whole or partial copies: 1) machine-readable instructions and data, 2) components, files, and modules, 3) audio-visual content (such as images, text, recordings, or pictures), and 4) related licensed materials (such as keys and documentation). - -"Proof of Entitlement" ("PoE") - evidence of Licensee's Authorized Use. The PoE is also evidence of Licensee's eligibility for warranty, future update prices, if any, and potential special or promotional opportunities. If IBM does not provide Licensee with a PoE, then IBM may accept as the PoE the original paid sales receipt or other sales record from the party (either IBM or its reseller) from whom Licensee obtained the Program, provided that it specifies the Program name and Authorized Use obtained. - -"Warranty Period" - one year, starting on the date the original Licensee is granted the license. - -2. Agreement Structure - -This Agreement includes Part 1 - General Terms, Part 2 - Country-unique Terms (if any), the LI, and the PoE and is the complete agreement between Licensee and IBM regarding the use of the Program. It replaces any prior oral or written communications between Licensee and IBM concerning Licensee's use of the Program. The terms of Part 2 may replace or modify those of Part 1. To the extent of any conflict, the LI prevails over both Parts. - -3. License Grant - -The Program is owned by IBM or an IBM supplier, and is copyrighted and licensed, not sold. - -IBM grants Licensee a nonexclusive license to 1) use the Program up to the Authorized Use specified in the PoE, 2) make and install copies to support such Authorized Use, and 3) make a backup copy, all provided that - -a. Licensee has lawfully obtained the Program and complies with the terms of this Agreement; - -b. the backup copy does not execute unless the backed-up Program cannot execute; - -c. Licensee reproduces all copyright notices and other legends of ownership on each copy, or partial copy, of the Program; - -d. Licensee ensures that anyone who uses the Program (accessed either locally or remotely) 1) does so only on Licensee's behalf and 2) complies with the terms of this Agreement; - -e. Licensee does not 1) use, copy, modify, or distribute the Program except as expressly permitted in this Agreement; 2) reverse assemble, reverse compile, otherwise translate, or reverse engineer the Program, except as expressly permitted by law without the possibility of contractual waiver; 3) use any of the Program's components, files, modules, audio-visual content, or related licensed materials separately from that Program; or 4) sublicense, rent, or lease the Program; and - -f. if Licensee obtains this Program as a Supporting Program, Licensee uses this Program only to support the Principal Program and subject to any limitations in the license to the Principal Program, or, if Licensee obtains this Program as a Principal Program, Licensee uses all Supporting Programs only to support this Program, and subject to any limitations in this Agreement. For purposes of this Item "f," a "Supporting Program" is a Program that is part of another IBM Program ("Principal Program") and identified as a Supporting Program in the Principal Program's LI. (To obtain a separate license to a Supporting Program without these restrictions, Licensee should contact the party from whom Licensee obtained the Supporting Program.) - -This license applies to each copy of the Program that Licensee makes. - -3.1 Trade-ups, Updates, Fixes, and Patches - -3.1.1 Trade-ups - -If the Program is replaced by a trade-up Program, the replaced Program's license is promptly terminated. - -3.1.2 Updates, Fixes, and Patches - -When Licensee receives an update, fix, or patch to a Program, Licensee accepts any additional or different terms that are applicable to such update, fix, or patch that are specified in its LI. If no additional or different terms are provided, then the update, fix, or patch is subject solely to this Agreement. If the Program is replaced by an update, Licensee agrees to promptly discontinue use of the replaced Program. - -3.2 Fixed Term Licenses - -If IBM licenses the Program for a fixed term, Licensee's license is terminated at the end of the fixed term, unless Licensee and IBM agree to renew it. - -3.3 Term and Termination - -This Agreement is effective until terminated. - -IBM may terminate Licensee's license if Licensee fails to comply with the terms of this Agreement. - -If the license is terminated for any reason by either party, Licensee agrees to promptly discontinue use of and destroy all of Licensee's copies of the Program. Any terms of this Agreement that by their nature extend beyond termination of this Agreement remain in effect until fulfilled, and apply to both parties' respective successors and assignees. - -4. Charges - -Charges are based on Authorized Use obtained, which is specified in the PoE. IBM does not give credits or refunds for charges already due or paid, except as specified elsewhere in this Agreement. - -If Licensee wishes to increase its Authorized Use, Licensee must notify IBM or an authorized IBM reseller in advance and pay any applicable charges. - -5. Taxes - -If any authority imposes on the Program a duty, tax, levy, or fee, excluding those based on IBM's net income, then Licensee agrees to pay that amount, as specified in an invoice, or supply exemption documentation. Licensee is responsible for any personal property taxes for the Program from the date that Licensee obtains it. If any authority imposes a customs duty, tax, levy, or fee for the import into or the export, transfer, access, or use of the Program outside the country in which the original Licensee was granted the license, then Licensee agrees that it is responsible for, and will pay, any amount imposed. - -6. Money-back Guarantee - -If Licensee is dissatisfied with the Program for any reason and is the original Licensee, Licensee may terminate the license and obtain a refund of the amount Licensee paid for the Program, provided that Licensee returns the Program and PoE to the party from whom Licensee obtained it within 30 days of the date the PoE was issued to Licensee. If the license is for a fixed term that is subject to renewal, then Licensee may obtain a refund only if the Program and its PoE are returned within the first 30 days of the initial term. If Licensee downloaded the Program, Licensee should contact the party from whom Licensee obtained it for instructions on how to obtain the refund. - -7. Program Transfer - -Licensee may transfer the Program and all of Licensee's license rights and obligations to another party only if that party agrees to the terms of this Agreement. If the license is terminated for any reason by either party, Licensee is prohibited from transferring the Program to another party. Licensee may not transfer a portion of 1) the Program or 2) the Program's Authorized Use. When Licensee transfers the Program, Licensee must also transfer a hard copy of this Agreement, including the LI and PoE. Immediately after the transfer, Licensee's license terminates. - -8. Warranty and Exclusions - -8.1 Limited Warranty - -IBM warrants that the Program, when used in its specified operating environment, will conform to its specifications. The Program's specifications, and specified operating environment information, can be found in documentation accompanying the Program (such as a read-me file) or other information published by IBM (such as an announcement letter). Licensee agrees that such documentation and other Program content may be supplied only in the English language, unless otherwise required by local law without the possibility of contractual waiver or limitation. - -The warranty applies only to the unmodified portion of the Program. IBM does not warrant uninterrupted or error-free operation of the Program, or that IBM will correct all Program defects. Licensee is responsible for the results obtained from the use of the Program. - -During the Warranty Period, IBM provides Licensee with access to IBM databases containing information on known Program defects, defect corrections, restrictions, and bypasses at no additional charge. Consult the IBM Software Support Handbook for further information at www.ibm.com/software/support. - -If the Program does not function as warranted during the Warranty Period and the problem cannot be resolved with information available in the IBM databases, Licensee may return the Program and its PoE to the party (either IBM or its reseller) from whom Licensee obtained it and receive a refund of the amount Licensee paid. After returning the Program, Licensee's license terminates. If Licensee downloaded the Program, Licensee should contact the party from whom Licensee obtained it for instructions on how to obtain the refund. - -8.2 Exclusions - -THESE WARRANTIES ARE LICENSEE'S EXCLUSIVE WARRANTIES AND REPLACE ALL OTHER WARRANTIES OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. SOME STATES OR JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF EXPRESS OR IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO LICENSEE. IN THAT EVENT, SUCH WARRANTIES ARE LIMITED IN DURATION TO THE WARRANTY PERIOD. NO WARRANTIES APPLY AFTER THAT PERIOD. SOME STATES OR JURISDICTIONS DO NOT ALLOW LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY LASTS, SO THE ABOVE LIMITATION MAY NOT APPLY TO LICENSEE. - -THESE WARRANTIES GIVE LICENSEE SPECIFIC LEGAL RIGHTS. LICENSEE MAY ALSO HAVE OTHER RIGHTS THAT VARY FROM STATE TO STATE OR JURISDICTION TO JURISDICTION. - -THE WARRANTIES IN THIS SECTION 8 (WARRANTY AND EXCLUSIONS) ARE PROVIDED SOLELY BY IBM. THE DISCLAIMERS IN THIS SUBSECTION 8.2 (EXCLUSIONS), HOWEVER, ALSO APPLY TO IBM'S SUPPLIERS OF THIRD PARTY CODE. THOSE SUPPLIERS PROVIDE SUCH CODE WITHOUT WARRANTIES OR CONDITION OF ANY KIND. THIS PARAGRAPH DOES NOT NULLIFY IBM'S WARRANTY OBLIGATIONS UNDER THIS AGREEMENT. - -9. Licensee Data and Databases - -To assist Licensee in isolating the cause of a problem with the Program, IBM may request that Licensee 1) allow IBM to remotely access Licensee's system or 2) send Licensee information or system data to IBM. However, IBM is not obligated to provide such assistance unless IBM and Licensee enter a separate written agreement under which IBM agrees to provide to Licensee that type of support, which is beyond IBM's warranty obligations in this Agreement. In any event, IBM uses information about errors and problems to improve its products and services, and assist with its provision of related support offerings. For these purposes, IBM may use IBM entities and subcontractors (including in one or more countries other than the one in which Licensee is located), and Licensee authorizes IBM to do so. - -Licensee remains responsible for 1) any data and the content of any database Licensee makes available to IBM, 2) the selection and implementation of procedures and controls regarding access, security, encryption, use, and transmission of data (including any personally-identifiable data), and 3) backup and recovery of any database and any stored data. Licensee will not send or provide IBM access to any personally-identifiable information, whether in data or any other form, and will be responsible for reasonable costs and other amounts that IBM may incur relating to any such information mistakenly provided to IBM or the loss or disclosure of such information by IBM, including those arising out of any third party claims. - -10. Limitation of Liability - -The limitations and exclusions in this Section 10 (Limitation of Liability) apply to the full extent they are not prohibited by applicable law without the possibility of contractual waiver. - -10.1 Items for Which IBM May Be Liable - -Circumstances may arise where, because of a default on IBM's part or other liability, Licensee is entitled to recover damages from IBM. Regardless of the basis on which Licensee is entitled to claim damages from IBM (including fundamental breach, negligence, misrepresentation, or other contract or tort claim), IBM's entire liability for all claims in the aggregate arising from or related to each Program or otherwise arising under this Agreement will not exceed the amount of any 1) damages for bodily injury (including death) and damage to real property and tangible personal property and 2) other actual direct damages up to the charges (if the Program is subject to fixed term charges, up to twelve months' charges) Licensee paid for the Program that is the subject of the claim. - -This limit also applies to any of IBM's Program developers and suppliers. It is the maximum for which IBM and its Program developers and suppliers are collectively responsible. - -10.2 Items for Which IBM Is Not Liable - -UNDER NO CIRCUMSTANCES IS IBM, ITS PROGRAM DEVELOPERS OR SUPPLIERS LIABLE FOR ANY OF THE FOLLOWING, EVEN IF INFORMED OF THEIR POSSIBILITY: - -a. LOSS OF, OR DAMAGE TO, DATA; - -b. SPECIAL, INCIDENTAL, EXEMPLARY, OR INDIRECT DAMAGES, OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES; OR - -c. LOST PROFITS, BUSINESS, REVENUE, GOODWILL, OR ANTICIPATED SAVINGS. - -11. Compliance Verification - -For purposes of this Section 11 (Compliance Verification), "IPLA Program Terms" means 1) this Agreement and applicable amendments and transaction documents provided by IBM, and 2) IBM software policies that may be found at the IBM Software Policy website (www.ibm.com/softwarepolicies), including but not limited to those policies concerning backup, sub-capacity pricing, and migration. - -The rights and obligations set forth in this Section 11 remain in effect during the period the Program is licensed to Licensee, and for two years thereafter. - -11.1 Verification Process - -Licensee agrees to create, retain, and provide to IBM and its auditors accurate written records, system tool outputs, and other system information sufficient to provide auditable verification that Licensee's use of all Programs is in compliance with the IPLA Program Terms, including, without limitation, all of IBM's applicable licensing and pricing qualification terms. Licensee is responsible for 1) ensuring that it does not exceed its Authorized Use, and 2) remaining in compliance with IPLA Program Terms. - -Upon reasonable notice, IBM may verify Licensee's compliance with IPLA Program Terms at all sites and for all environments in which Licensee uses (for any purpose) Programs subject to IPLA Program Terms. Such verification will be conducted in a manner that minimizes disruption to Licensee's business, and may be conducted on Licensee's premises, during normal business hours. IBM may use an independent auditor to assist with such verification, provided IBM has a written confidentiality agreement in place with such auditor. - -11.2 Resolution - -IBM will notify Licensee in writing if any such verification indicates that Licensee has used any Program in excess of its Authorized Use or is otherwise not in compliance with the IPLA Program Terms. Licensee agrees to promptly pay directly to IBM the charges that IBM specifies in an invoice for 1) any such excess use, 2) support for such excess use for the lesser of the duration of such excess use or two years, and 3) any additional charges and other liabilities determined as a result of such verification. - -12. Third Party Notices - -The Program may include third party code that IBM, not the third party, licenses to Licensee under this Agreement. Notices, if any, for the third party code ("Third Party Notices") are included for Licensee's information only. These notices can be found in the Program's NOTICES file(s). Information on how to obtain source code for certain third party code can be found in the Third Party Notices. If in the Third Party Notices IBM identifies third party code as "Modifiable Third Party Code," IBM authorizes Licensee to 1) modify the Modifiable Third Party Code and 2) reverse engineer the Program modules that directly interface with the Modifiable Third Party Code provided that it is only for the purpose of debugging Licensee's modifications to such third party code. IBM's service and support obligations, if any, apply only to the unmodified Program. - -13. General - -a. Nothing in this Agreement affects any statutory rights of consumers that cannot be waived or limited by contract. - -b. For Programs IBM provides to Licensee in tangible form, IBM fulfills its shipping and delivery obligations upon the delivery of such Programs to the IBM-designated carrier, unless otherwise agreed to in writing by Licensee and IBM. - -c. If any provision of this Agreement is held to be invalid or unenforceable, the remaining provisions of this Agreement remain in full force and effect. - -d. Licensee agrees to comply with all applicable export and import laws and regulations, including U.S. embargo and sanctions regulations and prohibitions on export for certain end uses or to certain users. - -e. Licensee authorizes International Business Machines Corporation and its subsidiaries (and their successors and assigns, contractors and IBM Business Partners) to store and use Licensee's business contact information wherever they do business, in connection with IBM products and services, or in furtherance of IBM's business relationship with Licensee. - -f. Each party will allow the other reasonable opportunity to comply before it claims that the other has not met its obligations under this Agreement. The parties will attempt in good faith to resolve all disputes, disagreements, or claims between the parties relating to this Agreement. - -g. Unless otherwise required by applicable law without the possibility of contractual waiver or limitation: 1) neither party will bring a legal action, regardless of form, for any claim arising out of or related to this Agreement more than two years after the cause of action arose; and 2) upon the expiration of such time limit, any such claim and all respective rights related to the claim lapse. - -h. Neither Licensee nor IBM is responsible for failure to fulfill any obligations due to causes beyond its control. - -i. No right or cause of action for any third party is created by this Agreement, nor is IBM responsible for any third party claims against Licensee, except as permitted in Subsection 10.1 (Items for Which IBM May Be Liable) above for bodily injury (including death) or damage to real or tangible personal property for which IBM is legally liable to that third party. - -j. In entering into this Agreement, neither party is relying on any representation not specified in this Agreement, including but not limited to any representation concerning: 1) the performance or function of the Program, other than as expressly warranted in Section 8 (Warranty and Exclusions) above; 2) the experiences or recommendations of other parties; or 3) any results or savings that Licensee may achieve. - -k. IBM has signed agreements with certain organizations (called "IBM Business Partners") to promote, market, and support certain Programs. IBM Business Partners remain independent and separate from IBM. IBM is not responsible for the actions or statements of IBM Business Partners or obligations they have to Licensee. - -l. The license and intellectual property indemnification terms of Licensee's other agreements with IBM (such as the IBM Customer Agreement) do not apply to Program licenses granted under this Agreement. - -14. Geographic Scope and Governing Law - -14.1 Governing Law - -Both parties agree to the application of the laws of the country in which Licensee obtained the Program license to govern, interpret, and enforce all of Licensee's and IBM's respective rights, duties, and obligations arising from, or relating in any manner to, the subject matter of this Agreement, without regard to conflict of law principles. - -The United Nations Convention on Contracts for the International Sale of Goods does not apply. - -14.2 Jurisdiction - -All rights, duties, and obligations are subject to the courts of the country in which Licensee obtained the Program license. - -Part 2 - Country-unique Terms - -For licenses granted in the countries specified below, the following terms replace or modify the referenced terms in Part 1. All terms in Part 1 that are not changed by these amendments remain unchanged and in effect. This Part 2 is organized as follows: - -* Multiple country amendments to Part 1, Section 14 (Governing Law and Jurisdiction); - -* Americas country amendments to other Agreement terms; - -* Asia Pacific country amendments to other Agreement terms; and - -* Europe, Middle East, and Africa country amendments to other Agreement terms. - -Multiple country amendments to Part 1, Section 14 (Governing Law and Jurisdiction) - -14.1 Governing Law - -The phrase "the laws of the country in which Licensee obtained the Program license" in the first paragraph of 14.1 Governing Law is replaced by the following phrases in the countries below: - -AMERICAS - -(1) In Canada: the laws in the Province of Ontario; - -(2) in Mexico: the federal laws of the Republic of Mexico; - -(3) in the United States, Anguilla, Antigua/Barbuda, Aruba, British Virgin Islands, Cayman Islands, Dominica, Grenada, Guyana, Saint Kitts and Nevis, Saint Lucia, Saint Maarten, and Saint Vincent and the Grenadines: the laws of the State of New York, United States; - -(4) in Venezuela: the laws of the Bolivarian Republic of Venezuela; - -ASIA PACIFIC - -(5) in Cambodia and Laos: the laws of the State of New York, United States; - -(6) in Australia: the laws of the State or Territory in which the transaction is performed; - -(7) in Hong Kong SAR and Macau SAR: the laws of Hong Kong Special Administrative Region ("SAR"); - -(8) in Taiwan: the laws of Taiwan; - -EUROPE, MIDDLE EAST, AND AFRICA - -(9) in Albania, Armenia, Azerbaijan, Belarus, Bosnia-Herzegovina, Bulgaria, Croatia, Former Yugoslav Republic of Macedonia, Georgia, Hungary, Kazakhstan, Kyrgyzstan, Moldova, Montenegro, Poland, Romania, Russia, Serbia, Slovakia, Tajikistan, Turkmenistan, Ukraine, and Uzbekistan: the laws of Austria; - -(10) in Algeria, Andorra, Benin, Burkina Faso, Cameroon, Cape Verde, Central African Republic, Chad, Comoros, Congo Republic, Djibouti, Democratic Republic of Congo, Equatorial Guinea, French Guiana, French Polynesia, Gabon, Gambia, Guinea, Guinea-Bissau, Ivory Coast, Lebanon, Madagascar, Mali, Mauritania, Mauritius, Mayotte, Morocco, New Caledonia, Niger, Reunion, Senegal, Seychelles, Togo, Tunisia, Vanuatu, and Wallis and Futuna: the laws of France; - -(11) in Estonia, Latvia, and Lithuania: the laws of Finland; - -(12) in Angola, Bahrain, Botswana, Burundi, Egypt, Eritrea, Ethiopia, Ghana, Jordan, Kenya, Kuwait, Liberia, Malawi, Malta, Mozambique, Nigeria, Oman, Pakistan, Qatar, Rwanda, Sao Tome and Principe, Saudi Arabia, Sierra Leone, Somalia, Tanzania, Uganda, United Arab Emirates, the United Kingdom, West Bank/Gaza, Yemen, Zambia, and Zimbabwe: the laws of England; and - -(13) in South Africa, Namibia, Lesotho, and Swaziland: the laws of the Republic of South Africa. - -14.2 Jurisdiction - -The following paragraph pertains to jurisdiction and replaces Subsection 14.2 (Jurisdiction) as it applies for those countries identified below: - -All rights, duties, and obligations are subject to the courts of the country in which Licensee obtained the Program license except that in the countries identified below all disputes arising out of or related to this Agreement, including summary proceedings, will be brought before and subject to the exclusive jurisdiction of the following courts of competent jurisdiction: - -AMERICAS - -(1) In Argentina: the Ordinary Commercial Court of the city of Buenos Aires; - -(2) in Brazil: the court of Rio de Janeiro, RJ; - -(3) in Chile: the Civil Courts of Justice of Santiago; - -(4) in Ecuador: the civil judges of Quito for executory or summary proceedings (as applicable); - -(5) in Mexico: the courts located in Mexico City, Federal District; - -(6) in Peru: the judges and tribunals of the judicial district of Lima, Cercado; - -(7) in Uruguay: the courts of the city of Montevideo; - -(8) in Venezuela: the courts of the metropolitan area of the city of Caracas; - -EUROPE, MIDDLE EAST, AND AFRICA - -(9) in Austria: the court of law in Vienna, Austria (Inner-City); - -(10) in Algeria, Andorra, Benin, Burkina Faso, Cameroon, Cape Verde, Central African Republic, Chad, Comoros, Congo Republic, Djibouti, Democratic Republic of Congo, Equatorial Guinea, France, French Guiana, French Polynesia, Gabon, Gambia, Guinea, Guinea-Bissau, Ivory Coast, Lebanon, Madagascar, Mali, Mauritania, Mauritius, Mayotte, Monaco, Morocco, New Caledonia, Niger, Reunion, Senegal, Seychelles, Togo, Tunisia, Vanuatu, and Wallis and Futuna: the Commercial Court of Paris; - -(11) in Angola, Bahrain, Botswana, Burundi, Egypt, Eritrea, Ethiopia, Ghana, Jordan, Kenya, Kuwait, Liberia, Malawi, Malta, Mozambique, Nigeria, Oman, Pakistan, Qatar, Rwanda, Sao Tome and Principe, Saudi Arabia, Sierra Leone, Somalia, Tanzania, Uganda, United Arab Emirates, the United Kingdom, West Bank/Gaza, Yemen, Zambia, and Zimbabwe: the English courts; - -(12) in South Africa, Namibia, Lesotho, and Swaziland: the High Court in Johannesburg; - -(13) in Greece: the competent court of Athens; - -(14) in Israel: the courts of Tel Aviv-Jaffa; - -(15) in Italy: the courts of Milan; - -(16) in Portugal: the courts of Lisbon; - -(17) in Spain: the courts of Madrid; and - -(18) in Turkey: the Istanbul Central Courts and Execution Directorates of Istanbul, the Republic of Turkey. - -14.3 Arbitration - -The following paragraph is added as a new Subsection 14.3 (Arbitration) as it applies for those countries identified below. The provisions of this Subsection 14.3 prevail over those of Subsection 14.2 (Jurisdiction) to the extent permitted by the applicable governing law and rules of procedure: - -ASIA PACIFIC - -(1) In Cambodia, India, Laos, Philippines, and Vietnam: - -Disputes arising out of or in connection with this Agreement will be finally settled by arbitration which will be held in Singapore in accordance with the Arbitration Rules of Singapore International Arbitration Center ("SIAC Rules") then in effect. The arbitration award will be final and binding for the parties without appeal and will be in writing and set forth the findings of fact and the conclusions of law. - -The number of arbitrators will be three, with each side to the dispute being entitled to appoint one arbitrator. The two arbitrators appointed by the parties will appoint a third arbitrator who will act as chairman of the proceedings. Vacancies in the post of chairman will be filled by the president of the SIAC. Other vacancies will be filled by the respective nominating party. Proceedings will continue from the stage they were at when the vacancy occurred. - -If one of the parties refuses or otherwise fails to appoint an arbitrator within 30 days of the date the other party appoints its, the first appointed arbitrator will be the sole arbitrator, provided that the arbitrator was validly and properly appointed. - -All proceedings will be conducted, including all documents presented in such proceedings, in the English language. The English language version of this Agreement prevails over any other language version. - -(2) In the People's Republic of China: - -In case no settlement can be reached, the disputes will be submitted to China International Economic and Trade Arbitration Commission for arbitration according to the then effective rules of the said Arbitration Commission. The arbitration will take place in Beijing and be conducted in Chinese. The arbitration award will be final and binding on both parties. During the course of arbitration, this agreement will continue to be performed except for the part which the parties are disputing and which is undergoing arbitration. - -(3) In Indonesia: - -Each party will allow the other reasonable opportunity to comply before it claims that the other has not met its obligations under this Agreement. The parties will attempt in good faith to resolve all disputes, disagreements, or claims between the parties relating to this Agreement. Unless otherwise required by applicable law without the possibility of contractual waiver or limitation, i) neither party will bring a legal action, regardless of form, arising out of or related to this Agreement or any transaction under it more than two years after the cause of action arose; and ii) after such time limit, any legal action arising out of this Agreement or any transaction under it and all respective rights related to any such action lapse. - -Disputes arising out of or in connection with this Agreement shall be finally settled by arbitration that shall be held in Jakarta, Indonesia in accordance with the rules of Board of the Indonesian National Board of Arbitration (Badan Arbitrase Nasional Indonesia or "BANI") then in effect. The arbitration award shall be final and binding for the parties without appeal and shall be in writing and set forth the findings of fact and the conclusions of law. - -The number of arbitrators shall be three, with each side to the dispute being entitled to appoint one arbitrator. The two arbitrators appointed by the parties shall appoint a third arbitrator who shall act as chairman of the proceedings. Vacancies in the post of chairman shall be filled by the chairman of the BANI. Other vacancies shall be filled by the respective nominating party. Proceedings shall continue from the stage they were at when the vacancy occurred. - -If one of the parties refuses or otherwise fails to appoint an arbitrator within 30 days of the date the other party appoints its, the first appointed arbitrator shall be the sole arbitrator, provided that the arbitrator was validly and properly appointed. - -All proceedings shall be conducted, including all documents presented in such proceedings, in the English and/or Indonesian language. - -EUROPE, MIDDLE EAST, AND AFRICA - -(4) In Albania, Armenia, Azerbaijan, Belarus, Bosnia-Herzegovina, Bulgaria, Croatia, Former Yugoslav Republic of Macedonia, Georgia, Hungary, Kazakhstan, Kyrgyzstan, Moldova, Montenegro, Poland, Romania, Russia, Serbia, Slovakia, Tajikistan, Turkmenistan, Ukraine, and Uzbekistan: - -All disputes arising out of this Agreement or related to its violation, termination or nullity will be finally settled under the Rules of Arbitration and Conciliation of the International Arbitral Center of the Federal Economic Chamber in Vienna (Vienna Rules) by three arbitrators appointed in accordance with these rules. The arbitration will be held in Vienna, Austria, and the official language of the proceedings will be English. The decision of the arbitrators will be final and binding upon both parties. Therefore, pursuant to paragraph 598 (2) of the Austrian Code of Civil Procedure, the parties expressly waive the application of paragraph 595 (1) figure 7 of the Code. IBM may, however, institute proceedings in a competent court in the country of installation. - -(5) In Estonia, Latvia, and Lithuania: - -All disputes arising in connection with this Agreement will be finally settled in arbitration that will be held in Helsinki, Finland in accordance with the arbitration laws of Finland then in effect. Each party will appoint one arbitrator. The arbitrators will then jointly appoint the chairman. If arbitrators cannot agree on the chairman, then the Central Chamber of Commerce in Helsinki will appoint the chairman. - -AMERICAS COUNTRY AMENDMENTS - -CANADA - -10.1 Items for Which IBM May be Liable - -The following replaces Item 1 in the first paragraph of this Subsection 10.1 (Items for Which IBM May be Liable): - -1) damages for bodily injury (including death) and physical harm to real property and tangible personal property caused by IBM's negligence; and - -13. General - -The following replaces Item 13.d: - -d. Licensee agrees to comply with all applicable export and import laws and regulations, including those of that apply to goods of United States origin and that prohibit or limit export for certain uses or to certain users. - -The following replaces Item 13.i: - -i. No right or cause of action for any third party is created by this Agreement or any transaction under it, nor is IBM responsible for any third party claims against Licensee except as permitted by the Limitation of Liability section above for bodily injury (including death) or physical harm to real or tangible personal property caused by IBM's negligence for which IBM is legally liable to that third party. - -The following is added as Item 13.m: - -m. For purposes of this Item 13.m, "Personal Data" refers to information relating to an identified or identifiable individual made available by one of the parties, its personnel or any other individual to the other in connection with this Agreement. The following provisions apply in the event that one party makes Personal Data available to the other: - -(1) General - -(a) Each party is responsible for complying with any obligations applying to it under applicable Canadian data privacy laws and regulations ("Laws"). - -(b) Neither party will request Personal Data beyond what is necessary to fulfill the purpose(s) for which it is requested. The purpose(s) for requesting Personal Data must be reasonable. Each party will agree in advance as to the type of Personal Data that is required to be made available. - -(2) Security Safeguards - -(a) Each party acknowledges that it is solely responsible for determining and communicating to the other the appropriate technological, physical and organizational security measures required to protect Personal Data. - -(b) Each party will ensure that Personal Data is protected in accordance with the security safeguards communicated and agreed to by the other. - -(c) Each party will ensure that any third party to whom Personal Data is transferred is bound by the applicable terms of this section. - -(d) Additional or different services required to comply with the Laws will be deemed a request for new services. - -(3) Use - -Each party agrees that Personal Data will only be used, accessed, managed, transferred, disclosed to third parties or otherwise processed to fulfill the purpose(s) for which it was made available. - -(4) Access Requests - -(a) Each party agrees to reasonably cooperate with the other in connection with requests to access or amend Personal Data. - -(b) Each party agrees to reimburse the other for any reasonable charges incurred in providing each other assistance. - -(c) Each party agrees to amend Personal Data only upon receiving instructions to do so from the other party or its personnel. - -(5) Retention - -Each party will promptly return to the other or destroy all Personal Data that is no longer necessary to fulfill the purpose(s) for which it was made available, unless otherwise instructed by the other or its personnel or required by law. - -(6) Public Bodies Who Are Subject to Public Sector Privacy Legislation - -For Licensees who are public bodies subject to public sector privacy legislation, this Item 13.m applies only to Personal Data made available to Licensee in connection with this Agreement, and the obligations in this section apply only to Licensee, except that: 1) section (2)(a) applies only to IBM; 2) sections (1)(a) and (4)(a) apply to both parties; and 3) section (4)(b) and the last sentence in (1)(b) do not apply. - -PERU - -10. Limitation of Liability - -The following is added to the end of this Section 10 (Limitation of Liability): - -Except as expressly required by law without the possibility of contractual waiver, Licensee and IBM intend that the limitation of liability in this Limitation of Liability section applies to damages caused by all types of claims and causes of action. If any limitation on or exclusion from liability in this section is held by a court of competent jurisdiction to be unenforceable with respect to a particular claim or cause of action, the parties intend that it nonetheless apply to the maximum extent permitted by applicable law to all other claims and causes of action. - -10.1 Items for Which IBM May be Liable - -The following is added at the end of this Subsection 10.1: - -In accordance with Article 1328 of the Peruvian Civil Code, the limitations and exclusions specified in this section will not apply to damages caused by IBM's willful misconduct ("dolo") or gross negligence ("culpa inexcusable"). - -UNITED STATES OF AMERICA - -5. Taxes - -The following is added at the end of this Section 5 (Taxes) - -For Programs delivered electronically in the United States for which Licensee claims a state sales and use tax exemption, Licensee agrees not to receive any tangible personal property (e.g., media and publications) associated with the electronic program. - -Licensee agrees to be responsible for any sales and use tax liabilities that may arise as a result of Licensee's subsequent redistribution of Programs after delivery by IBM. - -13. General - -The following is added to Section 13 as Item 13.m: - -U.S. Government Users Restricted Rights - Use, duplication or disclosure is restricted by the GSA IT Schedule 70 Contract with the IBM Corporation. - -The following is added to Item 13.f: - -Each party waives any right to a jury trial in any proceeding arising out of or related to this Agreement. - -ASIA PACIFIC COUNTRY AMENDMENTS - -AUSTRALIA - -5. Taxes - -The following sentences replace the first two sentences of Section 5 (Taxes): - -If any government or authority imposes a duty, tax (other than income tax), levy, or fee, on this Agreement or on the Program itself, that is not otherwise provided for in the amount payable, Licensee agrees to pay it when IBM invoices Licensee. If the rate of GST changes, IBM may adjust the charge or other amount payable to take into account that change from the date the change becomes effective. - -8.1 Limited Warranty - -The following is added to Subsection 8.1 (Limited Warranty): - -The warranties specified this Section are in addition to any rights Licensee may have under the Competition and Consumer Act 2010 or other legislation and are only limited to the extent permitted by the applicable legislation. - -10.1 Items for Which IBM May be Liable - -The following is added to Subsection 10.1 (Items for Which IBM May be Liable): - -Where IBM is in breach of a condition or warranty implied by the Competition and Consumer Act 2010, IBM's liability is limited to the repair or replacement of the goods, or the supply of equivalent goods. Where that condition or warranty relates to right to sell, quiet possession or clear title, or the goods are of a kind ordinarily obtained for personal, domestic or household use or consumption, then none of the limitations in this paragraph apply. - -HONG KONG SAR, MACAU SAR, AND TAIWAN - -As applies to licenses obtained in Taiwan and the special administrative regions, phrases throughout this Agreement containing the word "country" (for example, "the country in which the original Licensee was granted the license" and "the country in which Licensee obtained the Program license") are replaced with the following: - -(1) In Hong Kong SAR: "Hong Kong SAR" - -(2) In Macau SAR: "Macau SAR" except in the Governing Law clause (Section 14.1) - -(3) In Taiwan: "Taiwan." - -INDIA - -10.1 Items for Which IBM May be Liable - -The following replaces the terms of Items 1 and 2 of the first paragraph: - -1) liability for bodily injury (including death) or damage to real property and tangible personal property will be limited to that caused by IBM's negligence; and 2) as to any other actual damage arising in any situation involving nonperformance by IBM pursuant to, or in any way related to the subject of this Agreement, IBM's liability will be limited to the charge paid by Licensee for the individual Program that is the subject of the claim. - -13. General - -The following replaces the terms of Item 13.g: - -If no suit or other legal action is brought, within three years after the cause of action arose, in respect of any claim that either party may have against the other, the rights of the concerned party in respect of such claim will be forfeited and the other party will stand released from its obligations in respect of such claim. - -INDONESIA - -3.3 Term and Termination - -The following is added to the last paragraph: - -Both parties waive the provision of article 1266 of the Indonesian Civil Code, to the extent the article provision requires such court decree for the termination of an agreement creating mutual obligations. - -JAPAN - -13. General - -The following is inserted after Item 13.f: - -Any doubts concerning this Agreement will be initially resolved between us in good faith and in accordance with the principle of mutual trust. - -MALAYSIA - -10.2 Items for Which IBM Is not Liable - -The word "SPECIAL" in Item 10.2b is deleted. - -NEW ZEALAND - -8.1 Limited Warranty - -The following is added: - -The warranties specified in this Section are in addition to any rights Licensee may have under the Consumer Guarantees Act 1993 or other legislation which cannot be excluded or limited. The Consumer Guarantees Act 1993 will not apply in respect of any goods which IBM provides, if Licensee requires the goods for the purposes of a business as defined in that Act. - -10. Limitation of Liability - -The following is added: - -Where Programs are not obtained for the purposes of a business as defined in the Consumer Guarantees Act 1993, the limitations in this Section are subject to the limitations in that Act. - -PEOPLE'S REPUBLIC OF CHINA - -4. Charges - -The following is added: - -All banking charges incurred in the People's Republic of China will be borne by Licensee and those incurred outside the People's Republic of China will be borne by IBM. - -PHILIPPINES - -10.2 Items for Which IBM Is not Liable - -The following replaces the terms of Item 10.2b: - -b. special (including nominal and exemplary damages), moral, incidental, or indirect damages or for any economic consequential damages; or - -SINGAPORE - -10.2 Items for Which IBM Is not Liable - -The words "SPECIAL" and "ECONOMIC" are deleted from Item 10.2b. - -13. General - -The following replaces the terms of Item 13.i: - -Subject to the rights provided to IBM's suppliers and Program developers as provided in Section 10 above (Limitation of Liability), a person who is not a party to this Agreement will have no right under the Contracts (Right of Third Parties) Act to enforce any of its terms. - -TAIWAN - -8.1 Limited Warranty - -The last paragraph is deleted. - -10.1 Items for Which IBM May Be Liable - -The following sentences are deleted: - -This limit also applies to any of IBM's subcontractors and Program developers. It is the maximum for which IBM and its subcontractors and Program developers are collectively responsible. - -EUROPE, MIDDLE EAST, AFRICA (EMEA) COUNTRY AMENDMENTS - -EUROPEAN UNION MEMBER STATES - -8. Warranty and Exclusions - -The following is added to Section 8 (Warranty and Exclusion): - -In the European Union ("EU"), consumers have legal rights under applicable national legislation governing the sale of consumer goods. Such rights are not affected by the provisions set out in this Section 8 (Warranty and Exclusions). The territorial scope of the Limited Warranty is worldwide. - -EU MEMBER STATES AND THE COUNTRIES IDENTIFIED BELOW - -Iceland, Liechtenstein, Norway, Switzerland, Turkey, and any other European country that has enacted local data privacy or protection legislation similar to the EU model. - -13. General - -The following replaces Item 13.e: - -(1) Definitions - For the purposes of this Item 13.e, the following additional definitions apply: - -(a) Business Contact Information - business-related contact information disclosed by Licensee to IBM, including names, job titles, business addresses, telephone numbers and email addresses of Licensee's employees and contractors. For Austria, Italy and Switzerland, Business Contact Information also includes information about Licensee and its contractors as legal entities (for example, Licensee's revenue data and other transactional information) - -(b) Business Contact Personnel - Licensee employees and contractors to whom the Business Contact Information relates. - -(c) Data Protection Authority - the authority established by the Data Protection and Electronic Communications Legislation in the applicable country or, for non-EU countries, the authority responsible for supervising the protection of personal data in that country, or (for any of the foregoing) any duly appointed successor entity thereto. - -(d) Data Protection & Electronic Communications Legislation - (i) the applicable local legislation and regulations in force implementing the requirements of EU Directive 95/46/EC (on the protection of individuals with regard to the processing of personal data and on the free movement of such data) and of EU Directive 2002/58/EC (concerning the processing of personal data and the protection of privacy in the electronic communications sector); or (ii) for non-EU countries, the legislation and/or regulations passed in the applicable country relating to the protection of personal data and the regulation of electronic communications involving personal data, including (for any of the foregoing) any statutory replacement or modification thereof. - -(e) IBM Group - International Business Machines Corporation of Armonk, New York, USA, its subsidiaries, and their respective Business Partners and subcontractors. - -(2) Licensee authorizes IBM: - -(a) to process and use Business Contact Information within IBM Group in support of Licensee including the provision of support services, and for the purpose of furthering the business relationship between Licensee and IBM Group, including, without limitation, contacting Business Contact Personnel (by email or otherwise) and marketing IBM Group products and services (the "Specified Purpose"); and - -(b) to disclose Business Contact Information to other members of IBM Group in pursuit of the Specified Purpose only. - -(3) IBM agrees that all Business Contact Information will be processed in accordance with the Data Protection & Electronic Communications Legislation and will be used only for the Specified Purpose. - -(4) To the extent required by the Data Protection & Electronic Communications Legislation, Licensee represents that (a) it has obtained (or will obtain) any consents from (and has issued (or will issue) any notices to) the Business Contact Personnel as are necessary in order to enable IBM Group to process and use the Business Contact Information for the Specified Purpose. - -(5) Licensee authorizes IBM to transfer Business Contact Information outside the European Economic Area, provided that the transfer is made on contractual terms approved by the Data Protection Authority or the transfer is otherwise permitted under the Data Protection & Electronic Communications Legislation. - -AUSTRIA - -8.2 Exclusions - -The following is deleted from the first paragraph: - -MERCHANTABILITY, SATISFACTORY QUALITY - -10. Limitation of Liability - -The following is added: - -The following limitations and exclusions of IBM's liability do not apply for damages caused by gross negligence or willful misconduct. - -10.1 Items for Which IBM May Be Liable - -The following replaces the first sentence in the first paragraph: - -Circumstances may arise where, because of a default by IBM in the performance of its obligations under this Agreement or other liability, Licensee is entitled to recover damages from IBM. - -In the second sentence of the first paragraph, delete entirely the parenthetical phrase: - -"(including fundamental breach, negligence, misrepresentation, or other contract or tort claim)". - -10.2 Items for Which IBM Is Not Liable - -The following replaces Item 10.2b: - -b. indirect damages or consequential damages; or - -BELGIUM, FRANCE, ITALY, AND LUXEMBOURG - -10. Limitation of Liability - -The following replaces the terms of Section 10 (Limitation of Liability) in its entirety: - -Except as otherwise provided by mandatory law: - -10.1 Items for Which IBM May Be Liable - -IBM's entire liability for all claims in the aggregate for any damages and losses that may arise as a consequence of the fulfillment of its obligations under or in connection with this Agreement or due to any other cause related to this Agreement is limited to the compensation of only those damages and losses proved and actually arising as an immediate and direct consequence of the non-fulfillment of such obligations (if IBM is at fault) or of such cause, for a maximum amount equal to the charges (if the Program is subject to fixed term charges, up to twelve months' charges) Licensee paid for the Program that has caused the damages. - -The above limitation will not apply to damages for bodily injuries (including death) and damages to real property and tangible personal property for which IBM is legally liable. - -10.2 Items for Which IBM Is Not Liable - -UNDER NO CIRCUMSTANCES IS IBM OR ANY OF ITS PROGRAM DEVELOPERS LIABLE FOR ANY OF THE FOLLOWING, EVEN IF INFORMED OF THEIR POSSIBILITY: 1) LOSS OF, OR DAMAGE TO, DATA; 2) INCIDENTAL, EXEMPLARY OR INDIRECT DAMAGES, OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES; AND / OR 3) LOST PROFITS, BUSINESS, REVENUE, GOODWILL, OR ANTICIPATED SAVINGS, EVEN IF THEY ARISE AS AN IMMEDIATE CONSEQUENCE OF THE EVENT THAT GENERATED THE DAMAGES. - -10.3 Suppliers and Program Developers - -The limitation and exclusion of liability herein agreed applies not only to the activities performed by IBM but also to the activities performed by its suppliers and Program developers, and represents the maximum amount for which IBM as well as its suppliers and Program developers are collectively responsible. - -GERMANY - -8.1 Limited Warranty - -The following is inserted at the beginning of Section 8.1: - -The Warranty Period is twelve months from the date of delivery of the Program to the original Licensee. - -8.2 Exclusions - -Section 8.2 is deleted in its entirety and replaced with the following: - -Section 8.1 defines IBM's entire warranty obligations to Licensee except as otherwise required by applicable statutory law. - -10. Limitation of Liability - -The following replaces the Limitation of Liability section in its entirety: - -a. IBM will be liable without limit for 1) loss or damage caused by a breach of an express guarantee; 2) damages or losses resulting in bodily injury (including death); and 3) damages caused intentionally or by gross negligence. - -b. In the event of loss, damage and frustrated expenditures caused by slight negligence or in breach of essential contractual obligations, IBM will be liable, regardless of the basis on which Licensee is entitled to claim damages from IBM (including fundamental breach, negligence, misrepresentation, or other contract or tort claim), per claim only up to the greater of 500,000 euro or the charges (if the Program is subject to fixed term charges, up to 12 months' charges) Licensee paid for the Program that caused the loss or damage. A number of defaults which together result in, or contribute to, substantially the same loss or damage will be treated as one default. - -c. In the event of loss, damage and frustrated expenditures caused by slight negligence, IBM will not be liable for indirect or consequential damages, even if IBM was informed about the possibility of such loss or damage. - -d. In case of delay on IBM's part: 1) IBM will pay to Licensee an amount not exceeding the loss or damage caused by IBM's delay and 2) IBM will be liable only in respect of the resulting damages that Licensee suffers, subject to the provisions of Items a and b above. - -13. General - -The following replaces the provisions of 13.g: - -Any claims resulting from this Agreement are subject to a limitation period of three years, except as stated in Section 8.1 (Limited Warranty) of this Agreement. - -The following replaces the provisions of 13.i: - -No right or cause of action for any third party is created by this Agreement, nor is IBM responsible for any third party claims against Licensee, except (to the extent permitted in Section 10 (Limitation of Liability)) for: i) bodily injury (including death); or ii) damage to real or tangible personal property for which (in either case) IBM is legally liable to that third party. - -IRELAND - -8.2 Exclusions - -The following paragraph is added: - -Except as expressly provided in these terms and conditions, or Section 12 of the Sale of Goods Act 1893 as amended by the Sale of Goods and Supply of Services Act, 1980 (the "1980 Act"), all conditions or warranties (express or implied, statutory or otherwise) are hereby excluded including, without limitation, any warranties implied by the Sale of Goods Act 1893 as amended by the 1980 Act (including, for the avoidance of doubt, Section 39 of the 1980 Act). - -IRELAND AND UNITED KINGDOM - -2. Agreement Structure - -The following sentence is added: - -Nothing in this paragraph shall have the effect of excluding or limiting liability for fraud. - -10.1 Items for Which IBM May Be Liable - -The following replaces the first paragraph of the Subsection: - -For the purposes of this section, a "Default" means any act, statement, omission or negligence on the part of IBM in connection with, or in relation to, the subject matter of an Agreement in respect of which IBM is legally liable to Licensee, whether in contract or in tort. A number of Defaults which together result in, or contribute to, substantially the same loss or damage will be treated as one Default. - -Circumstances may arise where, because of a Default by IBM in the performance of its obligations under this Agreement or other liability, Licensee is entitled to recover damages from IBM. Regardless of the basis on which Licensee is entitled to claim damages from IBM and except as expressly required by law without the possibility of contractual waiver, IBM's entire liability for any one Default will not exceed the amount of any direct damages, to the extent actually suffered by Licensee as an immediate and direct consequence of the default, up to the greater of (1) 500,000 euro (or the equivalent in local currency) or (2) 125% of the charges (if the Program is subject to fixed term charges, up to 12 months' charges) for the Program that is the subject of the claim. Notwithstanding the foregoing, the amount of any damages for bodily injury (including death) and damage to real property and tangible personal property for which IBM is legally liable is not subject to such limitation. - -10.2 Items for Which IBM is Not Liable - -The following replaces Items 10.2b and 10.2c: - -b. special, incidental, exemplary, or indirect damages or consequential damages; or - -c. wasted management time or lost profits, business, revenue, goodwill, or anticipated savings. - -Z125-3301-14 (07/2011) - - diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b3f41ef..0000000 --- a/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,13 +0,0 @@ - - -## Relevant issue, Epic or stories. - - -## Description of what this PR accomplishes and why it's needed -Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - -Link to ot4i-ace-docker test build: diff --git a/README.md b/README.md index d0cf02d..e9eb647 100644 --- a/README.md +++ b/README.md @@ -1,312 +1,61 @@ # Overview -IBM ACE logo +![IBM ACE logo](./app_connect_light_256x256.png) Run [IBM® App Connect Enterprise](https://developer.ibm.com/integration/docs/app-connect-enterprise/faq/) in a container. -You can build an image containing one of the following combinations: -- IBM App Connect Enterprise -- IBM App Connect Enterprise with IBM MQ Client -- IBM App Connect Enterprise for Developers -- IBM App Connect Enterprise for Developers with IBM MQ Client +This repo is designed to provide information about how to build a simple ACE container and how to extend it with extra capability as per the requirements of your use case. -The IBM App Connect operator now supports a single image which includes both the ACE server runtime as well as an MQ client. This readme will describe how you can build an equivalent image. - -Pre-built developer and production edition image can be found on IBM Container Registry - [Obtaining the IBM App Connect Enterprise server image from the IBM Cloud Container Registry](https://www.ibm.com/support/knowledgecenter/en/SSTTDS_11.0.0/com.ibm.ace.icp.doc/certc_install_obtaininstallationimageser.html) +If you would like to use pre-built containers please refer to [Pre-Built Containers](#pre-built-containers) +If your looking for information on the previous images that were documented in this repo, please refer to the previous [releases](https://github.com/ot4i/ace-docker/releases). The previous images are designed only for use with the App Connect operator. They are not designed for use in your own non operator led deployment. ## Building a container image -Download a copy of App Connect Enterprise (ie. `ace-12.0.1.0.tar.gz`) and place it in the `deps` folder. When building the image use `build-arg` to specify the name of the file: `--build-arg ACE_INSTALL=ace-12.0.1.0.tar.gz` - **Important:** Only ACE version **12.0.1.0 or greater** is supported. -Choose if you want to have an image with just App Connect Enterprise or an image with both App Connect Enterprise and the IBM MQ Client libraries. The second of these is used by the IBM App Connect operator. - -### Building a container image which contains an IBM Service provided fix for ACE - -You may have been provided with a fix for App Connect Enterprise by IBM Support, this fix will have a name of the form `12.0.X.Y-ACE-LinuxX64-TF12345.tar.gz`. This fix can be used to create a container image in one of two different ways: +Before building the image you must obtain a copy of the relavent build of ACE and make it available on a HTTP endpoint. -#### Installation during container image build -This method builds a new container image derived from an existing ACE container image and applies the ifix using the standard `mqsifixinst.sh` script. The ifix image can be built from any existing ACE container image, e.g. `ace-only`, `ace-mqclient`, or another ifix image. Simply build `Dockerfile.ifix` passing in the full `BASE_IMAGE` name and the `IFIX_ID` arguments set: +When using an insecure http endpoint, build the image using a command such as: ```bash -docker build -t ace-server:12.0.x.y-r1-tfit12345 --build-arg BASE_IMAGE=ace-server:12.0.x.y-1 --build-arg IFIX_ID=12.0.X.Y-ACE-LinuxX64-TFIT12345 --file ubi/Dockerfile.ifix path/to/folder/containing/ifix -``` - -#### Pre-applying the fix to the ACE install image -This method applies the ifix directly to the ACE installation image that is consumed to make the full container image. **NB**: Only follow these instructions if you have been instructed by IBM Support to "manually install" the ifix, or that the above method is not applicable to your issue. If you follow these instructions then the ifix ID will _not_ appear in the output of `mqsiservice -v`. - -In order to apply this fix manually follow these steps. - - On a local system extract the App Connect Enterprise archive - `tar -xvf ace-12.0.1.0.tar.gz` - - Extract the fix package into expanded App Connect Enterprise installation - `tar -xvf /path/to/12.0.1.0-ACE-LinuxX64-TF12345.tar.gz --directory ace-12.0.1.0` - - Tar and compress the resulting App Connect Enterprise installation - `tar -cvf ace-12.0.1.0_with_IT12345.tar ace-12.0.1.0` - `gzip ace-12.0.1.0_with_IT12345.tar` - - Place the resulting `ace-12.0.1.0_with_IT12345.tar.gz` file in the `deps` folder and when building using the `build-arg` to specify the name of the file: `--build-arg ACE_INSTALL=ace-12.0.1.0_with_IT12345.tar.gz` - -### Using App Connect Enterprise for Developers - -Get [ACE for Developers edition](https://www.ibm.com/marketing/iwm/iwm/web/pick.do?source=swg-wmbfd). Then place it in the `deps` folder as mentioned above. - -### Build an image with App Connect Enterprise only - -NOTE: The current dockerfiles are tailored towards use by the App Connect Operator and as a result may have function removed from it if we are no longer using it in our operator. If you prefer to use the old dockerfiles for building your containers please use the `Dockerfile-legacy.aceonly` file - - -The `deps` folder must contain a copy of ACE, **version 12.0.1.0 or greater**. If using ACE for Developers, download it from [here](https://www.ibm.com/marketing/iwm/iwm/web/pick.do?source=swg-wmbfd). -Then set the build argument `ACE_INSTALL` to the name of the ACE file placed in `deps`. - -1. ACE for Developers only: - - `docker build -t ace-dev-only --build-arg ACE_INSTALL={ACE-dev-file-in-deps-folder} --file ubi/Dockerfile.aceonly .` -2. ACE production only: - - `docker build -t ace-only --build-arg ACE_INSTALL={ACE-file-in-deps-folder} --file ubi/Dockerfile.aceonly .` - -### Build an image with App Connect Enterprise and MQ Client - -Follow the instructions above for building an image with App Connect Enterprise Only. - -Add the MQ Client libraries to your existing image by running `docker build -t ace-mqclient --build-arg BASE_IMAGE= --file ubi/Dockerfile.mqclient .` - -`` is the tag of the image you want to add the client libs to i.e. ace-only. You can supply a customer URL for the MQ binaries by setting the argument MQ_URL - -### Applying an iFix to an existing image - -If you need to apply an iFix to an existing image, this can be done using the following Dockerfile sample. It requires the iFix to use the mqsifixinst.sh installation method. - -```Dockerfile -ARG ACE_IMAGE=cp.icr.io/cp/appc/ace-server-prod@sha256:f31b9adcfd4a77ba8c62b92c6f34985ef1f2d53e8082f628f170013eaf4c9003 -FROM $ACE_IMAGE - -ENV IFIX_TAR=12.0.2.0-ACE-LinuxX64-TFIT38649.tar.gz -ADD $IFIX_TAR ./fix - -USER root - -RUN cd /home/aceuser/fix \ - && IFIX=${IFIX_TAR::${#IFIX_TAR}-7} \ - && ./mqsifixinst.sh /opt/ibm/ace-12 install $IFIX \ - && cd /home/aceuser \ - && rm -rf /home/aceuser/fix - -USER 1000 +docker build -t ace --build-arg DOWNLOAD_URL=${DOWNLOAD_URL} --file ./Dockerfile . ``` -Update the Dockerfile such that - -- ACE_IMAGE points at your base image -- IFIX_TAR is the name of the iFix download file. This must be located in the same directory as the Dockerfile -- USER must be updated to match the ID of the ace user - -To build the image use a command such as the following: +If you want to connect to a secure endpoint build the image using a command such as: +i.e. ```bash -docker build -f Dockerfile --tag myregistry.com/ace/ace-server-prod:12.0.2.0-ACE-LinuxX64-TFIT38649 . +docker build -t ace --build-arg USERNAME= --build-arg PASSWORD= --build-arg DOWNLOAD_URL=${DOWNLOAD_URL} --file ./Dockerfile . ``` -The resulting inage should then be used using the same options as the original base image - -## Usage - -### Accepting the License - -In order to use the image, it is necessary to accept the terms of the IBM App Connect Enterprise license. This is achieved by specifying the environment variable `LICENSE` equal to `accept` when running the image. You can also view the license terms by setting this variable to `view`. Failure to set the variable will result in the termination of the container with a usage statement. You can view the license in a different language by also setting the `LANG` environment variable. - -### Red Hat OpenShift SecurityContextConstraints Requirements - -The predefined SecurityContextConstraint (SCC) `restricted` has been verified with the image when being run in a Red Hat OpenShift environment. - -### Running the container - -To run a container with ACE only with default configuration and these settings: - -- ACE server name `ACESERVER` -- listener for ACE web ui on port `7600` -- listener for ACE HTTP on port `7600` -run the following command: - -`docker run --name aceserver -p 7600:7600 -p 7800:7800 -p 7843:7843 --env LICENSE=accept --env ACE_SERVER_NAME=ACESERVER ace-only:latest` - -Once the console shows that the integration server is listening on port 7600, you can go to the ACE UI at http://localhost:7600/. To stop the container, run `docker stop aceserver` and the container will shut down cleanly, stopping the integration server. - -### Sample image - -In the `sample` folder there is an example on how to build a server image with a set of configuration and BAR files based on a previously built ACE image. **[How to use the sample.](sample/README.md)** - -### Environment variables supported by this image - -- **LICENSE** - Set this to `accept` to agree to the App Connect Enterprise license. If you wish to see the license you can set this to `view`. -- **LANG** - Set this to the language you would like the license to be printed in. -- **LOG_FORMAT** - Set this to change the format of the logs which are printed on the container's stdout. Set to "json" to use JSON format (JSON object per line); set to "basic" to use a simple human-readable format. Defaults to "basic". -- **ACE_ENABLE_METRICS** - Set this to `true` to generate Prometheus metrics for your Integration Server. -- **ACE_SERVER_NAME** - Set this to the name you want your Integration Server to run with. -- **ACE_TRUSTSTORE_PASSWORD** - Set this to the password you wish to use for the trust store (if using one). -- **ACE_KEYSTORE_PASSWORD** - Set this to the password you wish to use for the key store (if using one). - -- **ACE_ADMIN_SERVER_SECURITY** - Set to `true` if you intend to secure your Integration Server using SSL. -- **ACE_ADMIN_SERVER_NAME** - Set this to the DNS name of your Integration Server for SSL SAN checking. -- **ACE_ADMIN_SERVER_CA** - Set this to your Integration Server SSL CA certificates folder. -- **ACE_ADMIN_SERVER_CERT** - Set this to your Integration Server SSL certificate. -- **ACE_ADMIN_SERVER_KEY** - Set this to your Integration Server SSL key certificate. - -- **FORCE_FLOW_HTTPS** - Set to 'true' and the *.key and *.crt present in `/home/aceuser/httpsNodeCerts/` are used to force all your flows to use https - -## How to dynamically configure the ACE Integration Server - -To enable dynamic configuration of the ACE Integration Server, this setup supports configuration injected into the image as files. - -Before the Integration Server starts, the container is checked for the folder `/home/aceuser/initial-config`. For each folder in `/home/aceuser/initial-config` a script called `ace_config_{folder-name}.sh` will be run to process the information in the folder. -Shell scripts are supplied for the list of folders below, but you can extend this mechanism by adding your own folders and associated shell scripts. - -- **Note**: The work dir for the Integration Server in the image is `/home/aceuser/ace-server`. -- **Note**: An example `initial-config` directory with data can be found in the `sample` folder, as well as the [command on how to mount it when running the image]((sample/README.md#run-the-sample-image). - -You can mount the following file structure at `/home/aceuser/initial-config`. Missing folders will be skipped, but *empty* folders will cause an error: - -- `/home/aceuser/initial-config/keystore` - - A text file containing a certificate file in PEM format. This will be imported into the keystore file, along with the private key. The filename must be the *alias* for the certificate in the keystore, with the suffix `.crt`. The alias must not contain any whitespace characters. - - A text file containing a private key file in PEM format. This will be imported into the keystore file, along with the certificate. The filename must be the *alias* for the certificate in the keystore, with the suffix `.key`. - - If the private key is encrypted, then the passphrase may be specified in a file with the filename of *alias* with the suffix `.pass`. - - The keystore file that will be created for these files needs a password. You must set the keystore password using the environment variable `ACE_KEYSTORE_PASSWORD`. - - You can place multiple sets of files, each with a different file name/alias; each `.crt` file must have an associated `.key` file, and a `.pass` file must be present if the private key has a passphrase. -- `/home/aceuser/initial-config/odbcini` - - A text file called `odbc.ini`. This must be an `odbc.ini` file suitable for the Integration Server to use when connecting to a database. This will be copied to `/home/aceuser/ace-server/odbc.ini`. -- `/home/aceuser/initial-config/policy` - - A set of `.policyxml` files, each with the suffix `.policyxml`, and a single `policy.descriptor` file. These will be copied to `/home/aceuser/ace-server/overrides/DefaultPolicies/`. They should be specified in the `server.conf.yaml` section in order to be used. -- `/home/aceuser/initial-config/serverconf` - - A text file called `server.conf.yaml` that contains a `server.conf.yaml` overrides file. This will be copied to `/home/aceuser/ace-server/overrides/server.conf.yaml` -- `/home/aceuser/initial-config/setdbparms` - - For any parameters that need to be set via `mqsisetdbparms` include a text file called `setdbparms.txt` This supports 2 formats: - - ```script - # Lines starting with a "#" are ignored - # Each line which starts mqsisetdbparms will be run as written - # Alternatively each line should specify the , separated by a single space - # Each line will be processed by calling... - # mqsisetdbparms ${ACE_SERVER_NAME} -n -u -p - resource1 user1 password1 - resource2 user2 password2 - mqsisetdbparms -w /home/aceuser/ace-server -n salesforce::SecurityIdentity -u myUsername -p myPassword -c myClientID -s myClientSecret - ``` - -- `/home/aceuser/initial-config/truststore` - - A text file containing a certificate file in PEM format. This will be imported into the truststore file as a trusted Certificate Authority's certificate. The filename must be the *alias* for the certificate in the keystore, with the suffix `.crt`. The alias must not contain any whitespace characters. - - The truststore file that will be created for these files needs a password. You must set a truststore password using the environment variable `ACE_TRUSTSTORE_PASSWORD` - - You can place multiple files, each with a different file name/alias. -- `/home/aceuser/initial-config/webusers` - - A text file called `admin-users.txt`. It contains a list of users to be created as `admin` users using the command `mqsiwebuseradmin`. These users will have READ, WRITE and EXECUTE access on the Integration Server. The file has the following format: - - ```script - # Lines starting with a "#" are ignored - # Each line should specify the , separated by a single space - # Each user will have "READ", "WRITE" and "EXECUTE" access on the integration server - # Each line will be processed by calling... - # mqsiwebuseradmin -w /home/aceuser/ace-server -c -u -a -r admin - admin1 password1 - admin2 password2 - ``` - - - A text file called `operator-users.txt`. It contains a list of users to be created as `operator` users using the command `mqsiwebuseradmin`. These users will have READ and EXECUTE access on the Integration Server. The file has the following format: - - ```script - # Lines starting with a "#" are ignored - # Each line should specify the , separated by a single space - # Each user will have "READ" and "EXECUTE" access on the integration server - # Each line will be processed by calling... - # mqsiwebuseradmin -w /home/aceuser/ace-server -c -u -a -r operator - operator1 password1 - operator2 password2 - ``` - - - A text file called `editor-users.txt`. It contains a list of users to be created as `editor` users using the command `mqsiwebuseradmin`. These users will have READ and WRITE access on the Integration Server. The file has the following format: - - ```script - # Lines starting with a "#" are ignored - # Each line should specify the , separated by a single space - # Each user will have "READ" and "WRITE" access on the integration server - # Each line will be processed by calling... - # mqsiwebuseradmin -w /home/aceuser/ace-server -c -u -a -r editor - editor1 password1 - editor2 password2 - ``` - - - A text file called `audit-users.txt`. It contains a list of users to be created as `audit` users using the command `mqsiwebuseradmin`. These users will have READ access on the Integration Server. The file has the following format: - - ```script - # Lines starting with a "#" are ignored - # Each line should specify the , separated by a single space - # Each user will have "READ" access on the integration server - # Each line will be processed by calling... - # mqsiwebuseradmin -w /home/aceuser/ace-server -c -u -a -r audit - audit1 password1 - audit2 password2 - ``` - - - A text file called `viewer-users.txt`. It contains a list of users to be created as `viewer` users using the command `mqsiwebuseradmin`. These users will have READ access on the Integration Server. The file has the following format: - - ```script - # Lines starting with a "#" are ignored - # Each line should specify the , separated by a single space - # Each user will have "READ" access on the integration server - # Each line will be processed by calling... - # mqsiwebuseradmin -w /home/aceuser/ace-server -c -u -a -r viewer - viewer1 password1 - viewer2 password2 - ``` - -- `/home/aceuser/initial-config/agent` - - A json file called 'switch.json' containing configuration information for the switch, this will be copied into the appropriate iibswitch directory - - A json file called 'agentx.json' containing configuration information for the agent connectivity, this will be copied into the appropriate iibswitch directory - - A json file called 'agenta.json' containing configuration information for the agent connectivity, this will be copied into the appropriate iibswitch directory - - A json file called 'agentc.json' containing configuration information for the agent connectivity, this will be copied into the appropriate iibswitch directory - - A json file called 'agentp.json' containing configuration information for the agent connectivity, this will be copied into the appropriate iibswitch directory -- `/home/aceuser/initial-config/extensions` - - A zip file called `extensions.zip` will be extracted into the directory `/home/aceuser/ace-server/extensions`. This allows you to place extra files into a directory you can then reference in, for example, the server.conf.yaml -- `/home/aceuser/initial-config/ssl` - - A pem file called 'ca.crt' will be extracted into the directory `/home/aceuser/ace-server/ssl` - - A pem file called 'tls.key' will be extracted into the directory `/home/aceuser/ace-server/ssl` - - A pem file called 'tls.cert' will be extracted into the directory `/home/aceuser/ace-server/ssl` -- `/home/aceuser/initial-config/bar_overrides` - - For any parameters that need to be set via `mqsiapplybaroverride` include text files with extension `.properties` Eg: - ```script - sampleFlow#MQInput.queueName=NEWC - ``` -- `/home/aceuser/initial-config/workdir_overrides` - - For any parameters that need to be set via `ibm int apply overrides --work-directory /home/aceuser/ace-server` on the integration server include text files Eg: - ```script - TestFlow#HTTP Input.URLSpecifier=/production - ``` - - -## Logging +NOTE: If no DOWNLOAD_URL is provided the build will use a copy of the App Connect Enterprise developer edition as referenced in the Dockerfile -The logs from the integration server running within the container will log to standard out. The log entries can be output in two format: +### Running the image -- basic: human-headable for use in development when using `docker logs` or `kubectl logs` -- json: for pushing into ELK stack for searching and visualising in Kibana +To run the image use a command such as -The output format is controlled by the `LOG_FORMAT` environment variable +`docker run -d -p 7600:7600 -p 7800:7800 -e LICENSE=accept ace:latest` -A sample Kibana dashboard is available at sample/dashboards/ibm-ace-kibana-dashboard.json +### Extending the image -## Monitoring +To add extra artifacts into the container such as server.conf.yaml overrides, bars files etc please refer to the sample on adding files in [Samples](samples/README.md) -The accounting and statistics feature in IBM App Connect Enterprise provides the component level data with detailed insight into the running message flows to enabled problem determination, profiling, capacity planning, situation alert monitoring and charge-back modelling. +## Pre-Built Containers -A Prometheus exporter runs on port 9483 if `ACE_ENABLE_METRICS` is set to `true` - the exporter listens for accounting and statistics, and resource statistics, data on a websocket from the integration server, then aggregates this data to make available to Prometheus when requested. +Pre-built production images can be found on IBM Container Registry at `cp.icr.io/cp/appc/ace` - [Building a sample IBM App Connect Enterprise image using Docker](https://www.ibm.com/docs/en/app-connect/12.0?topic=cacerid-building-sample-app-connect-enterprise-image-using-docker) -A sample Grafana dashboard is available at sample/dashboards/ibm-ace-grafana-dashboard.json +### Fixing security vulnerabilities in the base software -## License +If you find there are vulnerabilities in the base redhat software there are two options to fix this -The Dockerfile and associated scripts are licensed under the [Eclipse Public License 2.0](LICENSE). Licenses for the products installed within the images are as follows: +- Apply the fix yourself using a sample docker file to install all available updates - [Samples/updateBase](samples/updateBase/Dockerfile) +- Pick up the latest version of the image which will include all fixes at the point it was built. -- IBM App Connect Enterprise for Developers is licensed under the IBM International License Agreement for Non-Warranted Programs. This license may be viewed from the image using the `LICENSE=view` environment variable as described above. +### Fixing issues with ACE -Note that the IBM App Connect Enterprise for Developers license does not permit further distribution. +If you find a problem with ACE software, raise a PMR to obtain a fix. Once the fix is provided this can be applied to any existing image using a [Samples](samples/README.md#ifix-sample) dockerfile -## Copyright +## Support -© Copyright IBM Corporation 2015, 2018 +All information provided in this repo as supported as-is. diff --git a/ace_compile_bars.sh b/ace_compile_bars.sh deleted file mode 100755 index a1ebbf2..0000000 --- a/ace_compile_bars.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -if ls /home/aceuser/bars/*.bar >/dev/null 2>&1; then - for bar in /home/aceuser/bars/*.bar - do - mqsibar -a $bar -w /home/aceuser/ace-server -c - done -fi diff --git a/ace_config_agent.sh b/ace_config_agent.sh deleted file mode 100755 index c61a8a5..0000000 --- a/ace_config_agent.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling agent configuration" - -if [ -s "/home/aceuser/initial-config/agent/switch.json" ]; then - mkdir -p /home/aceuser/ace-server/config/iibswitch/switch - cp /home/aceuser/initial-config/agent/switch.json /home/aceuser/ace-server/config/iibswitch/switch/switch.json -fi - -if [ -s "/home/aceuser/initial-config/agent/agentx.json" ]; then - mkdir -p /home/aceuser/ace-server/config/iibswitch/agentx - cp /home/aceuser/initial-config/agent/agentx.json /home/aceuser/ace-server/config/iibswitch/agentx/agentx.json -fi - -if [ -s "/home/aceuser/initial-config/agent/agenta.json" ]; then - mkdir -p /home/aceuser/ace-server/config/iibswitch/agenta - cp /home/aceuser/initial-config/agent/agenta.json /home/aceuser/ace-server/config/iibswitch/agenta/agenta.json -fi - -if [ -s "/home/aceuser/initial-config/agent/agentp.json" ]; then - mkdir -p /home/aceuser/ace-server/config/iibswitch/agentp - cp /home/aceuser/initial-config/agent/agentp.json /home/aceuser/ace-server/config/iibswitch/agentp/agentp.json -fi - -if [ -s "/home/aceuser/initial-config/agent/agentc.json" ]; then - mkdir -p /home/aceuser/ace-server/config/iibswitch/agentc - cp /home/aceuser/initial-config/agent/agentc.json /home/aceuser/ace-server/config/iibswitch/agentc/agentc.json -fi - -log "agent configuration complete" diff --git a/ace_config_bar_overrides.sh b/ace_config_bar_overrides.sh deleted file mode 100755 index 718efb0..0000000 --- a/ace_config_bar_overrides.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -if ls /home/aceuser/initial-config/bar_overrides/*.properties >/dev/null 2>&1; then - for propertyFile in /home/aceuser/initial-config/bar_overrides/*.properties - do - for bar in /home/aceuser/initial-config/bars/*.bar - do - mqsiapplybaroverride -b $bar -p $propertyFile -r - echo $propertyFile >> /home/aceuser/initial-config/bar_overrides/logs.txt - done - done -fi \ No newline at end of file diff --git a/ace_config_bars.sh b/ace_config_bars.sh deleted file mode 100755 index d9fef56..0000000 --- a/ace_config_bars.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -if ls /home/aceuser/initial-config/bars/*.bar >/dev/null 2>&1; then - for bar in /home/aceuser/initial-config/bars/*.bar - do - mqsibar -a $bar -w /home/aceuser/ace-server - done -fi diff --git a/ace_config_extensions.sh b/ace_config_extensions.sh deleted file mode 100755 index dafa802..0000000 --- a/ace_config_extensions.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling extensions configuration" - -if [ -s "/home/aceuser/initial-config/extensions/extensions.zip" ]; then - mkdir /home/aceuser/ace-server/extensions - unzip /home/aceuser/initial-config/extensions/extensions.zip -d /home/aceuser/ace-server/extensions -fi - -log "extensions configuration complete" diff --git a/ace_config_keystore.sh b/ace_config_keystore.sh deleted file mode 100755 index e213fe8..0000000 --- a/ace_config_keystore.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling keystore configuration" - -if ls /home/aceuser/initial-config/keystore/*.key >/dev/null 2>&1; then - - if [ $(cat /home/aceuser/initial-config/keystore/*.key | wc -l) -gt 0 ]; then - if [ -f /home/aceuser/ace-server/keystore.jks ]; then - OUTPUT=$(rm /home/aceuser/ace-server/keystore.jks 2>&1) - logAndExitIfError $? "${OUTPUT}" - fi - fi - - IFS=$'\n' - KEYTOOL=/opt/ibm/ace-12/common/jdk/jre/bin/keytool - if [ ! -f "$KEYTOOL" ]; then - KEYTOOL=/opt/ibm/ace-12/common/jre/bin/keytool - fi - for keyfile in `ls /home/aceuser/initial-config/keystore/*.key`; do - if [ -s "${keyfile}" ]; then - if [ -z "${ACE_KEYSTORE_PASSWORD}" ]; then - log "No keystore password defined" - exit 1 - fi - - filename=$(basename ${keyfile}) - dirname=$(dirname ${keyfile}) - alias=$(echo ${filename} | sed -e 's/\.key$'//) - certfile=${dirname}/${alias}.crt - passphrasefile=${dirname}/${alias}.pass - - if [ ! -f ${certfile} ]; then - log "Certificate file ${certfile} not found." - exit 1 - fi - - if [ -f ${passphrasefile} ];then - ACE_PRI_KEY_PASS=$(cat ${passphrasefile}) - OUTPUT=$(openssl pkcs12 -export -in ${certfile} -inkey ${keyfile} -passin pass:${ACE_PRI_KEY_PASS} -out /home/aceuser/ace-server/keystore.p12 -name ${alias} -password pass:${ACE_KEYSTORE_PASSWORD} 2>&1) - else - OUTPUT=$(openssl pkcs12 -export -in ${certfile} -inkey ${keyfile} -out /home/aceuser/ace-server/keystore.p12 -name ${alias} -password pass:${ACE_KEYSTORE_PASSWORD} 2>&1) - fi - logAndExitIfError $? "${OUTPUT}" - - OUTPUT=$(${KEYTOOL} -importkeystore -srckeystore /home/aceuser/ace-server/keystore.p12 -destkeystore /home/aceuser/ace-server/keystore.jks -srcstorepass ${ACE_KEYSTORE_PASSWORD} -deststorepass ${ACE_KEYSTORE_PASSWORD} -srcalias ${alias} -destalias ${alias} -srcstoretype PKCS12 -noprompt 2>&1) - logAndExitIfError $? "${OUTPUT}" - - OUTPUT=$(rm /home/aceuser/ace-server/keystore.p12 2>&1) - logAndExitIfError $? "${OUTPUT}" - fi - done -fi - -log "Keystore configuration complete" diff --git a/ace_config_odbcini.sh b/ace_config_odbcini.sh deleted file mode 100755 index 7e7e3e7..0000000 --- a/ace_config_odbcini.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling odbcini configuration" - -if [ -s "/home/aceuser/initial-config/odbcini/odbc.ini" ]; then - ODBCINI=/home/aceuser/ace-server/odbc.ini - cp /home/aceuser/initial-config/odbcini/odbc.ini ${ODBCINI} -fi - -log "Odbcini configuration complete" diff --git a/ace_config_policy.sh b/ace_config_policy.sh deleted file mode 100755 index 428e5ff..0000000 --- a/ace_config_policy.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling policy configuration" - -mkdir /home/aceuser/ace-server/overrides/DefaultPolicies - -if ls /home/aceuser/initial-config/policy/*.policyxml >/dev/null 2>&1; then - for policyfile in `ls /home/aceuser/initial-config/policy/*.policyxml`; do - if [ -s "${policyfile}" ]; then - cp "${policyfile}" /home/aceuser/ace-server/overrides/DefaultPolicies/. - fi - done -fi - -if [ -s "/home/aceuser/initial-config/policy/policy.descriptor" ]; then - cp /home/aceuser/initial-config/policy/policy.descriptor /home/aceuser/ace-server/overrides/DefaultPolicies/policy.descriptor -fi - -log "Policy configuration complete" diff --git a/ace_config_serverconf.sh b/ace_config_serverconf.sh deleted file mode 100755 index 0d18ded..0000000 --- a/ace_config_serverconf.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling server.conf configuration" - -if [ -s "/home/aceuser/initial-config/serverconf/server.conf.yaml" ]; then - cp /home/aceuser/initial-config/serverconf/server.conf.yaml /home/aceuser/ace-server/overrides/server.conf.yaml -fi - -log "server.conf configuration complete" diff --git a/ace_config_ssl.sh b/ace_config_ssl.sh deleted file mode 100755 index ea521cf..0000000 --- a/ace_config_ssl.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling SSL files" - -mkdir /home/aceuser/ace-server/ssl/ - -if ls /home/aceuser/initial-config/ssl/* >/dev/null 2>&1; then - for sslfile in `ls /home/aceuser/initial-config/ssl/*`; do - if [ -s "${sslfile}" ]; then - cp "${sslfile}" /home/aceuser/ace-server/ssl/. - fi - done -fi - -log "SSL configuration complete" diff --git a/ace_config_truststore.sh b/ace_config_truststore.sh deleted file mode 100755 index 979a17b..0000000 --- a/ace_config_truststore.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Handling truststore configuration" - -if ls /home/aceuser/initial-config/truststore/*.crt >/dev/null 2>&1; then - - if [ $(cat /home/aceuser/initial-config/truststore/*.crt | wc -l) -gt 0 ]; then - if [ -f /home/aceuser/ace-server/truststore.jks ]; then - OUTPUT=$(rm /home/aceuser/ace-server/truststore.jks 2>&1) - logAndExitIfError $? "${OUTPUT}" - fi - fi - - IFS=$'\n' - KEYTOOL=/opt/ibm/ace-12/common/jdk/jre/bin/keytool - if [ ! -f "$KEYTOOL" ]; then - KEYTOOL=/opt/ibm/ace-12/common/jre/bin/keytool - fi - for file in `ls /home/aceuser/initial-config/truststore/*.crt`; do - if [ -s "${file}" ]; then - if [ -z "${ACE_TRUSTSTORE_PASSWORD}" ]; then - log "No truststore password defined" - exit 1 - fi - - filename=$(basename $file) - alias=$(echo $filename | sed -e 's/\.crt$'//) - OUTPUT=$(${KEYTOOL} -importcert -trustcacerts -alias ${filename} -file ${file} -keystore /home/aceuser/ace-server/truststore.jks -storepass ${ACE_TRUSTSTORE_PASSWORD} -noprompt 2>&1) - logAndExitIfError $? "${OUTPUT}" - fi - done -fi - -log "Truststore configuration complete" diff --git a/ace_config_workdir_overrides.sh b/ace_config_workdir_overrides.sh deleted file mode 100755 index 207d16e..0000000 --- a/ace_config_workdir_overrides.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2021. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -if ls /home/aceuser/initial-config/workdir_overrides/* >/dev/null 2>&1; then - for workdiroverride in /home/aceuser/initial-config/workdir_overrides/* - do - ibmint apply overrides $workdiroverride --work-directory /home/aceuser/ace-server - done -fi diff --git a/ace_env.sh b/ace_env.sh deleted file mode 100755 index 20ac4e3..0000000 --- a/ace_env.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi diff --git a/ace_forceflowhttps.sh b/ace_forceflowhttps.sh deleted file mode 100755 index 289cc83..0000000 --- a/ace_forceflowhttps.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2021. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -source ${SCRIPT_DIR}/ace_config_logging.sh - -log "Creating force flows to be https keystore" - -if [ -f /home/aceuser/ace-server/https-keystore.p12 ]; then - OUTPUT=$(rm /home/aceuser/ace-server/https-keystore.p12 2>&1) - logAndExitIfError $? "${OUTPUT}" -fi - -IFS=$'\n' -KEYTOOL=/opt/ibm/ace-12/common/jdk/jre/bin/keytool -if [ ! -f "$KEYTOOL" ]; then - KEYTOOL=/opt/ibm/ace-12/common/jre/bin/keytool -fi - -if [ ! -f /home/aceuser/httpsNodeCerts/*.key ]; then - log "No keystore files found at location /home/aceuser/httpsNodeCerts/*.key cannot create Force Flows HTTPS keystore" - exit 1 -fi - -for keyfile in `ls /home/aceuser/httpsNodeCerts/*.key`; do - if [ -s "${keyfile}" ]; then - if [ -z "${1}" ]; then - log "No keystore password defined" - exit 1 - fi - - filename=$(basename ${keyfile}) - dirname=$(dirname ${keyfile}) - alias=$(echo ${filename} | sed -e 's/\.key$'//) - certfile=${dirname}/${alias}.crt - passphrasefile=${dirname}/${alias}.pass - - if [ ! -f ${certfile} ]; then - log "Certificate file ${certfile} not found." - exit 1 - fi - - OUTPUT=$(openssl pkcs12 -export -in ${certfile} -inkey ${keyfile} -out /home/aceuser/ace-server/https-keystore.p12 -name ${alias} -password pass:${1} 2>&1) - logAndExitIfError $? "${OUTPUT}" - - log "Setting https keystore password" - cmd="mqsisetdbparms -w /home/aceuser/ace-server -n brokerHTTPSKeystore::password -u anything -p \"${1}\" 2>&1" - OUTPUT=`eval "$cmd"` - echo $OUTPUT - - fi -done - -log "Force flows to be https keystore creation complete" diff --git a/ace_integration_server.sh b/ace_integration_server.sh deleted file mode 100755 index 0cb1dfe..0000000 --- a/ace_integration_server.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -# Enable TLS on both MQ and DB2 -if [ -d /opt/mqm/gskit8/lib64 ]; then - export LD_LIBRARY_PATH=/opt/mqm/gskit8/lib64:$LD_LIBRARY_PATH -fi - -if [ -s /home/aceuser/ace-server/odbc.ini ]; then - export ODBCINI=/home/aceuser/ace-server/odbc.ini -fi - -# For customers running pod environment -if [ -s /home/aceuser/generic/odbcinst.ini ]; then - export ODBCSYSINI=/home/aceuser/generic -fi - -# For customers running ace in docker themselves -if [ -s /home/aceuser/ace-server/extensions/odbcinst.ini ]; then - export ODBCSYSINI=/home/aceuser/ace-server/extensions -fi - -# We need to keep the kubernetes port overrides as customers could be running ace in docker themselves -# but we need to allow the ports to be overwritten in the pod environment if set by the operator -if ! [[ -z "${KUBERNETES_PORT}" ]] && ! [[ -z "${SERVICE_NAME}" ]] && ! [[ -z "${MQSI_OVERRIDE_HTTP_PORT}" ]] && ! [[ -z "${MQSI_OVERRIDE_HTTPS_PORT}" ]] ; then - . /home/aceuser/portOverrides -fi - -exec IntegrationServer $* diff --git a/ace_license_check.sh b/ace_license_check.sh deleted file mode 100755 index 0d80acf..0000000 --- a/ace_license_check.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ "$LICENSE" = "accept" ]; then - exit 0 -elif [ "$LICENSE" = "view" ]; then - case "$LANG" in - zh_TW*) LICENSE_FILE=Chinese_TW.txt ;; - zh*) LICENSE_FILE=Chinese.txt ;; - cs*) LICENSE_FILE=Czech.txt ;; - en*) LICENSE_FILE=English.txt ;; - fr*) LICENSE_FILE=French.txt ;; - de*) LICENSE_FILE=German.txt ;; - el*) LICENSE_FILE=Greek.txt ;; - id*) LICENSE_FILE=Indonesian.txt ;; - it*) LICENSE_FILE=Italian.txt ;; - ja*) LICENSE_FILE=Japanese.txt ;; - ko*) LICENSE_FILE=Korean.txt ;; - lt*) LICENSE_FILE=Lithuanian.txt ;; - pl*) LICENSE_FILE=Polish.txt ;; - pt*) LICENSE_FILE=Portuguese.txt ;; - ru*) LICENSE_FILE=Russian.txt ;; - sl*) LICENSE_FILE=Slovenian.txt ;; - es*) LICENSE_FILE=Spanish.txt ;; - tr*) LICENSE_FILE=Turkish.txt ;; - *) LICENSE_FILE=English.txt ;; - esac - cat /opt/ibm/ace-12/license/$LICENSE_FILE - exit 1 -else - echo -e "Set environment variable LICENSE=accept to indicate acceptance of license terms and conditions.\n\nLicense agreements and information can be viewed by running this image with the environment variable LICENSE=view. You can also set the LANG environment variable to view the license in a different language." - exit 1 -fi diff --git a/ace_mqsicommand.sh b/ace_mqsicommand.sh deleted file mode 100755 index 4efa025..0000000 --- a/ace_mqsicommand.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# © Copyright IBM Corporation 2018. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v2.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v20.html - -if [ -z "$MQSI_VERSION" ]; then - source /opt/ibm/ace-12/server/bin/mqsiprofile -fi - -mqsi$* diff --git a/appconnect_enterprise_logo.svg b/appconnect_enterprise_logo.svg deleted file mode 100644 index 85b78c5..0000000 --- a/appconnect_enterprise_logo.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - appconnect - Created with Sketch. - - - - - - - - - - - - - - - diff --git a/build-rhel.sh b/build-rhel.sh deleted file mode 100755 index ce53a98..0000000 --- a/build-rhel.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -ex -echo "Building ACE build container" -buildType=$1 -buildTag=$2 -aceInstall=$3 -mqImage=$4 - - -if [ -z "$aceInstall" ] -then - echo "Building temporary container with default ACE install parameters" - docker build --no-cache --build-arg -t ace/builder:11.0.0.4 . -f ./rhel/Dockerfile.build -else - echo "Building temporary container with ACE install $buildType" - docker build --no-cache --build-arg ACE_INSTALL=$aceInstall -t ace/builder:11.0.0.4 . -f ./rhel/Dockerfile.build -fi - -docker create --name builder ace/builder:11.0.0.4 -docker cp builder:/opt/ibm/ace-12 ./rhel/ace-12 -docker cp builder:/go/src/github.com/ot4i/ace-docker/runaceserver ./rhel/runaceserver -docker cp builder:/go/src/github.com/ot4i/ace-docker/chkaceready ./rhel/chkaceready -docker cp builder:/go/src/github.com/ot4i/ace-docker/chkacehealthy ./rhel/chkacehealthy -docker rm -f builder - -echo "Building ACE runtime container" - -# Replace the FROM statement to use the MQ container -sed -i "s%^FROM .*%FROM $mqImage%" ./rhel/Dockerfile.acemqrhel - -case $buildType in -"ace-dev-only") - echo "Building ACE only for development" - docker build --no-cache -t $buildTag -f ./rhel/Dockerfile.acerhel . - ;; -"ace-only") - echo "Building ACE only for production" - docker build --no-cache -t $buildTag -f ./rhel/Dockerfile.acerhel . - ;; -"ace-mq") - echo "Building ACE with MQ for production" - docker build --no-cache -t $buildTag --build-arg BASE_IMAGE=$mqImage -f ./rhel/Dockerfile.acemqrhel . - ;; -"ace-dev-mq-dev") - echo "Building ACE with MQ for production" - docker build --no-cache -t $buildTag --build-arg BASE_IMAGE=$mqImage -f ./rhel/Dockerfile.acemqrhel . - ;; -*) echo "Invalid option" - ;; -esac diff --git a/cmd/chkacehealthy/.gitignore b/cmd/chkacehealthy/.gitignore deleted file mode 100644 index 1349ec4..0000000 --- a/cmd/chkacehealthy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -chkacehealthy \ No newline at end of file diff --git a/cmd/chkacehealthy/main.go b/cmd/chkacehealthy/main.go deleted file mode 100644 index 987633e..0000000 --- a/cmd/chkacehealthy/main.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// chkacelively checks that ACE is still runing, by checking if the admin REST endpoint port is available. -package main - -import ( - "context" - "fmt" - "log" - "net" - "net/http" - "os" - "time" - - "k8s.io/apimachinery/pkg/api/errors" -) - -var checkACE = checkACElocal -var httpCheck = httpChecklocal -var socketCheck = socketChecklocal -var osExit = os.Exit - -const restartIsTimeoutInSeconds = 60 - -var netDial = net.Dial -var httpGet = http.Get - -func main() { - - err := checkACE() - if err != nil { - log.Fatal(err) - } - - // If knative service also check FDR is up - knative := os.Getenv("KNATIVESERVICE") - if knative == "true" || knative == "1" { - fmt.Println("KNATIVESERVICE set so checking FDR container") - err := checkDesignerHealth() - if err != nil { - log.Fatal(err) - } - } else { - fmt.Println("KNATIVESERVICE is not set so skipping FDR checks") - } - -} - -func checkDesignerHealth() error { - // HTTP LMAP endpoint - err := httpCheck("LMAP Port", "http://localhost:3002/admin/ready") - if err != nil { - return err - } - - isConnectorService := os.Getenv("CONNECTOR_SERVICE") - if isConnectorService == "true" || isConnectorService == "1" { - // HTTP LCP Connector service endpoint - err = httpCheck("LCP Port", "http://localhost:3001/admin/ready") - if err != nil { - return err - } - } - - // LCP api flow endpoint - lcpsocket := "/tmp/lcp.socket" - if value, ok := os.LookupEnv("LCP_IPC_PATH"); ok { - lcpsocket = value - } - err = socketCheck("LCP socket", lcpsocket) - if err != nil { - return err - } - - // LMAP endpoint - lmapsocket := "/tmp/lmap.socket" - if value, ok := os.LookupEnv("LMAP_IPC_PATH"); ok { - lmapsocket = value - } - err = socketCheck("LMAP socket", lmapsocket) - if err != nil { - return err - } - - return nil -} - -func isEnvExist(key string) bool { - if _, ok := os.LookupEnv(key); ok { - return true - } - return false -} - -func checkACElocal() error { - // Check if the integration server has started the admin REST endpoint - conn, err := netDial("tcp", "127.0.0.1:7600") - - if err != nil { - - fmt.Println("Unable to connect to IntegrationServer REST endpoint: " + err.Error() + ", ") - - fileInfo, statErr := os.Stat("/tmp/integration_server_restart.timestamp") - - if os.IsNotExist(statErr) { - fmt.Println("Integration server is not active") - return errors.NewBadRequest("Integration server is not active") - } else if statErr != nil { - fmt.Println(statErr) - return errors.NewBadRequest("stat error " + statErr.Error()) - } else { - fmt.Println("Integration server restart file found") - timeNow := time.Now() - timeDiff := timeNow.Sub(fileInfo.ModTime()) - - if timeDiff.Seconds() < restartIsTimeoutInSeconds { - fmt.Println("Integration server is restarting") - } else { - fmt.Println("Integration restart time elapsed") - return errors.NewBadRequest("Integration restart time elapsed") - } - } - } else { - fmt.Println("ACE ready check passed") - } - conn.Close() - return nil -} - -func httpChecklocal(name string, addr string) error { - resp, err := httpGet(addr) - if err != nil { - return err - } - if resp.StatusCode != 200 { - fmt.Println(name + " ready check failed - HTTP Status is not 200 range") - return errors.NewBadRequest(name + " ready check failed - HTTP Status is not 200 range") - } else { - fmt.Println(name + " ready check passed") - } - return nil -} - -func socketChecklocal(name string, socket string) error { - httpc := http.Client{ - Transport: &http.Transport{ - DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { - return net.Dial("unix", socket) - }, - }, - } - response, err := httpc.Get("http://dummyHostname/admin/ready") - if err != nil { - return err - } - if response.StatusCode != 200 { - log.Fatal(name + " ready check failed - HTTP Status is not 200 range") - return errors.NewBadRequest(name + " ready check failed - HTTP Status is not 200 range") - } else { - fmt.Println(name + " ready check passed") - } - return nil -} diff --git a/cmd/chkacehealthy/main_test.go b/cmd/chkacehealthy/main_test.go deleted file mode 100644 index 4406566..0000000 --- a/cmd/chkacehealthy/main_test.go +++ /dev/null @@ -1,134 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// chkacelively checks that ACE is still runing, by checking if the admin REST endpoint port is available. -package main - -import ( - "net/http" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "k8s.io/apimachinery/pkg/api/errors" -) - -func Test_httpChecklocal(t *testing.T) { - - t.Run("http get succeeds", func(t *testing.T) { - - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{ - StatusCode: 200, - } - return response, nil - } - - err := httpChecklocal("LMAP Port", "http://localhost:3002/admin/ready") - assert.Nil(t, err) - }) - - t.Run("http get fails with err on get", func(t *testing.T) { - - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{} - return response, errors.NewBadRequest("mock err") - } - - err := httpChecklocal("LMAP Port", "http://localhost:3002/admin/ready") - assert.Error(t, err, "mock err") - }) - - t.Run("http get fails with non 200", func(t *testing.T) { - - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{ - StatusCode: 404, - } - return response, nil - } - - err := httpChecklocal("Test", "http://localhost:3002/admin/ready") - assert.Error(t, err, "Test ready check failed - HTTP Status is not 200 range") - }) -} - -func Test_checkDesignerHealth(t *testing.T) { - t.Run("connector service enabled and health check is successful", func(t *testing.T) { - os.Setenv("CONNECTOR_SERVICE", "true") - defer os.Unsetenv("CONNECTOR_SERVICE") - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{ - StatusCode: 200, - } - return response, nil - } - - oldSocketCheck := socketCheck - defer func() { socketCheck = oldSocketCheck }() - socketCheck = func(string, string) (err error) { - return nil - } - err := checkDesignerHealth() - assert.Nil(t, err) - }) - - t.Run("connector service enabled and health check fails", func(t *testing.T) { - os.Setenv("CONNECTOR_SERVICE", "true") - defer os.Unsetenv("CONNECTOR_SERVICE") - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{} - return response, errors.NewBadRequest("mock err") - } - - oldSocketCheck := socketCheck - defer func() { socketCheck = oldSocketCheck }() - socketCheck = func(string, string) (err error) { - return nil - } - err := checkDesignerHealth() - assert.Error(t, err, "mock err") - }) - - t.Run("health check fails for socket http server", func(t *testing.T) { - oldhttpGet := httpGet - defer func() { httpGet = oldhttpGet }() - httpGet = func(string) (resp *http.Response, err error) { - response := &http.Response{ - StatusCode: 200, - } - return response, nil - } - - oldSocketCheck := socketCheck - defer func() { socketCheck = oldSocketCheck }() - socketCheck = func(string, string) (err error) { - return errors.NewBadRequest("mock err") - } - err := checkDesignerHealth() - assert.Error(t, err, "mock err") - }) -} diff --git a/cmd/chkaceready/main.go b/cmd/chkaceready/main.go deleted file mode 100644 index b3c861c..0000000 --- a/cmd/chkaceready/main.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// chkaceready checks that ACE is ready for work, by checking if the admin REST endpoint port is available. -package main - -import ( - "fmt" - "net" - "os" -) - -func main() { - // Check if the integration server has started the admin REST endpoint - conn, err := net.Dial("tcp", "127.0.0.1:7600") - if err != nil { - fmt.Println(err) - os.Exit(1) - } - conn.Close() - -} diff --git a/cmd/runaceserver/integrationserver.go b/cmd/runaceserver/integrationserver.go deleted file mode 100644 index e2da12c..0000000 --- a/cmd/runaceserver/integrationserver.go +++ /dev/null @@ -1,1230 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "context" - "crypto/rand" - "crypto/x509" - "encoding/pem" - "errors" - "fmt" - "io" - "io/ioutil" - "math/big" - "net" - "net/http" - "net/url" - "os" - "os/exec" - "os/user" - "path" - "sort" - "strings" - "time" - - "github.com/fsnotify/fsnotify" - "github.com/ot4i/ace-docker/common/contentserver" - "github.com/ot4i/ace-docker/internal/command" - "github.com/ot4i/ace-docker/internal/configuration" - "github.com/ot4i/ace-docker/internal/name" - "github.com/ot4i/ace-docker/internal/webadmin" - "gopkg.in/yaml.v2" - - "software.sslmate.com/src/go-pkcs12" -) - -var osMkdir = os.Mkdir -var osCreate = os.Create -var osStat = os.Stat -var ioutilReadFile = ioutil.ReadFile -var ioutilReadDir = ioutil.ReadDir -var ioCopy = io.Copy -var contentserverGetBAR = contentserver.GetBAR -var watcher *fsnotify.Watcher -var createSHAServerConfYaml = createSHAServerConfYamlLocal -var homedir string = "/home/aceuser" -var initialConfigDir string = "/home/aceuser/initial-config" -var ConfigureWebAdminUsers = webadmin.ConfigureWebAdminUsers -var readServerConfFile = readServerConfFileLocal -var yamlUnmarshal = yaml.Unmarshal -var yamlMarshal = yaml.Marshal -var writeServerConfFile = writeServerConfFileLocal -var getConfigurationFromContentServer = getConfigurationFromContentServerLocal -var commandRunCmd = command.RunCmd -var packageBarFile = packageBarFileLocal -var deployBarFile = deployBarFileLocal - -// initialIntegrationServerConfig walks through the /home/aceuser/initial-config directory -// looking for directories (each containing some config data), then runs a shell script -// called ace_config_{directory-name}.sh to process that data. -func initialIntegrationServerConfig() error { - log.Printf("Performing initial configuration of integration server") - - if configuration.ContentServer { - getConfError := getConfigurationFromContentServer() - if getConfError != nil { - log.Errorf("Error getting configuration from content server: %v", getConfError) - return getConfError - } - } - - fileList, err := ioutilReadDir(homedir) - if err != nil { - log.Errorf("Error checking for an initial configuration folder: %v", err) - return err - } - - configDirExists := false - for _, file := range fileList { - if file.IsDir() && file.Name() == "initial-config" { - configDirExists = true - } - } - - if !configDirExists { - log.Printf("No initial configuration of integration server to perform") - return nil - } - - fileList, err = ioutil.ReadDir(initialConfigDir) - if err != nil { - log.Errorf("Error checking for initial configuration folders: %v", err) - return err - } - - // Sort filelist to server.conf.yaml gets written before webusers are processedconfigDirExists - SortFileNameAscend(fileList) - for _, file := range fileList { - if file.IsDir() && file.Name() != "mqsc" && file.Name() != "workdir_overrides" { - log.Printf("Processing configuration in folder %v", file.Name()) - if file.Name() == "webusers" { - log.Println("Configuring server.conf.yaml overrides - Webadmin") - updateServerConf := createSHAServerConfYaml() - if updateServerConf != nil { - log.Errorf("Error setting webadmin SHA server.conf.yaml: %v", updateServerConf) - return updateServerConf - } - log.Println("Configuring WebAdmin Users") - err := ConfigureWebAdminUsers(log) - if err != nil { - log.Errorf("Error configuring the WebAdmin users : %v", err) - return err - } - } - - // do not generate script for webusers dir or designerflowyaml - // designerflowyaml is where we mount the ConfigMaps containing the IntegrationFlow resources - if file.Name() != "webusers" && file.Name() != "designerflowyaml" && file.Name() != "generated-bar" { - cmd := exec.Command("ace_config_" + file.Name() + ".sh") - out, _, err := command.RunCmd(cmd) - if err != nil { - log.LogDirect(out) - log.Errorf("Error processing configuration in folder %v: %v", file.Name(), err) - return err - } - log.LogDirect(out) - } - } - - } - - enableMetrics := os.Getenv("ACE_ENABLE_METRICS") - if enableMetrics == "true" || enableMetrics == "1" { - enableMetricsError := enableMetricsInServerConf() - if enableMetricsError != nil { - log.Errorf("Error enabling metrics in server.conf.yaml: %v", enableMetricsError) - return enableMetricsError - } - } - - enableOpenTracing := os.Getenv("ACE_ENABLE_OPEN_TRACING") - if enableOpenTracing == "true" || enableOpenTracing == "1" { - enableOpenTracingError := enableOpenTracingInServerConf() - if enableOpenTracingError != nil { - log.Errorf("Error enabling user exits in server.conf.yaml: %v", enableOpenTracingError) - return enableOpenTracingError - } - } - - enableAdminssl := os.Getenv("ACE_ADMIN_SERVER_SECURITY") - if enableAdminssl == "true" || enableAdminssl == "1" { - enableAdminsslError := enableAdminsslInServerConf() - if enableAdminsslError != nil { - log.Errorf("Error enabling admin server security in server.conf.yaml: %v", enableAdminsslError) - return enableAdminsslError - } - } - - forceFlowHttps := os.Getenv("FORCE_FLOW_HTTPS") - if forceFlowHttps == "true" || forceFlowHttps == "1" { - log.Printf("Forcing all flows to be https. FORCE_FLOW_HTTPS=%v", forceFlowHttps) - - // create the https nodes keystore and password - password := generatePassword(10) - - log.Println("Force Flows to be HTTPS running keystore creation commands") - cmd := exec.Command("ace_forceflowhttps.sh", password) - out, _, err := command.RunCmd(cmd) - if err != nil { - log.Errorf("Error creating force flow https keystore and password, retrying. Error is %v", err) - log.LogDirect(out) - return err - } - - log.Println("Force Flows to be HTTPS in server.conf.yaml") - forceFlowHttpsError := forceFlowsHttpsInServerConf() - if forceFlowHttpsError != nil { - log.Errorf("Error forcing flows to https in server.conf.yaml: %v", forceFlowHttpsError) - return forceFlowHttpsError - } - - // Start watching the ..data/tls.key file where the tls.key secret is stored and if it changes recreate the p12 keystore and restart the HTTPSConnector dynamically - // need to watch the mounted ..data/tls.key file here as the tls.key symlink timestamp never changes - log.Println("Force Flows to be HTTPS starting to watch /home/aceuser/httpsNodeCerts/..data/tls.key") - watcher = watchForceFlowsHTTPSSecret(password) - err = watcher.Add("/home/aceuser/httpsNodeCerts/..data/tls.key") - if err != nil { - log.Errorf("Error watching /home/aceuser/httpsNodeCerts/tls.key for Force Flows to be HTTPS: %v", err) - } - } else { - log.Printf("Not Forcing all flows to be https as FORCE_FLOW_HTTPS=%v", forceFlowHttps) - } - - isEnabled, checkGlobalCacheError := checkGlobalCacheConfigurations() - if checkGlobalCacheError != nil { - log.Errorf("Error checking global cache configurations in server.conf.yaml: %v", checkGlobalCacheError) - return checkGlobalCacheError - } - if isEnabled { - log.Printf("*******") - log.Printf("The embedded global cache is enabled. This configuration is not supported in a containerized environment. For more information, see https://ibm.biz/aceglobalcache.") - log.Printf("*******") - } - - log.Println("Initial configuration of integration server complete") - - return nil -} - -func SortFileNameAscend(files []os.FileInfo) { - sort.Slice(files, func(i, j int) bool { - return files[i].Name() < files[j].Name() - }) -} - -func createSHAServerConfYamlLocal() error { - - oldserverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yamlUnmarshal([]byte(oldserverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return unmarshallError - } - - if serverconfMap["RestAdminListener"] == nil { - serverconfMap["RestAdminListener"] = map[string]interface{}{ - "authorizationEnabled": true, - "authorizationMode": "file", - "basicAuth": true, - } - } else { - restAdminListener := serverconfMap["RestAdminListener"].(map[interface{}]interface{}) - restAdminListener["authorizationEnabled"] = true - restAdminListener["authorizationMode"] = "file" - restAdminListener["basicAuth"] = true - - } - - serverconfYaml, marshallError := yamlMarshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return marshallError - } - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - - return nil - -} - -// enableMetricsInServerConf adds Statistics fields to the server.conf.yaml in overrides -// If the file does not exist already it gets created. -func enableMetricsInServerConf() error { - - log.Println("Enabling metrics in server.conf.yaml") - - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfYaml, manipulationError := addMetricsToServerConf(serverconfContent) - if manipulationError != nil { - return manipulationError - } - - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - - log.Println("Metrics enabled in server.conf.yaml") - - return nil -} - -// enableOpenTracingInServerConf adds OpenTracing UserExits fields to the server.conf.yaml in overrides -// If the file does not exist already it gets created. -func enableOpenTracingInServerConf() error { - - log.Println("Enabling OpenTracing in server.conf.yaml") - - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfYaml, manipulationError := addOpenTracingToServerConf(serverconfContent) - if manipulationError != nil { - return manipulationError - } - - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - - log.Println("OpenTracing enabled in server.conf.yaml") - - return nil -} - -// readServerConfFile returns the content of the server.conf.yaml file in the overrides folder -func readServerConfFileLocal() ([]byte, error) { - content, err := ioutil.ReadFile("/home/aceuser/ace-server/overrides/server.conf.yaml") - return content, err -} - -// writeServerConfFile writes the yaml content to the server.conf.yaml file in the overrides folder -// It creates the file if it doesn't already exist -func writeServerConfFileLocal(content []byte) error { - writeError := ioutil.WriteFile("/home/aceuser/ace-server/overrides/server.conf.yaml", content, 0644) - if writeError != nil { - log.Errorf("Error writing server.conf.yaml: %v", writeError) - return writeError - } - return nil -} - -// enableAdminsslInServerConf adds RestAdminListener configuration fields to the server.conf.yaml in overrides -// based on the env vars ACE_ADMIN_SERVER_KEY, ACE_ADMIN_SERVER_CERT, ACE_ADMIN_SERVER_CA -// If the file does not exist already it gets created. -func enableAdminsslInServerConf() error { - - log.Println("Enabling Admin Server Security in server.conf.yaml") - - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfYaml, manipulationError := addAdminsslToServerConf(serverconfContent) - if manipulationError != nil { - return manipulationError - } - - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - - log.Println("Admin Server Security enabled in server.conf.yaml") - - return nil -} - -// addMetricsToServerConf gets the content of the server.conf.yaml and adds the metrics fields to it -// It returns the updated server.conf.yaml content -func addMetricsToServerConf(serverconfContent []byte) ([]byte, error) { - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yamlUnmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return nil, unmarshallError - } - - snapshotObj := map[string]string{ - "publicationOn": "active", - "nodeDataLevel": "basic", - "outputFormat": "json", - "threadDataLevel": "none", - "accountingOrigin": "none", - } - - resourceObj := map[string]bool{ - "reportingOn": true, - } - - if serverconfMap["Statistics"] != nil { - statistics := serverconfMap["Statistics"].(map[interface{}]interface{}) - - if statistics["Snapshot"] != nil { - snapshot := statistics["Snapshot"].(map[interface{}]interface{}) - if snapshot["publicationOn"] == nil { - snapshot["publicationOn"] = "active" - } - if snapshot["nodeDataLevel"] == nil { - snapshot["nodeDataLevel"] = "basic" - } - if snapshot["outputFormat"] == nil { - snapshot["outputFormat"] = "json" - } else { - snapshot["outputFormat"] = fmt.Sprintf("%v", snapshot["outputFormat"]) + ",json" - } - if snapshot["threadDataLevel"] == nil { - snapshot["threadDataLevel"] = "none" - } - } else { - statistics["Snapshot"] = snapshotObj - } - - if statistics["Resource"] != nil { - resource := statistics["Resource"].(map[interface{}]interface{}) - if resource["reportingOn"] == nil { - resource["reportingOn"] = true - } - } else { - statistics["Resource"] = resourceObj - } - - } else { - serverconfMap["Statistics"] = map[string]interface{}{ - "Snapshot": snapshotObj, - "Resource": resourceObj, - } - } - - serverconfYaml, marshallError := yaml.Marshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return nil, marshallError - } - - return serverconfYaml, nil -} - -// addOpenTracingToServerConf gets the content of the server.conf.yaml and adds the OpenTracing UserExits fields to it -// It returns the updated server.conf.yaml content -func addOpenTracingToServerConf(serverconfContent []byte) ([]byte, error) { - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yaml.Unmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return nil, unmarshallError - } - - if serverconfMap["UserExits"] != nil { - userExits := serverconfMap["UserExits"].(map[interface{}]interface{}) - - userExits["activeUserExitList"] = "ACEOpenTracingUserExit" - userExits["userExitPath"] = "/opt/ACEOpenTracing" - - } else { - serverconfMap["UserExits"] = map[interface{}]interface{}{ - "activeUserExitList": "ACEOpenTracingUserExit", - "userExitPath": "/opt/ACEOpenTracing", - } - } - - serverconfYaml, marshallError := yaml.Marshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return nil, marshallError - } - - return serverconfYaml, nil -} - -// addAdminsslToServerConf gets the content of the server.conf.yaml and adds the Admin Server Security fields to it -// It returns the updated server.conf.yaml content -func addAdminsslToServerConf(serverconfContent []byte) ([]byte, error) { - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yaml.Unmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return nil, unmarshallError - } - - // Get the keys, certs location and default if not found - cert := os.Getenv("ACE_ADMIN_SERVER_CERT") - if cert == "" { - cert = "/home/aceuser/adminssl/tls.crt.pem" - } - - key := os.Getenv("ACE_ADMIN_SERVER_KEY") - if key == "" { - key = "/home/aceuser/adminssl/tls.key.pem" - } - - cacert := os.Getenv("ACE_ADMIN_SERVER_CA") - if cacert == "" { - cacert = "/home/aceuser/adminssl" - } - - isTrue := true - // Only update if there is not an existing entry in the override server.conf.yaml - // so we don't overwrite any customer provided configuration - if serverconfMap["RestAdminListener"] == nil { - serverconfMap["RestAdminListener"] = map[string]interface{}{ - "sslCertificate": cert, - "sslPassword": key, - "requireClientCert": isTrue, - "caPath": cacert, - } - log.Printf("Admin Server Security updating RestAdminListener using ACE_ADMIN_SERVER environment variables") - } else { - restAdminListener := serverconfMap["RestAdminListener"].(map[interface{}]interface{}) - - if restAdminListener["sslCertificate"] == nil { - restAdminListener["sslCertificate"] = cert - } - if restAdminListener["sslPassword"] == nil { - restAdminListener["sslPassword"] = key - } - if restAdminListener["requireClientCert"] == nil { - restAdminListener["requireClientCert"] = isTrue - } - if restAdminListener["caPath"] == nil { - restAdminListener["caPath"] = cacert - } - log.Printf("Admin Server Security merging RestAdminListener using ACE_ADMIN_SERVER environment variables") - } - - serverconfYaml, marshallError := yaml.Marshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return nil, marshallError - } - - return serverconfYaml, nil -} - -// getConfigurationFromContentServer checks if ACE_CONTENT_SERVER_URL exists. If so then it pulls -// a bar file from that URL -func getConfigurationFromContentServerLocal() error { - - // ACE_CONTENT_SERVER_URL can contain 1 or more comma separated urls - urls := os.Getenv("ACE_CONTENT_SERVER_URL") - if urls == "" { - log.Printf("No content server url available") - return nil - } - - defaultContentServer := os.Getenv("DEFAULT_CONTENT_SERVER") - if defaultContentServer == "" { - log.Printf("Can't tell if content server is default one so defaulting") - defaultContentServer = "true" - } - - err := osMkdir("/home/aceuser/initial-config/bars", os.ModePerm) - if err != nil { - log.Errorf("Error creating directory /home/aceuser/initial-config/bars: %v", err) - return err - } - - // check for AUTH env parameters (needed if auth is not encoded in urls for backward compatibility pending operator changes) - envServerName := os.Getenv("ACE_CONTENT_SERVER_NAME") - envToken := os.Getenv("ACE_CONTENT_SERVER_TOKEN") - - urlArray := strings.Split(urls, ",") - for _, barurl := range urlArray { - - serverName := envServerName - token := envToken - - // the ace content server name is the name of the secret where this cert is - // eg. secretName: {{ index (splitList ":" (index (splitList "/" (trim .Values.contentServerURL)) 2)) 0 | quote }} ? - // https://domsdash-ibm-ace-dashboard-prod:3443/v1/directories/CustomerDatabaseV1?userid=fsdjfhksdjfhsd - // or https://test-acecontentserver-ace-dom.svc:3443/v1/directories/testdir?e31d23f6-e3ba-467d-ab3b-ceb0ab12eead - // Mutli-tenant : https://test-acecontentserver-ace-dom.svc:3443/v1/namespace/directories/testdir - // https://dataplane-api-dash.appconnect:3443/v1/appc-fakeid/directories/ace_manualtest_callableflow - - splitOnSlash := strings.Split(barurl, "/") - - if len(splitOnSlash) > 2 { - serverName = strings.Split(splitOnSlash[2], ":")[0] // test-acecontentserver.ace-dom - } else { - // if we have not found serverName from either env or url error - log.Printf("No content server name available but a url is defined - Have you forgotten to define your BAR_AUTH configuration resource?") - return errors.New("No content server name available but a url is defined - Have you forgotten to define your BAR_AUTH configuration resource?") - } - - // if ACE_CONTENT_SERVER_TOKEN was set use it. It may have been read from a secret - // otherwise then look in the url for ? - if token == "" { - splitOnQuestion := strings.Split(barurl, "?") - if len(splitOnQuestion) > 1 && splitOnQuestion[1] != "" { - barurl = splitOnQuestion[0] // https://test-acecontentserver.ace-dom.svc:3443/v1/directories/testdir - token = splitOnQuestion[1] //userid=fsdjfhksdjfhsd - } else if defaultContentServer == "true" { - // if we have not found token from either env or url error - log.Errorf("No content server token available but a url is defined") - return errors.New("No content server token available but a url is defined") - } - } - - // use the last part of the url path (base) for the filename - u, err := url.Parse(barurl) - if err != nil { - log.Errorf("Error parsing content server url : %v", err) - return err - } - - var filename string - if len(urlArray) == 1 { - // temporarily override the bar name with "barfile.bar" if we only have ONE bar file until mq connector is fixed to support any bar name - filename = "/home/aceuser/initial-config/bars/barfile.bar" - } else { - // Multiple bar support. Need to loop to check that the file does not already exist - // (case where multiple bars have the same name) - isAvailable := false - count := 0 - for !isAvailable { - if count == 0 { - filename = "/home/aceuser/initial-config/bars/" + path.Base(u.Path) + ".bar" - } else { - filename = "/home/aceuser/initial-config/bars/" + path.Base(u.Path) + "-" + fmt.Sprint(count) + ".bar" - log.Printf("Previous path already in use. Testing filename: " + filename) - } - - if _, err := osStat(filename); os.IsNotExist(err) { - log.Printf("No existing file on that path so continuing") - isAvailable = true - } - count++ - } - } - - log.Printf("Will save bar as: " + filename) - - file, err := osCreate(filename) - if err != nil { - log.Errorf("Error creating file %v: %v", file, err) - return err - } - defer file.Close() - - // Create a CA certificate pool and add cacert to it - var contentServerCACert string - if defaultContentServer == "true" { - log.Printf("Getting configuration from content server") - contentServerCACert = "/home/aceuser/ssl/cacert.pem" - barurl = barurl + "?archive=true" - } else { - log.Printf("Getting configuration from custom content server") - contentServerCACert = os.Getenv("CONTENT_SERVER_CA") - if token != "" { - barurl = barurl + "?" + token - } - if contentServerCACert == "" { - log.Printf("CONTENT_SERVER_CA not defined") - return errors.New("CONTENT_SERVER_CA not defined") - } - } - log.Printf("Using the following url: " + barurl) - - log.Printf("Using ca file %s", contentServerCACert) - caCert, err := ioutilReadFile(contentServerCACert) - if err != nil { - log.Errorf("Error reading CA Certificate") - return errors.New("Error reading CA Certificate") - } - - contentServerCert := os.Getenv("CONTENT_SERVER_CERT") - contentServerKey := os.Getenv("CONTENT_SERVER_KEY") - - bar, err := contentserverGetBAR(barurl, serverName, token, caCert, contentServerCert, contentServerKey, log) - if err != nil { - return err - } - defer bar.Close() - - _, err = ioCopy(file, bar) - if err != nil { - log.Errorf("Error writing file %v: %v", file, err) - return err - } - - log.Printf("Configuration pulled from content server successfully") - - } - return nil -} - -// startIntegrationServer launches the IntegrationServer process in the background as the user "aceuser". -// This returns a BackgroundCmd, wrapping the backgrounded process, or an error if we completely failed to -// start the process -func startIntegrationServer() command.BackgroundCmd { - logOutputFormat := getLogOutputFormat() - - serverName, err := name.GetIntegrationServerName() - if err != nil { - log.Printf("Error getting integration server name: %v", err) - returnErr := command.BackgroundCmd{} - returnErr.ReturnCode = -1 - returnErr.ReturnError = err - return returnErr - } - - defaultAppName := os.Getenv("ACE_DEFAULT_APPLICATION_NAME") - if defaultAppName == "" { - log.Printf("No default application name supplied. Using the integration server name instead.") - defaultAppName = serverName - } - - thisUser, err := user.Current() - if err != nil { - log.Errorf("Error finding this user: %v", err) - returnErr := command.BackgroundCmd{} - returnErr.ReturnCode = -1 - returnErr.ReturnError = err - return returnErr - } - - return command.RunAsUserBackground(thisUser.Username, "ace_integration_server.sh", log, "-w", "/home/aceuser/ace-server", "--name", serverName, "--log-output-format", logOutputFormat, "--console-log", "--default-application-name", defaultAppName) -} - -func waitForIntegrationServer() error { - for { - cmd := exec.Command("chkaceready") - _, rc, err := command.RunCmd(cmd) - if rc != 0 || err != nil { - knative := os.Getenv("KNATIVESERVICE") - if knative == "true" || knative == "1" { - log.Printf("Integration server & FDR not ready yet") - } else { - log.Printf("Integration server not ready yet") - } - } - if rc == 0 { - break - } - time.Sleep(5 * time.Second) - } - return nil -} - -func stopIntegrationServer(integrationServerProcess command.BackgroundCmd) { - if integrationServerProcess.Cmd != nil && integrationServerProcess.Started && !integrationServerProcess.Finished { - command.SigIntBackground(integrationServerProcess) - command.WaitOnBackground(integrationServerProcess) - } -} - -func createWorkDir() error { - if _, err := os.Stat("/home/aceuser/ace-server/server.conf.yaml"); errors.Is(err, os.ErrNotExist) { - log.Printf("Attempting to initialise /home/aceuser/ace-server") - - // Run mqsicreateworkdir code - cmd := exec.Command("/opt/ibm/ace-12/server/bin/mqsicreateworkdir", "/home/aceuser/ace-server") - _, _, err := command.RunCmd(cmd) - if err != nil { - log.Printf("Error initializing work dir") - return err - } - log.Printf("Work dir initialization complete") - } else { - log.Printf("/home/aceuser/ace-server/server.conf.yaml found, not initializing Work dir") - } - return nil -} - -func createWorkDirSymLink() error { - log.Printf("Attempting to move / symlink /home/aceuser/ace-server to shared mount") - cmd := exec.Command("cp", "-r", "/home/aceuser/ace-server", "/workdir-shared/") - _, _, err := command.RunCmd(cmd) - if err != nil { - log.Printf("Error copying workdir to shared work dir") - return err - } - cmd = exec.Command("rm", "-rf", "/home/aceuser/ace-server") - _, _, err = command.RunCmd(cmd) - if err != nil { - log.Printf("Error deleting original work dir") - return err - } - cmd = exec.Command("ln", "-s", "/workdir-shared/ace-server", "/home/aceuser/") - _, _, err = command.RunCmd(cmd) - if err != nil { - log.Printf("Error creating symlink") - return err - } - - log.Printf("Work dir symlink complete") - return nil -} - -func checkLogs() error { - log.Printf("Contents of log directory") - system("ls", "-l", "/home/aceuser/ace-server/config/common/log") - - if os.Getenv("MQSI_PREVENT_CONTAINER_SHUTDOWN") == "true" { - log.Printf("MQSI_PREVENT_CONTAINER_SHUTDOWN set to blocking container shutdown to enable log copy out") - log.Printf("Once all logs have been copied out please kill container") - select {} - } - - log.Printf("If you want to stop the container shutting down to enable retrieval of these files please set the environment variable \"MQSI_PREVENT_CONTAINER_SHUTDOWN=true\"") - log.Printf("If you are running under kubernetes you will also need to disable the livenessProbe") - log.Printf("Log checking complete") - return nil -} - -func system(cmd string, arg ...string) { - out, err := exec.Command(cmd, arg...).Output() - if err != nil { - log.Printf(err.Error()) - } - log.Printf(string(out)) -} - -// applyWorkdirOverrides walks through the home/aceuser/initial-config/workdir_overrides directory -// we want to do this here rather than the loop above as we want to make sure we have done everything -// else before applying the workdir overrides and then start the integration server -func applyWorkdirOverrides() error { - - fileList, err := ioutil.ReadDir("/home/aceuser") - if err != nil { - log.Errorf("Error checking for the aceuser home directoy: %v", err) - return err - } - - configDirExists := false - for _, file := range fileList { - if file.IsDir() && file.Name() == "initial-config" { - configDirExists = true - } - } - - if !configDirExists { - log.Printf("No initial-config directory found") - return nil - } - - fileList, err = ioutil.ReadDir("/home/aceuser/initial-config") - if err != nil { - log.Errorf("Error checking for initial configuration folders: %v", err) - return err - } - - for _, file := range fileList { - if file.IsDir() && file.Name() == "workdir_overrides" { - log.Println("Applying workdir overrides to the integration server") - cmd := exec.Command("ace_config_workdir_overrides.sh") - out, _, err := command.RunCmd(cmd) - log.LogDirect(out) - if err != nil { - log.Errorf("Error processing workdir overrides in folder %v: %v", file.Name(), err) - return err - } - log.Printf("Workdir overrides applied to the integration server complete") - } - } - - return nil -} - -// forceFlowHttps adds ResourceManagers HTTPSConnector fields to the server.conf.yaml in overrides using the keystore and password created -// If the file does not exist already it gets created. -func forceFlowsHttpsInServerConf() error { - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfYaml, manipulationError := addforceFlowsHttpsToServerConf(serverconfContent) - if manipulationError != nil { - return manipulationError - } - - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - log.Println("Force Flows to be HTTPS in server.conf.yaml completed") - - return nil -} - -// addforceFlowsHttpsToServerConf gets the content of the server.conf.yaml and adds the Force Flow Security fields to it -// It returns the updated server.conf.yaml content -func addforceFlowsHttpsToServerConf(serverconfContent []byte) ([]byte, error) { - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yaml.Unmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return nil, unmarshallError - } - - isTrue := true - keystoreFile := "/home/aceuser/ace-server/https-keystore.p12" - keystorePassword := "brokerHTTPSKeystore::password" - keystoreType := "PKCS12" - - ResourceManagersMap := make(map[interface{}]interface{}) - ResourceManagersMap["HTTPSConnector"] = map[string]interface{}{ - "KeystoreFile": keystoreFile, - "KeystorePassword": keystorePassword, - "KeystoreType": keystoreType, - } - // Only update if there is not an existing entry in the override server.conf.yaml - // so we don't overwrite any customer provided configuration - if serverconfMap["forceServerHTTPS"] == nil { - serverconfMap["forceServerHTTPS"] = isTrue - log.Printf("Force Flows HTTPS Security setting forceServerHTTPS to true") - } - - if serverconfMap["ResourceManagers"] == nil { - serverconfMap["ResourceManagers"] = ResourceManagersMap - log.Printf("Force Flows HTTPS Security creating ResourceManagers->HTTPSConnector") - } else { - resourceManagers := serverconfMap["ResourceManagers"].(map[interface{}]interface{}) - if resourceManagers["HTTPSConnector"] == nil { - resourceManagers["HTTPSConnector"] = ResourceManagersMap["HTTPSConnector"] - log.Printf("Force Flows HTTPS Security updating ResourceManagers creating HTTPSConnector") - } else { - httpsConnector := resourceManagers["HTTPSConnector"].(map[interface{}]interface{}) - log.Printf("Force Flows HTTPS Security merging ResourceManagers->HTTPSConnector") - - if httpsConnector["KeystoreFile"] == nil { - httpsConnector["KeystoreFile"] = keystoreFile - } else { - log.Printf("Force Flows HTTPS Security leaving ResourceManagers->HTTPSConnector->KeystoreFile unchanged") - } - if httpsConnector["KeystorePassword"] == nil { - httpsConnector["KeystorePassword"] = keystorePassword - } else { - log.Printf("Force Flows HTTPS Security leaving ResourceManagers->HTTPSConnector->KeystorePassword unchanged") - } - if httpsConnector["KeystoreType"] == nil { - httpsConnector["KeystoreType"] = keystoreType - } else { - log.Printf("Force Flows HTTPS Security leaving ResourceManagers->HTTPSConnector->KeystoreType unchanged") - } - } - } - - serverconfYaml, marshallError := yaml.Marshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return nil, marshallError - } - - return serverconfYaml, nil -} - -func checkGlobalCacheConfigurations() (bool, error) { - isEmbeddedCacheEnabled := false - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return isEmbeddedCacheEnabled, readError - } - } - - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yaml.Unmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return isEmbeddedCacheEnabled, unmarshallError - } - - if serverconfMap["ResourceManagers"] != nil { - resourceManagers := serverconfMap["ResourceManagers"].(map[interface{}]interface{}) - if resourceManagers["GlobalCache"] != nil { - globalCache := resourceManagers["GlobalCache"].(map[interface{}]interface{}) - if globalCache["cacheOn"] == true && globalCache["enableCatalogService"] == true && globalCache["enableContainerService"] == true { - isEmbeddedCacheEnabled = true - } - } - } - - return isEmbeddedCacheEnabled, nil -} - -func generatePassword(length int64) string { - var i, e = big.NewInt(length), big.NewInt(10) - bigInt, _ := rand.Int(rand.Reader, i.Exp(e, i, nil)) - return bigInt.String() -} - -func watchForceFlowsHTTPSSecret(password string) *fsnotify.Watcher { - - //set up watch on the /home/aceuser/httpsNodeCerts/tls.key file - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Errorf("Error creating new watcher for Force Flows to be HTTPS: %v", err) - } - - go func() { - for { - select { - case event, ok := <-watcher.Events: - if !ok { - return - } - - // https://github.com/istio/istio/issues/7877 Remove is triggered for the ..data directory when the secret is updated so check for remove too - if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Remove == fsnotify.Remove { - log.Println("modified file regenerating /home/aceuser/ace-server/https-keystore.p12 and restarting HTTPSConnector:", event.Name) - time.Sleep(1 * time.Second) - - // 1. generate new p12 /home/aceuser/ace-server/https-keystore.p12 and then - generateHTTPSKeystore("/home/aceuser/httpsNodeCerts/tls.key", "/home/aceuser/httpsNodeCerts/tls.crt", "/home/aceuser/ace-server/https-keystore.p12", password) - - // 2. patch the HTTPSConnector to pick this up - patchHTTPSConnector("/home/aceuser/ace-server/config/IntegrationServer.uds") - - // 3. Need to start watching the newly created/ mounted tls.key - err = watcher.Add("/home/aceuser/httpsNodeCerts/..data/tls.key") - if err != nil { - log.Errorf("Error watching /home/aceuser/httpsNodeCerts/tls.key for Force Flows to be HTTPS: %v", err) - } - } - - case err, ok := <-watcher.Errors: - log.Println("error from Force Flows to be HTTPS watcher:", err) - if !ok { - return - } - } - } - }() - - return watcher -} - -var generateHTTPSKeystore = localGenerateHTTPSKeystore - -func localGenerateHTTPSKeystore(privateKeyLocation string, certificateLocation string, keystoreLocation string, password string) { - // create /home/aceuser/ace-server/https-keystore.p12 using: - // single /home/aceuser/httpsNodeCerts/tls.key - // single /home/aceuser/httpsNodeCerts/tls.crt - - //Script version: openssl pkcs12 -export -in ${certfile} -inkey ${keyfile} -out /home/aceuser/ace-server/https-keystore.p12 -name ${alias} -password pass:${1} 2>&1) - - // Load the private key file into a rsa.PrivateKey - privateKeyFile, err := ioutil.ReadFile(privateKeyLocation) - if err != nil { - log.Error("Error loading "+privateKeyLocation, err) - } - privateKeyPem, _ := pem.Decode(privateKeyFile) - if privateKeyPem.Type != "RSA PRIVATE KEY" { - log.Error(privateKeyLocation + " is not of type RSA private key") - } - privateKeyPemBytes := privateKeyPem.Bytes - parsedPrivateKey, err := x509.ParsePKCS1PrivateKey(privateKeyPemBytes) - if err != nil { - log.Error("Error parsing "+privateKeyLocation+" RSA PRIVATE KEY", err) - } - - // Load the single cert file into a x509.Certificate - certificateFile, err := ioutil.ReadFile(certificateLocation) - if err != nil { - log.Error("Error loading "+certificateLocation, err) - } - certificatePem, _ := pem.Decode(certificateFile) - if certificatePem.Type != "CERTIFICATE" { - log.Error(certificateLocation+" is not CERTIFICATE type ", certificatePem.Type) - } - certificatePemBytes := certificatePem.Bytes - parsedCertificate, err := x509.ParseCertificate(certificatePemBytes) - if err != nil { - log.Error("Error parsing "+certificateLocation+" CERTIFICATE", err) - } - - // Create Keystore - pfxBytes, err := pkcs12.Encode(rand.Reader, parsedPrivateKey, parsedCertificate, []*x509.Certificate{}, password) - if err != nil { - log.Error("Error creating the "+keystoreLocation, err) - } - - // Write out the Keystore 600 (rw- --- ---) - err = ioutil.WriteFile(keystoreLocation, pfxBytes, 0600) - if err != nil { - log.Error(err) - } -} - -var patchHTTPSConnector = localPatchHTTPSConnector - -func localPatchHTTPSConnector(uds string) { - // curl -GET --unix-socket /home/aceuser/ace-server/config/IntegrationServer.uds http://localhost/apiv2/resource-managers/https-connector - // curl -d "" -POST --unix-socket /home/aceuser/ace-server/config/IntegrationServer.uds http://localhost/apiv2/resource-managers/https-connector/refresh-tls-config -i - // HTTP/1.1 200 OK - // Content-Length: 0 - // Content-Type: application/json - - // use unix domain socket - httpc := http.Client{ - Transport: &http.Transport{ - DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { - return net.Dial("unix", uds) - }, - }, - } - - var err error - // can be any path root but use localhost to match curl - _, err = httpc.Post("http://localhost/apiv2/resource-managers/https-connector/refresh-tls-config", "application/octet-stream", strings.NewReader("")) - if err != nil { - log.Println("error during call to restart HTTPSConnector for Force Flows HTTPS", err) - } else { - log.Println("Call made to restart HTTPSConnector for Force Flows HTTPS") - } - -} - -func deployIntegrationFlowResources() error { - log.Println("Deploying IntegrationFlow resources") - err := packageBarFile() - if err != nil { - log.Println(err) - return err - } - - err = deployBarFile() - if err != nil { - log.Println(err) - return err - } - - return nil -} - -func packageBarFileLocal() error { - cmd := exec.Command("/opt/ibm/ace-12/common/node/bin/node", "/opt/ibm/acecc-bar-gen/acecc-bar-gen.js", "2>&1") - out, _, err := commandRunCmd(cmd) - if err != nil { - log.Println("Error packaging BAR file :", err) - return err - } - log.Print(out) - - return nil -} - -func deployBarFileLocal() error { - mqsiCommand := exec.Command("/bin/sh", "-c", "source /opt/ibm/ace-12/server/bin/mqsiprofile; /opt/ibm/ace-12/server/bin/ibmint deploy --input-bar-file /home/aceuser/initial-config/generated-bar/integrationFlowResources.bar --output-work-directory /home/aceuser/ace-server") - out, _, err := commandRunCmd(mqsiCommand) - if err != nil { - fmt.Println("Error deploying BAR file :", err) - return err - } - log.Print(out) - return nil -} - -func deployCSAPIFlows() error { - csAPIProxy := os.Getenv("CONNECTOR_SERVICE") - if csAPIProxy == "true" || csAPIProxy == "1" { - log.Println("Deploying Connector Service API Proxy Flow") - cpCommand := exec.Command("cp", "--recursive", "/home/aceuser/deps/CSAPI", "/home/aceuser/ace-server/run/CSAPI") - out, _, err := commandRunCmd(cpCommand) - if err != nil { - log.Println("Error deploying copy CS API flow files :", err) - return err - } - log.Print(out) - log.Println("Connector Service API flow deployed") - } - return nil -} - -// This function updates the server.conf.yaml with the fields required to -// force basic auth on all flows -func forceflowbasicauthServerConfUpdate() error { - - log.Println("Enabling basic auth on all flows in server.conf.yaml") - - serverconfContent, readError := readServerConfFile() - if readError != nil { - if !os.IsNotExist(readError) { - // Error is different from file not existing (if the file does not exist we will create it ourselves) - log.Errorf("Error reading server.conf.yaml: %v", readError) - return readError - } - } - - serverconfMap := make(map[interface{}]interface{}) - unmarshallError := yamlUnmarshal([]byte(serverconfContent), &serverconfMap) - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return unmarshallError - } - - if serverconfMap["forceServerHTTPSecurityProfile"] == nil { - serverconfMap["forceServerHTTPSecurityProfile"] = "{DefaultPolicies}:SecProfLocal" - } else { - log.Println("WARNING: You have asked to force basic auth on all flows but already have forceServerHTTPSecurityProfile set") - log.Println("WARNING: We will not override this existing value which may prevent the basic working. ") - } - - serverconfYaml, marshallError := yamlMarshal(&serverconfMap) - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return marshallError - } - - writeError := writeServerConfFile(serverconfYaml) - if writeError != nil { - return writeError - } - - log.Println("forceServerHTTPSecurityProfile enabled in server.conf.yaml") - - return nil -} \ No newline at end of file diff --git a/cmd/runaceserver/integrationserver_internal_test.go b/cmd/runaceserver/integrationserver_internal_test.go deleted file mode 100644 index 1d02e01..0000000 --- a/cmd/runaceserver/integrationserver_internal_test.go +++ /dev/null @@ -1,1240 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "errors" - "io" - "io/ioutil" - "net" - "net/http" - "os" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/stretchr/testify/assert" -) - -var yamlTests = []struct { - in string - out string -}{ - { // User's yaml has Statistics - it should keep accountingOrigin in Statics and any other main sections - `Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -Statistics: - Snapshot: - accountingOrigin: 'test' - Archive: - test1: 'blah' - test2: 'blah2'`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -Statistics: - Archive: - test1: blah - test2: blah2 - Resource: - reportingOn: true - Snapshot: - accountingOrigin: test - nodeDataLevel: basic - outputFormat: json - publicationOn: active - threadDataLevel: none -`}, - { // User's yaml does not have a Statistics section, it adds the default metrics info - ` -Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS'`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -Statistics: - Resource: - reportingOn: true - Snapshot: - accountingOrigin: none - nodeDataLevel: basic - outputFormat: json - publicationOn: active - threadDataLevel: none -`}, - { // User's yaml has accountingOrigin in Statistics.Snapshot. It keeps this value. - ` -Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -Statistics: - Snapshot: - accountingOrigin: 'test'`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -Statistics: - Resource: - reportingOn: true - Snapshot: - accountingOrigin: test - nodeDataLevel: basic - outputFormat: json - publicationOn: active - threadDataLevel: none -`}, -{ // User's yaml has accountingOrigin in Statistics.Snapshot. It keeps this value. -` -Statistics: - Snapshot: - accountingOrigin: mockValue1 - nodeDataLevel: mockValue2 - outputFormat: csv - publicationOn: mockValue3 - threadDataLevel: mockValue4`, -`Statistics: - Resource: - reportingOn: true - Snapshot: - accountingOrigin: mockValue1 - nodeDataLevel: mockValue2 - outputFormat: csv,json - publicationOn: mockValue3 - threadDataLevel: mockValue4 -`}, -{ // User's yaml has accountingOrigin in Statistics.Snapshot and overriden outputFormat. It keeps these values. -` -Statistics: - Resource: - outputFormat: file`, -`Statistics: - Resource: - outputFormat: file - reportingOn: true - Snapshot: - accountingOrigin: none - nodeDataLevel: basic - outputFormat: json - publicationOn: active - threadDataLevel: none -`}, -{ // User's yaml has bare minimum. Our defaults added. -` -Statistics:`, -`Statistics: - Resource: - reportingOn: true - Snapshot: - accountingOrigin: none - nodeDataLevel: basic - outputFormat: json - publicationOn: active - threadDataLevel: none -`}, -} - -func TestAddMetricsToServerConf(t *testing.T) { - for _, table := range yamlTests { - out, err := addMetricsToServerConf([]byte(table.in)) - if err != nil { - t.Error(err) - } - stringOut := string(out) - if stringOut != table.out { - t.Errorf("addMetricsToServerConf expected %v, got %v", table.out, stringOut) - } - } -} - -func TestCheckLogs(t *testing.T) { - err := checkLogs() - if err != nil { - t.Error(err) - } -} - - -var yamlAdminTests = []struct { - in string - out string -}{ - { // User's yaml does not have a ResourceAdminListener section, so it is added -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS'`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -RestAdminListener: - caPath: /home/aceuser/adminssl - requireClientCert: true - sslCertificate: /home/aceuser/adminssl/tls.crt.pem - sslPassword: /home/aceuser/adminssl/tls.key.pem -`}, - { // User's yaml has RestAdminListener in don't alter. -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -RestAdminListener: - caPath: "test" - requireClientCert: false - sslCertificate: "test" - sslPassword: "test"`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -RestAdminListener: - caPath: test - requireClientCert: false - sslCertificate: test - sslPassword: test -`}, - { // User's yaml has a ResourceAdminListener section, so ours is merged with users taking precedence -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -RestAdminListener: - authorizationEnabled: true - requireClientCert: false - authorizationMode: file - sslPassword: "test" -`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -RestAdminListener: - authorizationEnabled: true - authorizationMode: file - caPath: /home/aceuser/adminssl - requireClientCert: false - sslCertificate: /home/aceuser/adminssl/tls.crt.pem - sslPassword: test -`}, -} - - -func TestAddAdminsslToServerConf(t *testing.T) { - for _, table := range yamlAdminTests { - out, err := addAdminsslToServerConf([]byte(table.in)) - if err != nil { - t.Error(err) - } - stringOut := string(out) - if stringOut != table.out { - t.Errorf("addAdminsslToServerConf expected \n%v, got \n%v", table.out, stringOut) - } - } -} - -var yamlForceFlowsHttpsTests = []struct { - in string - out string -}{ - { // User's yaml does not have a ResourceManagers section, so it is added -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS'`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -ResourceManagers: - HTTPSConnector: - KeystoreFile: /home/aceuser/ace-server/https-keystore.p12 - KeystorePassword: brokerHTTPSKeystore::password - KeystoreType: PKCS12 -forceServerHTTPS: true -`}, - { // User's yaml has ResourceManagers in don't alter. -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -ResourceManagers: - HTTPSConnector: - ListenerPort: 7843 - KeystoreFile: '/home/aceuser/keystores/des-01-quickstart-ma-designer-ks' - KeystorePassword: 'changeit' - KeystoreType: 'PKCS12' - CORSEnabled: true`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -ResourceManagers: - HTTPSConnector: - CORSEnabled: true - KeystoreFile: /home/aceuser/keystores/des-01-quickstart-ma-designer-ks - KeystorePassword: changeit - KeystoreType: PKCS12 - ListenerPort: 7843 -forceServerHTTPS: true -`}, - { // User's yaml has a ResourceManagers HTTPSConnector section, so ours is merged with users taking precedence -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -ResourceManagers: - HTTPSConnector: - ListenerPort: 7843 - KeystorePassword: 'changeit' - CORSEnabled: true -`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -ResourceManagers: - HTTPSConnector: - CORSEnabled: true - KeystoreFile: /home/aceuser/ace-server/https-keystore.p12 - KeystorePassword: changeit - KeystoreType: PKCS12 - ListenerPort: 7843 -forceServerHTTPS: true -`}, -{ // User's yaml has a ResourceManagers but no HTTPSConnector section, so ours is merged with users taking precedence -`Defaults: - defaultApplication: '' - policyProject: 'DefaultPolicies' - Policies: - HTTPSConnector: 'HTTPS' -ResourceManagers: - SOMETHINGELSE: - ListenerPort: 9999 - KeystorePassword: 'otherbit' - CORSEnabled: false -`, -`Defaults: - Policies: - HTTPSConnector: HTTPS - defaultApplication: "" - policyProject: DefaultPolicies -ResourceManagers: - HTTPSConnector: - KeystoreFile: /home/aceuser/ace-server/https-keystore.p12 - KeystorePassword: brokerHTTPSKeystore::password - KeystoreType: PKCS12 - SOMETHINGELSE: - CORSEnabled: false - KeystorePassword: otherbit - ListenerPort: 9999 -forceServerHTTPS: true -`}, -} - -func TestAddforceFlowsHttpsToServerConf(t *testing.T) { - for _, table := range yamlForceFlowsHttpsTests { - out, err := addforceFlowsHttpsToServerConf([]byte(table.in)) - if err != nil { - t.Error(err) - } - stringOut := string(out) - if stringOut != table.out { - t.Errorf("addforceFlowsHttpsToServerConf expected \n%v, got \n%v", table.out, stringOut) - } - } -} - -func TestCheckGlobalCacheConfigurations(t *testing.T) { - t.Run("When global cache is not configured, no warning message is issued.", func(t *testing.T) { - serverConfigYaml := `ResourceManagers:` - - readServerConfFile = func() ([]byte, error) { - return []byte(serverConfigYaml), nil - } - - isEmbeddedCacheEnabled, err := checkGlobalCacheConfigurations() - assert.NoError(t, err) - assert.Equal(t, isEmbeddedCacheEnabled, false, "The WXS server should be disabled.") - }) - - t.Run("When global cache is disabled, no warning message is issued.", func(t *testing.T) { - serverConfigYaml := -`ResourceManagers: - GlobalCache: - cacheOn: false - enableCatalogService: false - enableContainerService: false` - - readServerConfFile = func() ([]byte, error) { - return []byte(serverConfigYaml), nil - } - - isEmbeddedCacheEnabled, err := checkGlobalCacheConfigurations() - assert.NoError(t, err) - assert.Equal(t, isEmbeddedCacheEnabled, false, "The WXS server should be disabled.") - }) - - t.Run("When global cache is enabled without the WXS server, no warning message is issued.", func(t *testing.T) { - serverConfigYaml := -`ResourceManagers: - GlobalCache: - cacheOn: true - enableCatalogService: false - enableContainerService: false` - - readServerConfFile = func() ([]byte, error) { - return []byte(serverConfigYaml), nil - } - - isEmbeddedCacheEnabled, err := checkGlobalCacheConfigurations() - assert.NoError(t, err) - assert.Equal(t, isEmbeddedCacheEnabled, false, "The WXS server should be disabled.") - }) - - t.Run("When both global cache and the WXS server are enabled, a warning message is issued.", func(t *testing.T) { - serverConfigYaml := -`ResourceManagers: - GlobalCache: - cacheOn: true - enableCatalogService: true - enableContainerService: true` - - readServerConfFile = func() ([]byte, error) { - return []byte(serverConfigYaml), nil - } - - isEmbeddedCacheEnabled, err := checkGlobalCacheConfigurations() - assert.NoError(t, err) - assert.Equal(t, isEmbeddedCacheEnabled, true, "The WXS server should be enabled.") - }) -} - -func TestGetConfigurationFromContentServer(t *testing.T) { - - barDirPath := "/home/aceuser/initial-config/bars" - var osMkdirRestore = osMkdir - var osCreateRestore = osCreate - var osStatRestore = osStat - var ioutilReadFileRestore = ioutilReadFile - var ioCopyRestore = ioCopy - var contentserverGetBARRestore = contentserverGetBAR - - var dummyCert = `-----BEGIN CERTIFICATE----- - MIIC1TCCAb2gAwIBAgIJANoE+RGRB8c6MA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNV - BAMTD3d3dy5leGFtcGxlLmNvbTAeFw0yMTA1MjUwMjE3NDlaFw0zMTA1MjMwMjE3 - NDlaMBoxGDAWBgNVBAMTD3d3dy5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEB - BQADggEPADCCAQoCggEBAOOh3VRmp/NfWbzXONxeLK/JeNvtC+TnWCz6HgtRzlhe - 7qe55dbm51Z6+l9y3C4KYH/K+a8Wgb9pKfeGCtfhRybVW3lYFtfudW7LrvgTyRIr - r/D9UPK9J+4p/ucClGERixSY8a2F4L3Bt3o1eKDeRnz5rUlmO2mJOw41p8sSgWtp - 9MOaw5OdUrqgXh3qWkctJ8gWS2eMddh0T5ZTYE2VAOW8mTtSwAFYeBSzB+/mcl8Y - BE7pOd71a3ka2xxLwm9KfSGLQTw0K7PxeZvdEcAq+Ffb+f/eOw0TwkNPGjnmQxLa - MSEDDOw0AzYPibRAZIBfhLeBOHifxTd0XbCYOUAD5zkCAwEAAaMeMBwwGgYDVR0R - BBMwEYIPd3d3LmV4YW1wbGUuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQAuTsah7W7H - HRvsuzEnPNXKKuy/aTvI3nnr6P9n5QCsdFirPyAS3/H7iNbvHVfSTfFa+b2qDaGU - tbLJkT84m/R6gIIzRMbA0WUwQ7GRJE3KwKIytSZcTY0AuQnXy7450COmka9ztBuI - rPYRV01LzLPJxO9A07tThSFMzhUiKrkeB5pBIjzgcYgQZNCfNtqpITmXKbO84oWA - rbxwlF1RCvmAvzIqQx21IX16i/vH/cQ3VvCIQJt1X47KCKmWaft9AkCdjyWrFh5M - ZhCApdQ3e/+TGkBlX32kHaRmn4Ascib7aQI2ugvowqLYFg/2LSeA0nexL+hA2GJB - GKhFuYZvggen - -----END CERTIFICATE-----` - - osMkdirError := errors.New("osMkdir failed") - - var reset = func() { - osMkdir = func(path string, mode os.FileMode) (error) { - panic("should be mocked") - } - osCreate = func(file string) (*os.File, error) { - panic("should be mocked") - } - osStat = func(file string) (os.FileInfo, error) { - panic("should be mocked") - } - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - panic("should be mocked") - } - ioutilReadFile = func(cafile string) ([]byte, error) { - panic("should be mocked") - } - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - panic("should be mocked") - } - } - - var restore = func() { - osMkdir = osMkdirRestore - osCreate = osCreateRestore - osStat = osStatRestore - ioutilReadFile = ioutilReadFileRestore - ioCopy = ioCopyRestore - contentserverGetBAR = contentserverGetBARRestore - } - - reset() - defer restore() - - t.Run("No error when ACE_CONTENT_SERVER_URL not set", func(t *testing.T) { - - os.Unsetenv("ACE_CONTENT_SERVER_URL") - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - }) - - t.Run("Fails when mkDir fails", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barAuth = "userid=fsdjfhksdjfhsd" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1" - - os.Unsetenv("DEFAULT_CONTENT_SERVER") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Setenv("ACE_CONTENT_SERVER_NAME", contentServerName) - os.Setenv("ACE_CONTENT_SERVER_TOKEN", barAuth) - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return osMkdirError - } - - errorReturned := getConfigurationFromContentServer() - - assert.Equal(t, errorReturned, osMkdirError) - }) - - - t.Run("Creates barfile.bar when ACE_CONTENT_SERVER_URL is SINGLE url and ACE_CONTENT_SERVER_NAME + ACE_CONTENT_SERVER_TOKEN - backward compatibility for MQ connector", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barAuth = "userid=fsdjfhksdjfhsd" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1" - - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - - os.Unsetenv("DEFAULT_CONTENT_SERVER") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Setenv("ACE_CONTENT_SERVER_NAME", contentServerName) - os.Setenv("ACE_CONTENT_SERVER_TOKEN", barAuth) - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - osCreate = func(file string) (*os.File, error) { - assert.Equal(t, "/home/aceuser/initial-config/bars/barfile.bar", file) - return nil, nil - } - - - osStat = func(file string) (os.FileInfo, error) { - // Should not be called - t.Errorf("Should not check if file exist when only single bar URL") - return nil, nil - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/cacert.pem", cafile) - return []byte(dummyCert), nil - } - - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - assert.Equal(t, barUrl + "?archive=true", url) - assert.Equal(t, contentServerName, serverName) - assert.Equal(t, barAuth, token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - return testReadCloser, nil - } - - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - return 0, nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - - }) - - t.Run("Error when DEFAULT_CONTENT_SERVER is true but no token found", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1" - - os.Setenv("DEFAULT_CONTENT_SERVER", "true") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/cacert.pem", cafile) - return []byte(dummyCert), nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Equal(t, errors.New("No content server token available but a url is defined"), errorReturned) - - }) - - t.Run("No error when DEFAULT_CONTENT_SERVER is false and token found", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1?user=default" - - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - - os.Setenv("DEFAULT_CONTENT_SERVER", "false") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Setenv("CONTENT_SERVER_CA", "/home/aceuser/ssl/mycustom.pem") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - osCreate = func(file string) (*os.File, error) { - assert.Equal(t, "/home/aceuser/initial-config/bars/barfile.bar", file) - return nil, nil - } - - osStat = func(file string) (os.FileInfo, error) { - // Should not be called - t.Errorf("Should not check if file exist when only single bar URL") - return nil, nil - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/mycustom.pem", cafile) - return []byte(dummyCert), nil - } - - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - assert.Equal(t, barUrl, url) - assert.Equal(t, contentServerName, serverName) - assert.Equal(t, "user=default", token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - return testReadCloser, nil - } - - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - return 0, nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - - }) - - - t.Run("No error when DEFAULT_CONTENT_SERVER is false and no token found", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1" - - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - - os.Setenv("DEFAULT_CONTENT_SERVER", "false") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Setenv("CONTENT_SERVER_CA", "/home/aceuser/ssl/mycustom.pem") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - osCreate = func(file string) (*os.File, error) { - assert.Equal(t, "/home/aceuser/initial-config/bars/barfile.bar", file) - return nil, nil - } - - osStat = func(file string) (os.FileInfo, error) { - // Should not be called - t.Errorf("Should not check if file exist when only single bar URL") - return nil, nil - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/mycustom.pem", cafile) - return []byte(dummyCert), nil - } - - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - assert.Equal(t, barUrl, url) - assert.Equal(t, contentServerName, serverName) - assert.Equal(t, "", token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - return testReadCloser, nil - } - - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - return 0, nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - - }) - - - t.Run("Error when DEFAULT_CONTENT_SERVER is false but no CONTENT_SERVER_CA found", func(t *testing.T) { - - var contentServerName = "domsdash-ibm-ace-dashboard-prod" - var barUrl = "https://"+contentServerName+":3443/v1/directories/CustomerDatabaseV1" - - os.Setenv("DEFAULT_CONTENT_SERVER", "false") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Unsetenv("CONTENT_SERVER_CA") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Equal(t, errors.New("CONTENT_SERVER_CA not defined"), errorReturned) - - }) - - t.Run("Creates multiple files when ACE_CONTENT_SERVER_URL is array url and extracts server name and auth from urls - multi bar support", func(t *testing.T) { - - //https://alexdash-ibm-ace-dashboard-prod:3443/v1/directories/CustomerDatabaseV1?userid=fsdjfhksdjfhsd - var barName1 = "CustomerDatabaseV1" - var contentServerName1 = "alexdash-ibm-ace-dashboard-prod" - var barAuth1 = "userid=fsdjfhksdjfhsd" - var barUrl1 = "https://"+contentServerName1+":3443/v1/directories/" + barName1 - - //https://test-acecontentserver-ace-alex.svc:3443/v1/directories/testdir?e31d23f6-e3ba-467d-ab3b-ceb0ab12eead - var barName2 = "testdir" - var contentServerName2 = "test-acecontentserver-ace-alex.svc" - var barAuth2 = "e31d23f6-e3ba-467d-ab3b-ceb0ab12eead" - var barUrl2 = "https://"+contentServerName2+":3443/v1/directories/" + barName2 - - var barUrl = barUrl1 + "?" + barAuth1 + "," + barUrl2 + "?" + barAuth2 - - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - - os.Unsetenv("DEFAULT_CONTENT_SERVER") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - osMkdir = func(dirPath string, mode os.FileMode) (error) { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - osCreateCall := 1 - osCreate = func(file string) (*os.File, error) { - if osCreateCall == 1 { - assert.Equal(t, "/home/aceuser/initial-config/bars/" + barName1 + ".bar", file) - } else if osCreateCall == 2 { - assert.Equal(t, "/home/aceuser/initial-config/bars/" + barName2 + ".bar", file) - } - osCreateCall = osCreateCall + 1 - return nil, nil - } - - osStat = func(file string) (os.FileInfo, error) { - return nil, os.ErrNotExist - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/cacert.pem", cafile) - return []byte(dummyCert), nil - } - - getBarCall := 1 - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - if getBarCall == 1 { - assert.Equal(t, barUrl1 + "?archive=true", url) - assert.Equal(t, contentServerName1, serverName) - assert.Equal(t, barAuth1, token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - } else if getBarCall == 2 { - assert.Equal(t, barUrl2 + "?archive=true", url) - assert.Equal(t, contentServerName2, serverName) - assert.Equal(t, barAuth2, token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - } - getBarCall = getBarCall + 1 - return testReadCloser, nil - } - - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - return 0, nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - }) - - t.Run("Creates multiple files with different names when using multi bar support and the bar file names are all the same", func(t *testing.T) { - - //https://alexdash-ibm-ace-dashboard-prod:3443/v1/directories/CustomerDatabaseV1?userid=fsdjfhksdjfhsd - var barName = "CustomerDatabaseV1" - var contentServerName = "alexdash-ibm-ace-dashboard-prod" - var barAuth = "userid=fsdjfhksdjfhsd" - var barUrlBase = "https://" + contentServerName + ":3443/v1/directories/" + barName - var barUrlFull = barUrlBase + "?" + barAuth - - var barUrl = barUrlFull + "," + barUrlFull + "," + barUrlFull - - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - - os.Unsetenv("DEFAULT_CONTENT_SERVER") - os.Setenv("ACE_CONTENT_SERVER_URL", barUrl) - os.Unsetenv("ACE_CONTENT_SERVER_NAME") - os.Unsetenv("ACE_CONTENT_SERVER_TOKEN") - os.Setenv("CONTENT_SERVER_CERT", "cacert") - os.Setenv("CONTENT_SERVER_KEY", "cakey") - - osMkdir = func(dirPath string, mode os.FileMode) error { - assert.Equal(t, barDirPath, dirPath) - assert.Equal(t, os.ModePerm, mode) - return nil - } - - createdFiles := map[string]bool{} - osCreateCall := 1 - osCreate = func(file string) (*os.File, error) { - createdFiles[file] = true - if osCreateCall == 1 { - assert.Equal(t, "/home/aceuser/initial-config/bars/"+barName+".bar", file) - } else if osCreateCall == 2 { - assert.Equal(t, "/home/aceuser/initial-config/bars/"+barName+"-1.bar", file) - } else if osCreateCall == 3 { - assert.Equal(t, "/home/aceuser/initial-config/bars/"+barName+"-2.bar", file) - } - osCreateCall = osCreateCall + 1 - return nil, nil - } - - osStat = func(file string) (os.FileInfo, error) { - if createdFiles[file] { - return nil, os.ErrExist - } else { - return nil, os.ErrNotExist - } - } - - ioutilReadFile = func(cafile string) ([]byte, error) { - assert.Equal(t, "/home/aceuser/ssl/cacert.pem", cafile) - return []byte(dummyCert), nil - } - - getBarCall := 1 - contentserverGetBAR = func(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - assert.Equal(t, barUrlBase+"?archive=true", url) - assert.Equal(t, contentServerName, serverName) - assert.Equal(t, barAuth, token) - assert.Equal(t, []byte(dummyCert), contentServerCACert) - assert.Equal(t, "cacert", contentServerCert) - assert.Equal(t, "cakey", contentServerKey) - getBarCall = getBarCall + 1 - return testReadCloser, nil - } - - ioCopy = func(target io.Writer, source io.Reader) (int64, error) { - return 0, nil - } - - errorReturned := getConfigurationFromContentServer() - - assert.Nil(t, errorReturned) - }) -} - -func TestWatchForceFlowsHTTPSSecret(t *testing.T) { - - patchHTTPSConnectorCalled := 0 - oldpatchHTTPSConnector := patchHTTPSConnector - defer func() { patchHTTPSConnector = oldpatchHTTPSConnector }() - patchHTTPSConnector = func(string) { - patchHTTPSConnectorCalled++ - } - - oldgenerateHTTPSKeystore := generateHTTPSKeystore - defer func() { generateHTTPSKeystore = oldgenerateHTTPSKeystore }() - generateHTTPSKeystore = func(string, string, string, string) { - } - - // Tidy up any /tmp files - files, err := filepath.Glob("/tmp/forceflowtest*") - if err != nil { - log.Errorf("Error finding tmp files: %v", err) - } - for _, f := range files { - if err := os.Remove(f); err != nil { - log.Errorf("Error removing tmp files: %v", err) - } - } - - // Create new test file - extension := generatePassword(5) - f, err := os.Create("/tmp/forceflowtest"+ extension) - helloFile := []byte{115, 111, 109, 101, 10} // hello - _, err = f.Write(helloFile) - - // Now create the watcher and watch the file created above - watcher := watchForceFlowsHTTPSSecret("TESTPASS") - err = watcher.Add("/tmp/forceflowtest"+ extension) - if err != nil { - log.Errorf("Error watching /home/aceuser/httpsNodeCerts for Force Flows to be HTTPS: %v", err) - } - - // Now write to the file to check we are called 2 times - // waits are required as if you update too quickly you only get called once - _, err = f.Write(helloFile) - time.Sleep(2* time.Second) - _, err = f.Write(helloFile) - time.Sleep(2* time.Second) - - // clean up watcher and temporary file - os.Remove("/tmp/forceflowtest"+ extension) - watcher.Close() - - // expected patchHTTPSConnector to be called twice - assert.Equal(t, patchHTTPSConnectorCalled, 2) - - log.Println("done") -} - -func TestUDSCall(t *testing.T) { - // curl --unix-socket /tmp/47EBPflowtest.uds http:/apiv2/resource-managers/https-connector/refresh-tls-config - - // Tidy up any /tmp files - files, err := filepath.Glob("/tmp/*flowtest.uds") - if err != nil { - log.Errorf("Error finding tmp files: %v", err) - } - for _, f := range files { - if err := os.Remove(f); err != nil { - log.Errorf("Error removing tmp files: %v", err) - } - } - - extension := generatePassword(5) - uds := "/tmp/"+extension+"flowtest.uds" - - timesServerCalled := 0 - - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - if (r.Method == "POST") && (r.RequestURI== "/apiv2/resource-managers/https-connector/refresh-tls-config") { - timesServerCalled++ - } else { - log.Print("Error: TestUDSCall called with the following but expected POST and /apiv2/resource-managers/https-connector/refresh-tls-config") - log.Printf(r.Method) - log.Printf(r.RequestURI) - assert.Equal(t, r.Method, "POST") - assert.Equal(t, r.RequestURI, "/apiv2/resource-managers/https-connector/refresh-tls-config") - } - }) - - unixListener, err := net.Listen("unix", uds) - if err != nil { - log.Errorf("Error creating UDS listener: %v", err) - } - handler := http.DefaultServeMux - // Kick off server in the background - go func() { - err = http.Serve(unixListener, handler) - if err != nil { - log.Errorf("Error starting up http UDS server: %v", err) - } - }() - - // test we can call the server above twice - localPatchHTTPSConnector(uds) - assert.Equal(t, timesServerCalled, 1) - localPatchHTTPSConnector(uds) - assert.Equal(t, timesServerCalled, 2) - - // tidy up uds file - os.Remove(uds) -} - - - -func TestGenerateHTTPSKeystore(t *testing.T) { - password := "anypassword" - - testPrivateKey := `-----BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEA63UlVOEWkHJFLPI/PAHZqZYyl4/nE+pDFXKXYuUjRRjXP9rY -AEK3zn8B5ysPwTrBq/RI7jCKTyiH+QriIFvIOjuerQ+FYNk98FwQw4NbMeghziii -+9E0qtd8VQ3QS/SdC2F5Fot0qVIzoGUk2jH6/IvpvT6UGVdd14pJRkOpGFLrojcI -8M6d9N8RkMWTIvmxbhw5HplsaMV3vZhDV4x8gKg/bPSd3dd8inzgenEnjS6a2wCb -auZyINUCOKAoLpzskzCwpNs1iEaD+5ZTqsEbDDLEU100Frm4x21kIGOmANe/YqrS -g5P2Uh/jLFobeYVZnfEC7cpksbS94APTA5+4TDNj7pvw0gcQGTZti//wO1bikKFf -ZKrqMRvmFbqqegoK0lQjMXFOfSucI6cocEB2nIcZNOYr5W17GEGdrH0lmAv/1L9r -DBy5aaNcNfqU7IHEDeoqt7cccqXfZV6pVeQCx+/eBKE1D+HmJ4MsHd1C6XvAJrBK -tiwCe5PjOs5iiZ4skSftjVTr8QV+8unr/sOJ2UQba7a6OM4gW4MgEeBZv3Tb/2aS -/RDZgfMI0kPTSsaRvdJzZtYf/XAVH64G60CbGeGxfo+MqREUSsyIdO6BOcoARYSh -2E1jKHlikXcRrkVqW/lurYulx3pVf1iyA9HQbpXR81VKSBlGhQYnCk62J0sCAwEA -AQKCAgEA4GGUn9yY2jJrRbfdFtxUhs4BjHmwJkRahXfcWHwwLkrL5agxq53o97oF -IDzjGKtboPh8/6/2PhVL7sK2V0vf9c6XGijuXCrqYcH6n7bwExE6FfKXzw3A+QW9 -EHjHhXqopg3PjPJ8zFbvp+x7QAvdOQpERvn5vGSLozm/NlyIKgvrTXzQ4lqkIJTr -cmE2JGB6+4mdzVE8BGQaBe2yTx4sD5dGShia0KvnnTn/2e83V82P+SAM+8R8Alm7 -cib9493bfTErRQ85ZpJ8eCb7uH+pvOgsO51YZEe8lR/kCRGtQqRXWDmdv5IjbIPC -w6NjB11S17azqdP0PX0WbQJ39r4gq3le2FtRCMS16hJNQzJptbUiv/T5awNq/7mU -NBXgDGiBu3BlOy3Il9+QWF0E/6v9sTBcuvGTCIWCXFaBJ3US8bqGFayBQhF9kVBD -/5Xwv5d4YpT2iRQ+fWeyFtQLvXCUka+pYpeOdMYP5LmdhWZxd7qDHdxjcz1GRuim -fK8ls5fM+54SQ4vzNd6scTwlv+LzIgsfAT+j+Aycf3eWkdpyz8B46Tfnc/jHOyeJ -o0dJlGbuiVGoTk5RTeRCpnOr9lYZZ1gkjCfc7WNCT/ls5EJvSq94sFf5fO9EKl86 -fM2nLS5AYETZkP42wGNQUnre+stlunNSOJ+NIzt/64gFMqokSpECggEBAPg60nUT -cfiZ4tcyf/t7ADwsP4Qo2BK8iIcg82ZAt5CV1ISKrpO1fy9SdBYqafejDQBtKELD -wLb7WjjylspgvQh9Z5ulBRQhuvr8V3AC2aKaJj8Oq8qRwqxbPvl9HeJQQE17fEy7 -clu+LMVQuq7UdD1yZJEeueF7U7auGL+VKcBoh0PaQJtgEvHxUYkx6NhR5G1llve3 -Q8ig8ZoAoEHD6zfLawo9VVhpCrC5c3fGc6A8g6CqW1LULgfd/3eDdUTLQAkjqRpx -3TOmY80Ij9mEvBIlQHPR13diFA2MfipEtLb835eq8dwBS3IGQO0ouDZJ282SD/um -RdiUOFJS70Zrid8CggEBAPLT+Xk1UsjwjGa59F4PCKAmUnWwVtg+9br/boOEuuOU -eNzl/hgkBiRTfa8XAmLoLpvSxYLLjWhib1qRmOP4z7X3DP2kAvCOr4s1bb6q8LWq -U7JRuiU5hz7/In4NKq76q+KUTUBHbPTu95RGii34BTFW1PzKxlY+s2QNIR3V+riR -pdAt4zLmFFLAJ72+9puP8zTNki8EK/RBR850WE7XG/Mdo+i07uct+M0bkmAUGuu4 -qQXcnz0nxVEtOD10n1WSwNgBVa5jWh3RYWM3iDeoWZ5+TxlyG4JfHvMy2jdtsaEQ -Sdo19P3DO5yuzySsuoZ+3irDOIdWZRG3jvvafTLHKBUCggEAT5AbEOeQqkw4xx0q -pGKCascL/MJSr366jAVlvqqTq8Y6fdktp66O+44EI26o1HTwn+hc9TllNcFO493t -syRasrPvV5YHELLXCceEByUCuPmLtL5xFdaufSwp/TG7OGTcl3kzGC0ktH86Pmxn -yc3TDDb0QQeGMN2ksXMP/6hB36ghYwA7oRGkQORGbCERLvTgsKfVQcT99vqPNftp -Ymr3o8SRpJCQIGxavtZSSlvTh9Kdpgu0hdH4hxEC5z29grVa6xMBCrbgXcPBTWCn -KuM+nNpP1E+4Lk3De6xCbC3ldpmK2UQzjX7kvcF/YgShNtVpnHRqpxBeZtLrUoe+ -peWmJQKCAQAw9PW+LzcCliTobSNMd2F40GEdozDPJlpqmicQ0wjO61c2yhPhkBnA -5yhWzZ/IiyEif2scxKc83WOv8dzOUZKnECkJVjDViR7xRRNcNqCTL8TyFbIe4StY -Ux4EJeluH9HZu6abiAr6ktdNiK9BN1jsqqIEWWmFZ9zJFjCQEF0dKxgwEaBV2bdN -O7qHceHMWUhiY/POENw/wY2VnTVUp9/VsyshtqDX8RfRWna3cjY/QhqpuOJN9R++ -DwzgrwuUuCKzKgm5QASiMF2fIEoRVprC7ppJ+gx7y2u1ApKmTDJc06jgGrLLGrqB -C2lt7nkotplaK8PQ3WVBHi3wrwtA2pBFAoIBAG1eAtGcHS2PaEnCurdY9jbz0z2m -AcD6jSMj5v0RTU2bFuyHVw1uI2se4J72JNhbvcWgAZpVhIzuw75j+jfc9aE3FY0k -5B61rxKyUNy5nTV6tCBvAdpael2IQJ8tTk4qXbur85LbKHVp1X7eVeJ7y6pGZp1b -lVNHe5WYCCqoajAuJ/doeUEMqi4RrHmWG5jf4qQlGIjvpvEKGJtO0YNakhnYT3AZ -aMIMn2ap5I7IASW0pGw43ukSwKvfw9ZydmUkNW1NNtlcKTeUePMIzBoR7bS+OMro -PH65jEx6b8eFNnZ/4xue3jhJeEAoAYdaI7dGmJR/yivbVtiQ4u4w1YHSgqY= ------END RSA PRIVATE KEY----- -` - - testCertificate := `-----BEGIN CERTIFICATE----- -MIIF0DCCA7igAwIBAgIQDqKhyQoLfI24yKy9pB9CajANBgkqhkiG9w0BAQsFADCB -ijELMAkGA1UEBhMCR0IxEjAQBgNVBAgTCUhhbXBzaGlyZTETMBEGA1UEBxMKV2lu -Y2hlc3RlcjEjMCEGA1UEChMaSUJNIFVuaXRlZCBLaW5nZG9tIExpbWl0ZWQxFDAS -BgNVBAsTC0FwcCBDb25uZWN0MRcwFQYDVQQDEw5hcHAtY29ubmVjdC1jYTAeFw0y -MTA3MDgwOTQ3NTZaFw0zMTA3MDgwOTQ3NTZaMIGMMQswCQYDVQQGEwJHQjESMBAG -A1UECBMJSGFtcHNoaXJlMRMwEQYDVQQHEwpXaW5jaGVzdGVyMSMwIQYDVQQKExpJ -Qk0gVW5pdGVkIEtpbmdkb20gTGltaXRlZDEUMBIGA1UECxMLQXBwIENvbm5lY3Qx -GTAXBgNVBAMTEGlzLTAxLXRvb2xraXQtaXMwggIiMA0GCSqGSIb3DQEBAQUAA4IC -DwAwggIKAoICAQDrdSVU4RaQckUs8j88AdmpljKXj+cT6kMVcpdi5SNFGNc/2tgA -QrfOfwHnKw/BOsGr9EjuMIpPKIf5CuIgW8g6O56tD4Vg2T3wXBDDg1sx6CHOKKL7 -0TSq13xVDdBL9J0LYXkWi3SpUjOgZSTaMfr8i+m9PpQZV13XiklGQ6kYUuuiNwjw -zp303xGQxZMi+bFuHDkemWxoxXe9mENXjHyAqD9s9J3d13yKfOB6cSeNLprbAJtq -5nIg1QI4oCgunOyTMLCk2zWIRoP7llOqwRsMMsRTXTQWubjHbWQgY6YA179iqtKD -k/ZSH+MsWht5hVmd8QLtymSxtL3gA9MDn7hMM2Pum/DSBxAZNm2L//A7VuKQoV9k -quoxG+YVuqp6CgrSVCMxcU59K5wjpyhwQHachxk05ivlbXsYQZ2sfSWYC//Uv2sM -HLlpo1w1+pTsgcQN6iq3txxypd9lXqlV5ALH794EoTUP4eYngywd3ULpe8AmsEq2 -LAJ7k+M6zmKJniyRJ+2NVOvxBX7y6ev+w4nZRBtrtro4ziBbgyAR4Fm/dNv/ZpL9 -ENmB8wjSQ9NKxpG90nNm1h/9cBUfrgbrQJsZ4bF+j4ypERRKzIh07oE5ygBFhKHY -TWMoeWKRdxGuRWpb+W6ti6XHelV/WLID0dBuldHzVUpIGUaFBicKTrYnSwIDAQAB -oy4wLDAqBgNVHREEIzAhgg1pcy0wMS10b29sa2l0ghBpcy0wMS10b29sa2l0LWlz -MA0GCSqGSIb3DQEBCwUAA4ICAQCxCR8weIn4IfHEZFUKFFAyijvq0rapWVFHaRoo -M0LPnbllyjX9H4oiDnAlwnlB4gWM06TltlJ5fR+O5Lf2aRPlvxm5mAZHKMSlwenO -DgnWSfXu5OwbnHrBVim+zcf4wmYo89HpH2UsbpVty28UjZ6elJzwkYG1MWWvWiLR -U28vps50UxuG1DQyMRiylnTKIWUdRAZG4k855UIIS9c++iCNY9S9DHAFj1Bl4hG8 -N1Jfsy8IJ+wAm/QPdE1cJO4U9ky7cB32IDynuv4nBr/K3XPXu0qvPVKl9jqGogpX -FspClOHor+7c47vusvA/Cvkrn14+BRgR/HcxrEZp15Tx9Vhr6sYTpXrLbOzTGoty -KI9eRbiXt50l347ZFhvgHBuSYW8YXzZ+pFymbh2LThC6Oum167Sb5IftAH1uQvb0 -WZKoaNc0JcpVkDmHkHhjLDU1G6rI/T9S7Rk/yGweLmQOVccw5y/E92KKeZzeVrNW -/LH1e0LeQkd+8KhaSWqAjxPFBHFuPF1fQVDs4OfzqgwDI40prvRQzAhkFy3TIMHK -Pr6B0s5nfURsB2sT7PUWYijTHvuuuyb5F/OLNIRXhMfGKfTwMHnhTanmZnjqQz47 -Y0UDx8nGWNT0OZrP0h/IFVUNCK7oupx0S0QxiRqmGS/4TfKZR6F/Pv5Vtc9KDxvf -iipaBg== ------END CERTIFICATE----- -` - - // Tidy up any /tmp files - files, err := filepath.Glob("/tmp/*generatekeystore*") - if err != nil { - log.Errorf("Error finding tmp files: %v", err) - } - for _, f := range files { - if err := os.Remove(f); err != nil { - log.Errorf("Error removing tmp files: %v", err) - } - } - - extension := generatePassword(5) - privateKeyFileLocation := "/tmp/"+extension+"generatekeystore.tls.key" - certificateLocation := "/tmp/"+extension+"generatekeystore.tls.cert" - keystoreLocation := "/tmp/"+extension+"generatekeystore.https-keystore.p12" - - keyFile, err := os.Create(privateKeyFileLocation) - if (err != nil) { - log.Error("Could not create " + privateKeyFileLocation) - assert.Nil(t, err) - } - keyFile.WriteString(testPrivateKey) - - certificateFile, err := os.Create(certificateLocation) - if (err != nil) { - log.Error("Could not create " + certificateLocation) - assert.Nil(t, err) - } - certificateFile.WriteString(testCertificate) - - generateHTTPSKeystore(privateKeyFileLocation, certificateLocation, keystoreLocation, password) - - // Check created keystore - fileInfo, err := os.Stat(keystoreLocation) - if (err != nil) { - log.Error("Could not stat " + keystoreLocation) - assert.Nil(t, err) - } - - // Check keystore size - assert.Equal(t, fileInfo.Size(), int64(4239)) - assert.Equal(t, fileInfo.IsDir(), false) - - // clean up - os.Remove(privateKeyFileLocation) - os.Remove(certificateLocation) - os.Remove(keystoreLocation) - -} - - - -var yamlOpenTracingTests = []struct { - in string - out string -}{ - { // User's blank yaml -``, -`UserExits: - activeUserExitList: ACEOpenTracingUserExit - userExitPath: /opt/ACEOpenTracing -`}, - { // Do not alter as values provided -`UserExits: - activeUserExitList: ACEOpenTracingUserExit - userExitPath: /opt/ACEOpenTracing`, -`UserExits: - activeUserExitList: ACEOpenTracingUserExit - userExitPath: /opt/ACEOpenTracing -`}, - { // Check all values -`UserExits: - userExitPath: /opt/ACEOpenTracing`, -`UserExits: - activeUserExitList: ACEOpenTracingUserExit - userExitPath: /opt/ACEOpenTracing -`}, -} - -func TestAddOpenTracingToServerConf(t *testing.T) { - for _, table := range yamlOpenTracingTests { - out, err := addOpenTracingToServerConf([]byte(table.in)) - if err != nil { - t.Error(err) - } - stringOut := string(out) - if stringOut != table.out { - t.Errorf("addOpenTracingToServerConf expected \n%v, got \n%v", table.out, stringOut) - } - } -} \ No newline at end of file diff --git a/cmd/runaceserver/integrationserver_test.go b/cmd/runaceserver/integrationserver_test.go deleted file mode 100644 index 98b4fe5..0000000 --- a/cmd/runaceserver/integrationserver_test.go +++ /dev/null @@ -1,438 +0,0 @@ -package main - -import ( - "errors" - "os" - "os/exec" - "testing" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" -) - -func Test_initialIntegrationServerConfig(t *testing.T) { - oldGetConfigurationFromContentServer := getConfigurationFromContentServer - getConfigurationFromContentServer = func() error { - return nil - } - t.Run("Golden path - When initial-config/webusers dir exists we call into ConfigureWebAdminUsers to process users", func(t *testing.T) { - oldCreateSHAServerConfYaml := createSHAServerConfYaml - createSHAServerConfYaml = func() error { - return nil - } - oldConfigureWebAdminUsers := ConfigureWebAdminUsers - ConfigureWebAdminUsers = func(log logger.LoggerInterface) error { - return nil - } - - homedir = "../../internal/webadmin/testdata" - initialConfigDir = "../../internal/webadmin/testdata/initial-config" - err := initialIntegrationServerConfig() - assert.NoError(t, err) - - createSHAServerConfYaml = oldCreateSHAServerConfYaml - ConfigureWebAdminUsers = oldConfigureWebAdminUsers - - }) - - t.Run("When we fail to properly configure WebAdmin users we fail and return error", func(t *testing.T) { - oldCreateSHAServerConfYaml := createSHAServerConfYaml - createSHAServerConfYaml = func() error { - return nil - } - oldConfigureWebAdminUsers := ConfigureWebAdminUsers - ConfigureWebAdminUsers = func(log logger.LoggerInterface) error { - return errors.New("Error processing WebAdmin users") - } - homedir = "../../internal/webadmin/testdata" - initialConfigDir = "../../internal/webadmin/testdata/initial-config" - err := initialIntegrationServerConfig() - assert.Error(t, err) - assert.Equal(t, "Error processing WebAdmin users", err.Error()) - - createSHAServerConfYaml = oldCreateSHAServerConfYaml - ConfigureWebAdminUsers = oldConfigureWebAdminUsers - }) - - getConfigurationFromContentServer = oldGetConfigurationFromContentServer -} - -func Test_createSHAServerConfYamlLocal(t *testing.T) { - t.Run("Golden path - Empty file gets populated with the right values", func(t *testing.T) { - - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - return []byte{}, nil - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - - err := createSHAServerConfYaml() - assert.NoError(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - }) - t.Run("Golden path 2 - Populated file gets handled and no errors", func(t *testing.T) { - - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - file, err := os.ReadFile("../../internal/webadmin/testdata/initial-config/webusers/server.conf.yaml") - if err != nil { - t.Log(err) - t.Fail() - } - return file, nil - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, nil - } - - err := createSHAServerConfYaml() - assert.NoError(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - yamlMarshal = oldYamlMarshal - - }) - t.Run("Error reading server.conf.yaml file", func(t *testing.T) { - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - return nil, errors.New("Error reading server.conf.yaml") - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - - err := createSHAServerConfYaml() - assert.Error(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return errors.New("Error unmarshalling yaml") - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, nil - } - - err := createSHAServerConfYaml() - assert.Error(t, err) - assert.Equal(t, "Error unmarshalling yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return nil - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, errors.New("Error marshalling yaml") - } - - err := createSHAServerConfYaml() - assert.Error(t, err) - assert.Equal(t, "Error marshalling yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return nil - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, nil - } - oldWriteServerConfFile := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return errors.New("Error writing server.conf.yaml") - } - err := createSHAServerConfYaml() - assert.Error(t, err) - assert.Equal(t, "Error writing server.conf.yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - writeServerConfFile = oldWriteServerConfFile - }) -} - -func Test_deployIntegrationFlowResources(t *testing.T) { - t.Run("deployIntegrationFlowResources returns nil as both commands returned without error", func(t *testing.T) { - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - return "success", 0, nil - } - err := deployIntegrationFlowResources() - assert.NoError(t, err) - }) - - t.Run("deployIntegrationFlowResources error running acecc-bar-gen.js", func(t *testing.T) { - oldpackageBarFile := packageBarFile - defer func() { packageBarFile = oldpackageBarFile }() - packageBarFile = func() error { - err := errors.New("Error running acecc-bar-gen.js") - return err - } - - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - err := errors.New("Error running acecc-bar-gen.js") - return "Error running acecc-bar-gen.js", 1, err - } - - err := deployIntegrationFlowResources() - assert.Error(t, err) - }) - - t.Run("deployIntegrationFlowResources error deploying BAR file - non zero return code", func(t *testing.T) { - oldpackageBarFile := packageBarFile - defer func() { packageBarFile = oldpackageBarFile }() - packageBarFile = func() error { - return nil - } - - olddeployBarFile := deployBarFile - defer func() { deployBarFile = olddeployBarFile }() - deployBarFile = func() error { - err := errors.New("Error deploying BAR file") - return err - } - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - err := errors.New("Error deploying BAR file") - return "Error deploying BAR file", 1, err - } - - err := deployIntegrationFlowResources() - assert.Error(t, err) - }) -} - -func Test_PackageBarFile(t *testing.T) { - t.Run("Success running acecc-bar-gen.js", func(t *testing.T) { - - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - return "Success", 0, nil - } - err := packageBarFile() - assert.NoError(t, err) - - }) - t.Run("Error running acecc-bar-gen.js", func(t *testing.T) { - - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - err := errors.New("Error running acecc-bar-gen.js") - return "Error running acecc-bar-gen.js", 1, err - } - err := packageBarFile() - assert.Error(t, err) - }) -} - -func Test_DeployBarFile(t *testing.T) { - t.Run("Success deploying BAR file", func(t *testing.T) { - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - return "Success", 0, nil - } - err := deployBarFile() - assert.NoError(t, err) - - }) - t.Run("Error deploying BAR file", func(t *testing.T) { - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - err := errors.New("Error running deploying BAR file") - return "Error running deploying BAR file", 1, err - } - err := deployBarFile() - assert.Error(t, err) - }) - -} - -func Test_deployCSAPIFlows(t *testing.T) { - - t.Run("Env var not set", func(t *testing.T) { - called := 0 - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - called++ - return "Success", 0, nil - } - err := deployCSAPIFlows() - assert.NoError(t, err) - assert.Equal(t, 0, called) - }) - - t.Run("Env var not set", func(t *testing.T) { - os.Setenv("CONNECTOR_SERVICE", "true") - - t.Run("Success deploying copyied files", func(t *testing.T) { - var command []string - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - command = cmd.Args - return "Success", 0, nil - } - err := deployCSAPIFlows() - assert.NoError(t, err) - assert.Contains(t, command, "/home/aceuser/deps/CSAPI") - assert.Contains(t, command, "/home/aceuser/ace-server/run/CSAPI") - - }) - t.Run("Error copying files", func(t *testing.T) { - oldcommandRunCmd := commandRunCmd - defer func() { commandRunCmd = oldcommandRunCmd }() - commandRunCmd = func(cmd *exec.Cmd) (string, int, error) { - err := errors.New("Error running deploying BAR file") - return "Error running deploying BAR file", 1, err - } - err := deployCSAPIFlows() - assert.Error(t, err) - }) - os.Unsetenv("CONNECTOR_SERVICE") - }) - -} - - -func Test_forceflowbasicauthServerConfUpdate(t *testing.T) { - t.Run("Golden path - Empty file gets populated with the right values", func(t *testing.T) { - - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - return []byte{}, nil - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - - err := forceflowbasicauthServerConfUpdate() - assert.NoError(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - }) - - t.Run("Existing value in server.conf.yaml", func(t *testing.T) { - - serverconfMap := make(map[interface{}]interface{}) - serverconfMap["forceServerHTTPSecurityProfile"] = "{DefaultPolicies}:SecProfLocal" - serverconfYaml, _ := yaml.Marshal(&serverconfMap) - - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - return serverconfYaml, nil - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - - err := forceflowbasicauthServerConfUpdate() - assert.NoError(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - }) - - t.Run("Error reading server.conf.yaml file", func(t *testing.T) { - oldReadServerConfFile := readServerConfFile - readServerConfFile = func() ([]byte, error) { - return nil, errors.New("Error reading server.conf.yaml") - } - oldWriteServerConfFileLocal := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return nil - } - - err := forceflowbasicauthServerConfUpdate() - assert.Error(t, err) - readServerConfFile = oldReadServerConfFile - writeServerConfFile = oldWriteServerConfFileLocal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return errors.New("Error unmarshalling yaml") - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, nil - } - - err := forceflowbasicauthServerConfUpdate() - assert.Error(t, err) - assert.Equal(t, "Error unmarshalling yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return nil - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, errors.New("Error marshalling yaml") - } - - err := forceflowbasicauthServerConfUpdate() - assert.Error(t, err) - assert.Equal(t, "Error marshalling yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - }) - t.Run("yaml.Marshal fails to execute properly", func(t *testing.T) { - oldYamlUnmarshal := yamlUnmarshal - yamlUnmarshal = func(in []byte, out interface{}) (err error) { - return nil - } - oldYamlMarshal := yamlMarshal - yamlMarshal = func(in interface{}) (out []byte, err error) { - return nil, nil - } - oldWriteServerConfFile := writeServerConfFile - writeServerConfFile = func(content []byte) error { - return errors.New("Error writing server.conf.yaml") - } - err := forceflowbasicauthServerConfUpdate() - assert.Error(t, err) - assert.Equal(t, "Error writing server.conf.yaml", err.Error()) - - yamlUnmarshal = oldYamlUnmarshal - yamlMarshal = oldYamlMarshal - writeServerConfFile = oldWriteServerConfFile - }) -} diff --git a/cmd/runaceserver/license.go b/cmd/runaceserver/license.go deleted file mode 100644 index 0d7eb26..0000000 --- a/cmd/runaceserver/license.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "errors" - "io/ioutil" - "os" - "path/filepath" - "strings" -) - -// resolveLicenseFile returns the file name of the MQ license file, taking into -// account the language set by the LANG environment variable -func resolveLicenseFile() string { - lang, ok := os.LookupEnv("LANG") - if !ok { - return "English.txt" - } - switch { - case strings.HasPrefix(lang, "zh_TW"): - return "Chinese_TW.txt" - case strings.HasPrefix(lang, "zh"): - return "Chinese.txt" - // Differentiate Czech (cs) and Kashubian (csb) - case strings.HasPrefix(lang, "cs") && !strings.HasPrefix(lang, "csb"): - return "Czech.txt" - case strings.HasPrefix(lang, "fr"): - return "French.txt" - case strings.HasPrefix(lang, "de"): - return "German.txt" - case strings.HasPrefix(lang, "el"): - return "Greek.txt" - case strings.HasPrefix(lang, "id"): - return "Indonesian.txt" - case strings.HasPrefix(lang, "it"): - return "Italian.txt" - case strings.HasPrefix(lang, "ja"): - return "Japanese.txt" - // Differentiate Korean (ko) from Konkani (kok) - case strings.HasPrefix(lang, "ko") && !strings.HasPrefix(lang, "kok"): - return "Korean.txt" - case strings.HasPrefix(lang, "lt"): - return "Lithuanian.txt" - case strings.HasPrefix(lang, "pl"): - return "Polish.txt" - case strings.HasPrefix(lang, "pt"): - return "Portugese.txt" - case strings.HasPrefix(lang, "ru"): - return "Russian.txt" - case strings.HasPrefix(lang, "sl"): - return "Slovenian.txt" - case strings.HasPrefix(lang, "es"): - return "Spanish.txt" - case strings.HasPrefix(lang, "tr"): - return "Turkish.txt" - } - return "English.txt" -} - -func checkLicense() (bool, error) { - lic, ok := os.LookupEnv("LICENSE") - switch { - case ok && lic == "accept": - return true, nil - case ok && lic == "view": - file := filepath.Join("/opt/ibm/ace-12/license", resolveLicenseFile()) - buf, err := ioutil.ReadFile(file) - if err != nil { - log.Println(err) - return false, err - } - log.Println(string(buf)) - return false, nil - } - log.Println("Error: Set environment variable LICENSE=accept to indicate acceptance of license terms and conditions.") - log.Println("License agreements and information can be viewed by setting the environment variable LICENSE=view. You can also set the LANG environment variable to view the license in a different language.") - return false, errors.New("Set environment variable LICENSE=accept to indicate acceptance of license terms and conditions") -} diff --git a/cmd/runaceserver/license_internal_test.go b/cmd/runaceserver/license_internal_test.go deleted file mode 100644 index 3495aa8..0000000 --- a/cmd/runaceserver/license_internal_test.go +++ /dev/null @@ -1,282 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "os" - "testing" -) - -var licenseTests = []struct { - in string - out string -}{ - {"en_US.UTF_8", "English.txt"}, - {"en_US.ISO-8859-15", "English.txt"}, - {"es_GB", "Spanish.txt"}, - {"el_ES.UTF_8", "Greek.txt"}, - // Cover a wide variety of valid values - {"af", "English.txt"}, - {"af_ZA", "English.txt"}, - {"ar", "English.txt"}, - {"ar_AE", "English.txt"}, - {"ar_BH", "English.txt"}, - {"ar_DZ", "English.txt"}, - {"ar_EG", "English.txt"}, - {"ar_IQ", "English.txt"}, - {"ar_JO", "English.txt"}, - {"ar_KW", "English.txt"}, - {"ar_LB", "English.txt"}, - {"ar_LY", "English.txt"}, - {"ar_MA", "English.txt"}, - {"ar_OM", "English.txt"}, - {"ar_QA", "English.txt"}, - {"ar_SA", "English.txt"}, - {"ar_SY", "English.txt"}, - {"ar_TN", "English.txt"}, - {"ar_YE", "English.txt"}, - {"az", "English.txt"}, - {"az_AZ", "English.txt"}, - {"az_AZ", "English.txt"}, - {"be", "English.txt"}, - {"be_BY", "English.txt"}, - {"bg", "English.txt"}, - {"bg_BG", "English.txt"}, - {"bs_BA", "English.txt"}, - {"ca", "English.txt"}, - {"ca_ES", "English.txt"}, - {"cs", "Czech.txt"}, - {"cs_CZ", "Czech.txt"}, - {"csb_PL", "English.txt"}, - {"cy", "English.txt"}, - {"cy_GB", "English.txt"}, - {"da", "English.txt"}, - {"da_DK", "English.txt"}, - {"de", "German.txt"}, - {"de_AT", "German.txt"}, - {"de_CH", "German.txt"}, - {"de_DE", "German.txt"}, - {"de_LI", "German.txt"}, - {"de_LU", "German.txt"}, - {"dv", "English.txt"}, - {"dv_MV", "English.txt"}, - {"el", "Greek.txt"}, - {"el_GR", "Greek.txt"}, - {"en", "English.txt"}, - {"en_AU", "English.txt"}, - {"en_BZ", "English.txt"}, - {"en_CA", "English.txt"}, - {"en_CB", "English.txt"}, - {"en_GB", "English.txt"}, - {"en_IE", "English.txt"}, - {"en_JM", "English.txt"}, - {"en_NZ", "English.txt"}, - {"en_PH", "English.txt"}, - {"en_TT", "English.txt"}, - {"en_US", "English.txt"}, - {"en_ZA", "English.txt"}, - {"en_ZW", "English.txt"}, - {"eo", "English.txt"}, - {"es", "Spanish.txt"}, - {"es_AR", "Spanish.txt"}, - {"es_BO", "Spanish.txt"}, - {"es_CL", "Spanish.txt"}, - {"es_CO", "Spanish.txt"}, - {"es_CR", "Spanish.txt"}, - {"es_DO", "Spanish.txt"}, - {"es_EC", "Spanish.txt"}, - {"es_ES", "Spanish.txt"}, - {"es_ES", "Spanish.txt"}, - {"es_GT", "Spanish.txt"}, - {"es_HN", "Spanish.txt"}, - {"es_MX", "Spanish.txt"}, - {"es_NI", "Spanish.txt"}, - {"es_PA", "Spanish.txt"}, - {"es_PE", "Spanish.txt"}, - {"es_PR", "Spanish.txt"}, - {"es_PY", "Spanish.txt"}, - {"es_SV", "Spanish.txt"}, - {"es_UY", "Spanish.txt"}, - {"es_VE", "Spanish.txt"}, - {"et", "English.txt"}, - {"et_EE", "English.txt"}, - {"eu", "English.txt"}, - {"eu_ES", "English.txt"}, - {"fa", "English.txt"}, - {"fa_IR", "English.txt"}, - {"fi", "English.txt"}, - {"fi_FI", "English.txt"}, - {"fo", "English.txt"}, - {"fo_FO", "English.txt"}, - {"fr", "French.txt"}, - {"fr_BE", "French.txt"}, - {"fr_CA", "French.txt"}, - {"fr_CH", "French.txt"}, - {"fr_FR", "French.txt"}, - {"fr_LU", "French.txt"}, - {"fr_MC", "French.txt"}, - {"gl", "English.txt"}, - {"gl_ES", "English.txt"}, - {"gu", "English.txt"}, - {"gu_IN", "English.txt"}, - {"he", "English.txt"}, - {"he_IL", "English.txt"}, - {"hi", "English.txt"}, - {"hi_IN", "English.txt"}, - {"hr", "English.txt"}, - {"hr_BA", "English.txt"}, - {"hr_HR", "English.txt"}, - {"hu", "English.txt"}, - {"hu_HU", "English.txt"}, - {"hy", "English.txt"}, - {"hy_AM", "English.txt"}, - {"id", "Indonesian.txt"}, - {"id_ID", "Indonesian.txt"}, - {"is", "English.txt"}, - {"is_IS", "English.txt"}, - {"it", "Italian.txt"}, - {"it_CH", "Italian.txt"}, - {"it_IT", "Italian.txt"}, - {"ja", "Japanese.txt"}, - {"ja_JP", "Japanese.txt"}, - {"ka", "English.txt"}, - {"ka_GE", "English.txt"}, - {"kk", "English.txt"}, - {"kk_KZ", "English.txt"}, - {"kn", "English.txt"}, - {"kn_IN", "English.txt"}, - {"ko", "Korean.txt"}, - {"ko_KR", "Korean.txt"}, - {"kok", "English.txt"}, - {"kok_IN", "English.txt"}, - {"ky", "English.txt"}, - {"ky_KG", "English.txt"}, - {"lt", "Lithuanian.txt"}, - {"lt_LT", "Lithuanian.txt"}, - {"lv", "English.txt"}, - {"lv_LV", "English.txt"}, - {"mi", "English.txt"}, - {"mi_NZ", "English.txt"}, - {"mk", "English.txt"}, - {"mk_MK", "English.txt"}, - {"mn", "English.txt"}, - {"mn_MN", "English.txt"}, - {"mr", "English.txt"}, - {"mr_IN", "English.txt"}, - {"ms", "English.txt"}, - {"ms_BN", "English.txt"}, - {"ms_MY", "English.txt"}, - {"mt", "English.txt"}, - {"mt_MT", "English.txt"}, - {"nb", "English.txt"}, - {"nb_NO", "English.txt"}, - {"nl", "English.txt"}, - {"nl_BE", "English.txt"}, - {"nl_NL", "English.txt"}, - {"nn_NO", "English.txt"}, - {"ns", "English.txt"}, - {"ns_ZA", "English.txt"}, - {"pa", "English.txt"}, - {"pa_IN", "English.txt"}, - {"pl", "Polish.txt"}, - {"pl_PL", "Polish.txt"}, - {"ps", "English.txt"}, - {"ps_AR", "English.txt"}, - {"pt", "Portugese.txt"}, - {"pt_BR", "Portugese.txt"}, - {"pt_PT", "Portugese.txt"}, - {"qu", "English.txt"}, - {"qu_BO", "English.txt"}, - {"qu_EC", "English.txt"}, - {"qu_PE", "English.txt"}, - {"ro", "English.txt"}, - {"ro_RO", "English.txt"}, - {"ru", "Russian.txt"}, - {"ru_RU", "Russian.txt"}, - {"sa", "English.txt"}, - {"sa_IN", "English.txt"}, - {"se", "English.txt"}, - {"se_FI", "English.txt"}, - {"se_FI", "English.txt"}, - {"se_FI", "English.txt"}, - {"se_NO", "English.txt"}, - {"se_NO", "English.txt"}, - {"se_NO", "English.txt"}, - {"se_SE", "English.txt"}, - {"se_SE", "English.txt"}, - {"se_SE", "English.txt"}, - {"sk", "English.txt"}, - {"sk_SK", "English.txt"}, - {"sl", "Slovenian.txt"}, - {"sl_SI", "Slovenian.txt"}, - {"sq", "English.txt"}, - {"sq_AL", "English.txt"}, - {"sr_BA", "English.txt"}, - {"sr_BA", "English.txt"}, - {"sr_SP", "English.txt"}, - {"sr_SP", "English.txt"}, - {"sv", "English.txt"}, - {"sv_FI", "English.txt"}, - {"sv_SE", "English.txt"}, - {"sw", "English.txt"}, - {"sw_KE", "English.txt"}, - {"syr", "English.txt"}, - {"syr_SY", "English.txt"}, - {"ta", "English.txt"}, - {"ta_IN", "English.txt"}, - {"te", "English.txt"}, - {"te_IN", "English.txt"}, - {"th", "English.txt"}, - {"th_TH", "English.txt"}, - {"tl", "English.txt"}, - {"tl_PH", "English.txt"}, - {"tn", "English.txt"}, - {"tn_ZA", "English.txt"}, - {"tr", "Turkish.txt"}, - {"tr_TR", "Turkish.txt"}, - {"tt", "English.txt"}, - {"tt_RU", "English.txt"}, - {"ts", "English.txt"}, - {"uk", "English.txt"}, - {"uk_UA", "English.txt"}, - {"ur", "English.txt"}, - {"ur_PK", "English.txt"}, - {"uz", "English.txt"}, - {"uz_UZ", "English.txt"}, - {"uz_UZ", "English.txt"}, - {"vi", "English.txt"}, - {"vi_VN", "English.txt"}, - {"xh", "English.txt"}, - {"xh_ZA", "English.txt"}, - {"zh", "Chinese.txt"}, - {"zh_CN", "Chinese.txt"}, - {"zh_HK", "Chinese.txt"}, - {"zh_MO", "Chinese.txt"}, - {"zh_SG", "Chinese.txt"}, - {"zh_TW", "Chinese_TW.txt"}, - {"zu", "English.txt"}, - {"zu_ZA", "English.txt"}, -} - -func TestResolveLicenseFile(t *testing.T) { - for _, table := range licenseTests { - os.Setenv("LANG", table.in) - f := resolveLicenseFile() - if f != table.out { - t.Errorf("resolveLicenseFile() with LANG=%v - expected %v, got %v", table.in, table.out, f) - } - } -} diff --git a/cmd/runaceserver/logging.go b/cmd/runaceserver/logging.go deleted file mode 100644 index 86284a3..0000000 --- a/cmd/runaceserver/logging.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/ot4i/ace-docker/common/logger" -) - -var log logger.LoggerInterface - -func logTerminationf(format string, args ...interface{}) { - logTermination(fmt.Sprintf(format, args...)) -} - -func logTermination(args ...interface{}) { - msg := fmt.Sprint(args...) - // Write the message to the termination log. This is the default place - // that Kubernetes will look for termination information. - log.Debugf("Writing termination message: %v", msg) - err := ioutil.WriteFile("/dev/termination-log", []byte(msg), 0660) - if err != nil { - log.Debug(err) - } - log.Error(msg) -} - -func getLogFormat() string { - return os.Getenv("LOG_FORMAT") -} - -func getLogOutputFormat() string { - switch getLogFormat() { - case "json": - return "ibmjson" - case "basic": - return "idText" - default: - return "ibmjson" - } -} - -func formatSimple(datetime string, message string) string { - return fmt.Sprintf("%v %v\n", datetime, message) -} - -func getDebug() bool { - debug := os.Getenv("DEBUG") - if debug == "true" || debug == "1" { - return true - } - return false -} - -func configureLogger(name string) error { - var err error - f := getLogFormat() - d := getDebug() - switch f { - case "json": - log, err = logger.NewLogger(os.Stderr, d, true, name) - if err != nil { - return err - } - return nil - case "basic": - log, err = logger.NewLogger(os.Stderr, d, false, name) - if err != nil { - return err - } - return nil - default: - log, err = logger.NewLogger(os.Stdout, d, false, name) - if err != nil { - return err - } - return fmt.Errorf("invalid value for LOG_FORMAT: %v", f) - } -} diff --git a/cmd/runaceserver/main.go b/cmd/runaceserver/main.go deleted file mode 100644 index add15c8..0000000 --- a/cmd/runaceserver/main.go +++ /dev/null @@ -1,274 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// runaceserver initializes, creates and starts a queue manager, as PID 1 in a container -package main - -import ( - "errors" - "io/ioutil" - "os" - - "github.com/ot4i/ace-docker/common/designer" - "github.com/ot4i/ace-docker/internal/command" - "github.com/ot4i/ace-docker/internal/configuration" - iscommandsapi "github.com/ot4i/ace-docker/internal/isCommandsApi" - "github.com/ot4i/ace-docker/internal/metrics" - "github.com/ot4i/ace-docker/internal/name" - "github.com/ot4i/ace-docker/internal/trace" -) - -func doMain() error { - var integrationServerProcess command.BackgroundCmd - - name, nameErr := name.GetIntegrationServerName() - err := configureLogger(name) - if err != nil { - logTermination(err) - return err - } - if nameErr != nil { - logTermination(err) - return err - } - - accepted, err := checkLicense() - if err != nil { - logTerminationf("Error checking license acceptance: %v", err) - return err - } - if !accepted { - err = errors.New("License not accepted") - logTermination(err) - return err - } - - performShutdown := func() { - - metrics.StopMetricsGathering() - - // Stop watching the Force Flows Secret if the watcher has been created - if watcher != nil { - log.Print("Stopping watching the Force Flows HTTPS secret") - watcher.Close() - } - - log.Print("Stopping Integration Server") - stopIntegrationServer(integrationServerProcess) - log.Print("Integration Server stopped") - - checkLogs() - - iscommandsapi.StopCommandsAPIServer() - log.Print("Shutdown complete") - } - - restartIntegrationServer := func() error { - err := ioutil.WriteFile("/tmp/integration_server_restart.timestamp", []byte(""), 0755) - - if err != nil { - log.Print("RestartIntegrationServer - Creating restart file failed") - return err - } - - log.Print("RestartIntegrationServer - Stopping integration server") - stopIntegrationServer(integrationServerProcess) - log.Println("RestartIntegrationServer - Starting integration server") - - integrationServerProcess = startIntegrationServer() - err = integrationServerProcess.ReturnError - - if integrationServerProcess.ReturnError == nil { - log.Println("RestartIntegrationServer - Waiting for integration server") - err = waitForIntegrationServer() - } - - if err != nil { - logTermination(err) - performShutdown() - return err - } - - log.Println("RestartIntegrationServer - Integration server is ready") - - return nil - } - - // Start signal handler - signalControl := signalHandler(performShutdown) - - // Print out versioning information - logVersionInfo() - - runOnly := os.Getenv("ACE_RUN_ONLY") - if runOnly == "true" || runOnly == "1" { - log.Println("Run selected so skipping setup") - } else { - log.Println("Checking for valid working directory") - err = createWorkDir() - if err != nil { - logTermination(err) - performShutdown() - return err - } - - workdirShared := os.Getenv("WORKDIR-SHARED") - if workdirShared == "true" || workdirShared == "1" { - log.Println("Add symlink into shared workdir") - err = createWorkDirSymLink() - if err != nil { - logTermination(err) - performShutdown() - return err - } - } - - // Note: this will do nothing if there are no crs set in the environment - err = configuration.SetupConfigurationsFiles(log, "/home/aceuser") - if err != nil { - logTermination(err) - performShutdown() - return err - } - - err = initialIntegrationServerConfig() - if err != nil { - logTermination(err) - performShutdown() - return err - } - - log.Println("Validating flows deployed to the integration server before starting") - licenseToggles, err := designer.GetLicenseTogglesFromEnvironmentVariables() - if err != nil { - logTermination(err) - performShutdown() - return err - } - designer.InitialiseLicenseToggles(licenseToggles) - - err = designer.ValidateFlows(log, "/home/aceuser") - if err != nil { - logTermination(err) - performShutdown() - return err - } - - // Apply any WorkdirOverrides provided - err = applyWorkdirOverrides() - if err != nil { - logTermination(err) - performShutdown() - return err - } - - // Deploy Connector Service API - err = deployCSAPIFlows() - if err != nil { - logTermination(err) - performShutdown() - return err - } - - designerIntegrationFlows := os.Getenv("DESIGNER_INTEGRATION_FLOWS") - if designerIntegrationFlows == "true" { - err = deployIntegrationFlowResources() - if err != nil { - logTermination(err) - performShutdown() - return err - } - } - - forceflowbasicauth := os.Getenv("FORCEFLOWBASICAUTH") - if forceflowbasicauth == "true" || forceflowbasicauth == "1" { - err = forceflowbasicauthServerConfUpdate() - if err != nil { - logTermination(err) - performShutdown() - return err - } - } - - } - - setupOnly := os.Getenv("ACE_SETUP_ONLY") - if setupOnly == "true" || setupOnly == "1" { - log.Println("Setup only enabled so exiting now") - osExit(0) - } - - log.Println("Starting integration server") - integrationServerProcess = startIntegrationServer() - if integrationServerProcess.ReturnError != nil { - logTermination(integrationServerProcess.ReturnError) - return integrationServerProcess.ReturnError - } - - log.Println("Waiting for integration server to be ready") - err = waitForIntegrationServer() - if err != nil { - logTermination(err) - performShutdown() - return err - } - log.Println("Integration server is ready") - - enableMetrics := os.Getenv("ACE_ENABLE_METRICS") - if enableMetrics == "true" || enableMetrics == "1" { - go metrics.GatherMetrics(name, log) - } else { - log.Println("Metrics are disabled") - } - - log.Println("Starting integration server commands API server") - err = iscommandsapi.StartCommandsAPIServer(log, 7980, restartIntegrationServer) - - if err != nil { - log.Println("Failed to start isapi server " + err.Error()) - } else { - log.Println("Integration API started") - } - - log.Println("Tracing: Starting trace API server") - err = trace.StartServer(log, 7981) - if err != nil { - log.Println("Failed to start trace API server, you will not be able to retrieve trace through the ACE dashboard " + err.Error()) - } else { - log.Println("Tracing: Trace API server started") - } - - // Start reaping zombies from now on. - // Start this here, so that we don't reap any sub-processes created - // by this process (e.g. for crtmqm or strmqm) - signalControl <- startReaping - // Reap zombies now, just in case we've already got some - signalControl <- reapNow - // Wait for terminate signal - <-signalControl - - return nil -} - -var osExit = os.Exit - -func main() { - - err := doMain() - if err != nil { - osExit(1) - } -} diff --git a/cmd/runaceserver/main_internal_test.go b/cmd/runaceserver/main_internal_test.go deleted file mode 100644 index f3f6b79..0000000 --- a/cmd/runaceserver/main_internal_test.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -© Copyright IBM Corporation 2017, 2018 - -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. -*/ -package main - -import ( - "flag" - "io/ioutil" - "os" - "path/filepath" - "strconv" - "testing" - - "github.com/ot4i/ace-docker/common/logger" -) - -var test *bool - -func init() { - test = flag.Bool("test", false, "Set to true when running tests for coverage") - log, _ = logger.NewLogger(os.Stdout, true, false, "test") -} - -// Test started when the test binary is started. Only calls main. -func TestSystem(t *testing.T) { - if *test { - var oldExit = osExit - defer func() { - osExit = oldExit - }() - - filename, ok := os.LookupEnv("EXIT_CODE_FILE") - if !ok { - filename = "/var/coverage/exitCode" - } else { - filename = filepath.Join("/var/coverage/", filename) - } - - osExit = func(rc int) { - // Write the exit code to a file instead - log.Printf("Writing exit code %v to file %v", strconv.Itoa(rc), filename) - err := ioutil.WriteFile(filename, []byte(strconv.Itoa(rc)), 0644) - if err != nil { - log.Print(err) - } - } - main() - } -} diff --git a/cmd/runaceserver/signals.go b/cmd/runaceserver/signals.go deleted file mode 100644 index 1383213..0000000 --- a/cmd/runaceserver/signals.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "os" - "os/signal" - "syscall" - - "golang.org/x/sys/unix" -) - -const ( - startReaping = iota - reapNow = iota -) - -func signalHandler(shutdownFunc func()) chan int { - control := make(chan int) - // Use separate channels for the signals, to avoid SIGCHLD signals swamping - // the buffer, and preventing other signals. - stopSignals := make(chan os.Signal, 2) - reapSignals := make(chan os.Signal, 2) - signal.Notify(stopSignals, syscall.SIGTERM, syscall.SIGINT) - go func() { - for { - select { - case sig := <-stopSignals: - log.Printf("Signal received: %v", sig) - signal.Stop(reapSignals) - signal.Stop(stopSignals) - shutdownFunc() - // One final reap - reapZombies() - close(control) - // End the goroutine - return - case <-reapSignals: - log.Debug("Received SIGCHLD signal") - reapZombies() - case job := <-control: - switch { - case job == startReaping: - // Add SIGCHLD to the list of signals we're listening to - log.Debug("Listening for SIGCHLD signals") - signal.Notify(reapSignals, syscall.SIGCHLD) - case job == reapNow: - reapZombies() - } - } - } - }() - return control -} - -// reapZombies reaps any zombie (terminated) processes now. -// This function should be called before exiting. -func reapZombies() { - for { - var ws unix.WaitStatus - pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, nil) - // If err or pid indicate "no child processes" - if pid == 0 || err == unix.ECHILD { - return - } - log.Debugf("Reaped PID %v", pid) - } -} diff --git a/cmd/runaceserver/version.go b/cmd/runaceserver/version.go deleted file mode 100644 index 08d92fd..0000000 --- a/cmd/runaceserver/version.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -package main - -import ( - "errors" - "regexp" - "strings" - "runtime" - - "github.com/ot4i/ace-docker/internal/command" -) - -var ( - // ImageCreated is the date the image was built - ImageCreated = "Not specified" -) - -func logDateStamp() { - log.Printf("Image created: %v", ImageCreated) -} - -func extractVersion(mqsiversion string) (string, error) { - versionRegex := regexp.MustCompile("(?sm).+BIP8996I: Version:\\s+(.*?)\\s?[\\r\\n].*") - version := versionRegex.FindStringSubmatch(mqsiversion) - if len(version) < 2 { - return "", errors.New("Failed to find version") - } - return version[1], nil -} - -func extractLevel(mqsiversion string) (string, error) { - levelRegex := regexp.MustCompile("(?sm).+BIP8998I: Code Level:\\s+(.*?)\\s?[\\r\\n].*") - level := levelRegex.FindStringSubmatch(mqsiversion) - if len(level) < 2 { - return "", errors.New("Failed to find level") - } - return level[1], nil -} - -func extractBuildType(mqsiversion string) (string, error) { - buildTypeRegex := regexp.MustCompile("(?sm).+BIP8999I: Build Type:\\s+(.*?)\\s[\\r\\n].*") - buildType := buildTypeRegex.FindStringSubmatch(mqsiversion) - if len(buildType) < 2 { - return "", errors.New("Failed to find build type") - } - return buildType[1], nil -} - -func logACEVersion() { - out, _, err := command.Run("ace_mqsicommand.sh", "service", "-v") - if err != nil { - log.Printf("Error calling mqsiservice. Output: %v Error: %v", strings.TrimSuffix(string(out), "\n"), err) - } - - version, err := extractVersion(out) - if err != nil { - log.Printf("Error getting ACE version: Output: %v Error: %v", strings.TrimSuffix(string(out), "\n"), err) - } - - level, err := extractLevel(out) - if err != nil { - log.Printf("Error getting ACE level: Output: %v Error: %v", strings.TrimSuffix(string(out), "\n"), err) - } - - buildType, err := extractBuildType(out) - if err != nil { - log.Printf("Error getting ACE build type: Output: %v Error: %v", strings.TrimSuffix(string(out), "\n"), err) - } - - log.Printf("ACE version: %v", version) - log.Printf("ACE level: %v", level) - log.Printf("ACE build type: %v", buildType) -} - -func logGoVersion() { - log.Printf("Go Version: %s", runtime.Version()) - log.Printf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH) -} - - -func logVersionInfo() { - logDateStamp() - logACEVersion() - logGoVersion() -} diff --git a/cmd/runaceserver/version_internal_test.go b/cmd/runaceserver/version_internal_test.go deleted file mode 100644 index d7fdd75..0000000 --- a/cmd/runaceserver/version_internal_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package main - -import ( - "testing" -) - -var versionTests = []struct { - in string - out string -}{ - {"BIPmsgs en_US\n Console CCSID=1208, ICU CCSID=1208\n Default codepage=UTF-8, in ascii=UTF-8\n JAVA console codepage name=UTF-8\n\nBIP8996I: Version: 11001 \nBIP8997I: Product: IBM App Connect Enterprise \nBIP8998I: Code Level: S000-L180810.12854 \nBIP8999I: Build Type: Production, 64 bit, amd64_linux_2 \n\nBIP8974I: Component: DFDL-C, Build ID: 20180710-2330, Version: 1.1.2.0 (1.1.2.0), Platform: linux_x86 64-bit, Type: production \n\nBIP8071I: Successful command completion.", "11001"}, -} - -var levelTests = []struct { - in string - out string -}{ - {"BIPmsgs en_US\n Console CCSID=1208, ICU CCSID=1208\n Default codepage=UTF-8, in ascii=UTF-8\n JAVA console codepage name=UTF-8\n\nBIP8996I: Version: 11001 \nBIP8997I: Product: IBM App Connect Enterprise \nBIP8998I: Code Level: S000-L180810.12854 \nBIP8999I: Build Type: Production, 64 bit, amd64_linux_2 \n\nBIP8974I: Component: DFDL-C, Build ID: 20180710-2330, Version: 1.1.2.0 (1.1.2.0), Platform: linux_x86 64-bit, Type: production \n\nBIP8071I: Successful command completion.", "S000-L180810.12854"}, - {"BIPmsgs en_US\n Console CCSID=1208, ICU CCSID=1208\n Default codepage=UTF-8, in ascii=UTF-8\n JAVA console codepage name=UTF-8\n\nBIP8996I: Version: 11001 \nBIP8997I: Product: IBM App Connect Enterprise \nBIP8998I: Code Level: S000-L180810.12854 Suffix \nBIP8999I: Build Type: Production, 64 bit, amd64_linux_2 \n\nBIP8974I: Component: DFDL-C, Build ID: 20180710-2330, Version: 1.1.2.0 (1.1.2.0), Platform: linux_x86 64-bit, Type: production \n\nBIP8071I: Successful command completion.", "S000-L180810.12854 Suffix"}, -} - -var buildTypeTests = []struct { - in string - out string -}{ - {"BIPmsgs en_US\n Console CCSID=1208, ICU CCSID=1208\n Default codepage=UTF-8, in ascii=UTF-8\n JAVA console codepage name=UTF-8\n\nBIP8996I: Version: 11001 \nBIP8997I: Product: IBM App Connect Enterprise \nBIP8998I: Code Level: S000-L180810.12854 \nBIP8999I: Build Type: Production, 64 bit, amd64_linux_2 \n\nBIP8974I: Component: DFDL-C, Build ID: 20180710-2330, Version: 1.1.2.0 (1.1.2.0), Platform: linux_x86 64-bit, Type: production \n\nBIP8071I: Successful command completion.", "Production, 64 bit, amd64_linux_2"}, -} - -func TestExtractVersion(t *testing.T) { - for _, table := range versionTests { - out, err := extractVersion(table.in) - if err != nil { - t.Errorf("extractVersion(%v) - unexpected error %v", table.in, err) - } - if out != table.out { - t.Errorf("extractVersion(%v) - expected %v, got %v", table.in, table.out, out) - } - } - _, err := extractVersion("xxx") - if err == nil { - t.Error("extractVersion(xxx) - expected an error but didn't get one") - } -} - -func TestExtractLevel(t *testing.T) { - for _, table := range levelTests { - out, err := extractLevel(table.in) - if err != nil { - t.Errorf("extractLevel(%v) - unexpected error %v", table.in, err) - } - if out != table.out { - t.Errorf("extractLevel(%v) - expected %v, got %v", table.in, table.out, out) - } - } - _, err := extractLevel("xxx") - if err == nil { - t.Error("extractLevel(xxx) - expected an error but didn't get one") - } -} - -func TestExtractBuildType(t *testing.T) { - for _, table := range buildTypeTests { - out, err := extractBuildType(table.in) - if err != nil { - t.Errorf("extractBuildType(%v) - unexpected error %v", table.in, err) - } - if out != table.out { - t.Errorf("extractBuildType(%v) - expected %v, got %v", table.in, table.out, out) - } - } - _, err := extractBuildType("xxx") - if err == nil { - t.Error("extractBuildType(xxx) - expected an error but didn't get one") - } -} diff --git a/common/contentserver/bar.go b/common/contentserver/bar.go deleted file mode 100644 index 95ae542..0000000 --- a/common/contentserver/bar.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package contentserver - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "io" - "net/http" - - "github.com/ot4i/ace-docker/common/logger" -) - -var loadX509KeyPair = tls.LoadX509KeyPair -var newRequest = http.NewRequest - -var newHTTPClient = func(rootCAs *x509.CertPool, cert tls.Certificate, serverName string) Client { - return &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - RootCAs: rootCAs, - Certificates: []tls.Certificate{cert}, - ServerName: serverName, - }, - }, - } -} - -func GetBAR(url string, serverName string, token string, contentServerCACert []byte, contentServerCert string, contentServerKey string, log logger.LoggerInterface) (io.ReadCloser, error) { - caCertPool := x509.NewCertPool() - caCertPool.AppendCertsFromPEM(contentServerCACert) - - // If provided read the key pair to create certificate - cert, err := loadX509KeyPair(contentServerCert, contentServerKey) - if err != nil { - if contentServerCert != "" && contentServerKey != "" { - log.Errorf("Error reading Certificates: %s", err) - return nil, errors.New("Error reading Certificates") - } - } else { - log.Printf("Using certs for mutual auth") - } - - client := newHTTPClient(caCertPool, cert, serverName) - - request, err := newRequest("GET", url, nil) - if err != nil { - return nil, err - } - - request.Header.Set("x-ibm-ace-directory-token", token) - response, err := client.Do(request) - if err != nil { - return nil, err - } - - if response.StatusCode != 200 { - log.Printf("Call to retrieve BAR file from content server failed with response code: %v", response.StatusCode) - return nil, errors.New("HTTP status : " + fmt.Sprint(response.StatusCode) + ". Unable to get BAR file from content server.") - } - - return response.Body, nil -} diff --git a/common/contentserver/bar_test.go b/common/contentserver/bar_test.go deleted file mode 100644 index 2cdc629..0000000 --- a/common/contentserver/bar_test.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -package contentserver - -import ( - "bytes" - "crypto/tls" - "crypto/x509" - "errors" - "io" - "io/ioutil" - "net/http" - "os" - "strings" - - "github.com/ot4i/ace-docker/common/logger" - - "testing" - - "github.com/stretchr/testify/assert" -) - -var testLogger, _ = logger.NewLogger(os.Stdout, true, true, "test") - -func TestGetBAR(t *testing.T) { - url := "" - serverName := "" - token := "" - contentServerCACert := []byte{} - - oldNewHTTPClient := newHTTPClient - newHTTPClient = func(*x509.CertPool, tls.Certificate, string) Client { - return &MockClient{Client: &http.Client{Transport: &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - }}} - } - - t.Run("When not able to load the content server cert and key pair, it returns an error", func(t *testing.T) { - oldLoadX509KeyPair := loadX509KeyPair - loadX509KeyPair = func(string, string) (tls.Certificate, error) { - return tls.Certificate{}, errors.New("Fail to load key pair") - } - - t.Run("When the server cert and key are not empty strings, it fails", func(t *testing.T) { - _, err := GetBAR(url, serverName, token, contentServerCACert, "contentServerCert", "contentServerKey", testLogger) - assert.Error(t, err) - }) - - loadX509KeyPair = oldLoadX509KeyPair - }) - - t.Run("When failing to create the http requestv", func(t *testing.T) { - oldNewRequest := newRequest - newRequest = func(string, string, io.Reader) (*http.Request, error) { - return nil, errors.New("Fail to create new request") - } - - _, err := GetBAR(url, serverName, token, contentServerCACert, "", "", testLogger) - assert.Error(t, err) - - newRequest = oldNewRequest - }) - - t.Run("When failing to make the client call, it returns an error", func(t *testing.T) { - setDoResponse(nil, errors.New("Fail to create new request")) - _, err := GetBAR(url, serverName, token, contentServerCACert, "", "", testLogger) - assert.Error(t, err) - resetDoResponse() - }) - - // TODO: should this return an error? - t.Run("When the client call reponds with a non 200, it does return an error", func(t *testing.T) { - setDoResponse(&http.Response{StatusCode: 500}, nil) - _, err := GetBAR(url, serverName, token, contentServerCACert, "", "", testLogger) - assert.Error(t, err) - resetDoResponse() - }) - - t.Run("When the client call reponds with a 200, it returns the body", func(t *testing.T) { - testReadCloser := ioutil.NopCloser(strings.NewReader("test")) - setDoResponse(&http.Response{StatusCode: 200, Body: testReadCloser}, nil) - body, err := GetBAR(url, serverName, token, contentServerCACert, "", "", testLogger) - assert.NoError(t, err) - buf := new(bytes.Buffer) - buf.ReadFrom(body) - assert.Equal(t, "test", buf.String()) - resetDoResponse() - }) - newHTTPClient = oldNewHTTPClient -} diff --git a/common/contentserver/mock_client.go b/common/contentserver/mock_client.go deleted file mode 100644 index 8d513f2..0000000 --- a/common/contentserver/mock_client.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -package contentserver - -import ( - "net/http" -) - -type Client interface { - Do(*http.Request) (*http.Response, error) -} - -type MockClient struct { - Client *http.Client -} - -var response *http.Response = nil -var err error = nil -func (m *MockClient) Do(request *http.Request) (*http.Response, error) { - if response != nil || err != nil{ - return response, err - } - return m.Client.Do(request) -} - -func setDoResponse(mockResponse *http.Response, mockError error) { - response = mockResponse - err = mockError -} - -func resetDoResponse() { - response = nil - err = nil -} \ No newline at end of file diff --git a/common/designer/flow_validation.go b/common/designer/flow_validation.go deleted file mode 100644 index df2f0d4..0000000 --- a/common/designer/flow_validation.go +++ /dev/null @@ -1,250 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -// Package designer contains code for the designer specific logic -package designer - -import ( - "os" - "io" - "io/ioutil" - "strings" - "gopkg.in/yaml.v2" - - "github.com/ot4i/ace-docker/internal/command" - "github.com/ot4i/ace-docker/common/logger" -) - -var runAsUser = command.RunAsUser -var osOpen = os.Open -var osCreate = os.Create -var ioCopy = io.Copy -var rename = os.Rename -var removeAll = os.RemoveAll -var remove = os.Remove -var mkdir = os.Mkdir -var readDir = ioutil.ReadDir - -type flowDocument struct { - Integration integration `yaml:"integration"` -} - -type integration struct { - TriggerInterfaces map[string]flowInterface `yaml:"trigger-interfaces"` - ActionInterfaces map[string]flowInterface `yaml:"action-interfaces"` -} - -type flowInterface struct { - ConnectorType string `yaml:"connector-type"` -} - -// replaceFlow replaces the resources associated with a deployed designer flow -// with the unpacked generic invalid BAR file -var replaceFlow = func (flow string, log logger.LoggerInterface, basedir string) error { - runFolder := basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" - - // Delete the /run/PolicyProject folder - err := removeAll(runFolder + string(os.PathSeparator) + flow + "PolicyProject") - if err != nil { - log.Errorf("Error checking for the flow's policy project folder: %v", err) - return err - } - - // Rename the flow folder _invalid_license - newFlowName := flow + "_invalid_license" - err = rename(runFolder + string(os.PathSeparator) + flow, runFolder + string(os.PathSeparator) + newFlowName) - if err != nil { - log.Errorf("Error renaming the flow's folder: %v", err) - return err - } - flow = newFlowName - - // Delete the /run//gen folder - err = removeAll(runFolder + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen") - if err != nil { - log.Errorf("Error deleting the flow's /gen folder: %v", err) - return err - } - - // Create a new /run//gen folder - err = mkdir(runFolder + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen", 0777) - if err != nil { - log.Errorf("Error creating the flow's new /gen folder: %v", err) - return err - } - - tempFolder := basedir + string(os.PathSeparator) + "temp" - // Copy the contents of /temp/gen into /run//gen - invalidFlowResourcesList, err := readDir(tempFolder + string(os.PathSeparator) + "gen") - if err != nil { - log.Errorf("Error checking for the invalid flow's /gen folder: %v", err) - return err - } - for _, invalidFlowResource := range invalidFlowResourcesList { - err = copy(tempFolder + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + invalidFlowResource.Name(), runFolder + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + invalidFlowResource.Name(), log) - if err != nil { - log.Errorf("Error copying resource %v from the flow's /gen folder: %v", invalidFlowResource.Name(), err) - return err - } - } - - // Remove the .msgflow, .subflow and, restapi.descriptor from /run/ - flowResourcesList, err := readDir(runFolder + string(os.PathSeparator) + flow) - if err != nil { - log.Errorf("Error checking for the flow's folder: %v", err) - return err - } - for _, flowResource := range flowResourcesList { - if strings.Contains(flowResource.Name(), ".msgflow") || strings.Contains(flowResource.Name(), ".subflow") || flowResource.Name() == "restapi.descriptor" { - err = remove(runFolder+ string(os.PathSeparator) + flow + string(os.PathSeparator) + flowResource.Name()) - if err != nil { - log.Errorf("Error deleting resource %v from the flow's folder: %v", flowResource.Name(), err) - return err - } - } - } - - // Replace restapi.descriptor with application.descriptor - err = copy(tempFolder + string(os.PathSeparator) + "application.descriptor", runFolder + string(os.PathSeparator) + flow + string(os.PathSeparator) + "application.descriptor", log) - if err != nil { - log.Errorf("Error copying resource restapi.descriptor to application.descriptor: %v", err) - return err - } - return nil -} - -// cleanupInvalidBarResources deletes the unpacked generic invalid BAR file -// to ensure there's no unknown flows deployed to a user's instnace -func cleanupInvalidBarResources(basedir string) error { - return os.RemoveAll(basedir + string(os.PathSeparator) + "temp") -} - -// getConnectorLicenseToggle computes the license toggle name from the connector -func getConnectorLicenseToggleName(name string) string { - return "connector-" + name -} - -// findDisabledConnectorInFlow returns the first disabled connector it finds -// if it doesn't find a disabled connector, it returns an empty string -var findDisabledConnectorInFlow = func (flowDocument flowDocument, log logger.LoggerInterface) string { - disabledConnectors := make([]string, 0) - - // read the connector-type field under each interface - // and check if the license toggle for that connector is enabled - findDisabledConnector := func(interfaces map[string]flowInterface) { - for _, i := range interfaces { - connector := i.ConnectorType - if connector != "" { - log.Printf("Checking if connector %v is supported under the current license.", connector) - if !isLicenseToggleEnabled(getConnectorLicenseToggleName(connector)) { - disabledConnectors = append(disabledConnectors, connector) - } - } - } - } - - findDisabledConnector(flowDocument.Integration.TriggerInterfaces) - findDisabledConnector(flowDocument.Integration.ActionInterfaces) - - return strings.Join(disabledConnectors[:], ", ") -} - -// IsFlowValid checks if a single flow is valid -var IsFlowValid = func(log logger.LoggerInterface, flow string, flowFile []byte) (bool, error) { - var flowDocument flowDocument - err := yaml.Unmarshal(flowFile, &flowDocument) - if err != nil { - log.Errorf("Error processing running flow in folder %v: %v", flow, err) - return false, err - } - - disabledConnectors := findDisabledConnectorInFlow(flowDocument, log) - if disabledConnectors != "" { - log.Errorf("Flow %v contains one or more connectors that aren't supported under the current license. Please update your license to enable this flow to run. The unsupported connectors are: %v.", flow, disabledConnectors) - } - return disabledConnectors == "", nil -} - -// ValidateFlows checks if the flows in the /run directory are valid -// by making sure all the connectors used by a flow are supported under the license -// if invalid, then it replaces a flow with a generic invalid one, which fails at startup -// if valid, it doesn't do anything -func ValidateFlows(log logger.LoggerInterface, basedir string) error { - // at this point the /run directory should have been created - log.Println("Processing running flows in folder /home/aceuser/ace-server/run") - runFileList, err := ioutil.ReadDir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run") - if err != nil { - log.Errorf("Error checking for the /run folder: %v", err) - return err - } - - for _, file := range runFileList { - // inside the /run directory there are folders corresponding to running toolkit and designer flows - // designer flows will have two folders: /run/ and /run/PolicyProject - // the yaml of the designer flow is the /run/ folder - flow := file.Name() - if file.IsDir() && !strings.Contains(flow, "PolicyProject") && dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "PolicyProject") { - log.Printf("Processing running flow with name %v", flow) - flowFile, err := ioutil.ReadFile(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + flow + ".yaml") - if err != nil { - log.Errorf("Error processing running flow in folder %v: %v", flow, err) - return err - } - - valid, err := IsFlowValid(log, flow, flowFile) - if err != nil { - return err - } - if !valid { - err = replaceFlow(flow, log, basedir) - if err != nil { - log.Errorf("Error replacing running flow in folder %v: %v", flow, err) - return err - } - } - } - } - - return cleanupInvalidBarResources(basedir) -} - -// copy copies from src to dest -var copy = func (src string, dest string, log logger.LoggerInterface) error { - source, err := osOpen(src) - if err != nil { - log.Errorf("Error opening the source file %v: %v", src, err) - return err - } - defer source.Close() - - destination, err := osCreate(dest) - if err != nil { - log.Errorf("Error creating the destination file %v: %v", dest, err) - return err - } - defer destination.Close() - _, err = ioCopy(destination, source) - return err -} - -// dirExist cheks if a directory exists at the given path -var dirExists = func (path string) bool { - _, err := os.Stat(path) - if err == nil { - return true - } - return !os.IsNotExist(err) -} diff --git a/common/designer/flow_validation_test.go b/common/designer/flow_validation_test.go deleted file mode 100644 index 78159ee..0000000 --- a/common/designer/flow_validation_test.go +++ /dev/null @@ -1,679 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -package designer - -import ( - "os" - "errors" - "io" - "io/ioutil" - - "github.com/ot4i/ace-docker/common/logger" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "testing" -) - -var testLogger, _ = logger.NewLogger(os.Stdout, true, true, "test") - -func TestGetConnectorLicenseToggleName(t *testing.T) { - require.Equal(t, "connector-test", getConnectorLicenseToggleName("test")) -} - -func TestFindDisabledConnectorInFlow(t *testing.T) { - oldIsLicenseToggleEnabled := isLicenseToggleEnabled - isLicenseToggleEnabled = func(toggle string) bool { - if toggle == "connector-test" { - return true - } else { - return false - } - } - t.Run("When there are no unsupported connectors", func(t *testing.T) { - testFlowDocument := flowDocument { - integration { - map[string]flowInterface { - "trigger-interface1": { - ConnectorType: "test", - }, - }, - map[string]flowInterface { - "action-interface1": { - ConnectorType: "test", - }, - }, - }, - } - require.Equal(t, "", findDisabledConnectorInFlow(testFlowDocument, testLogger)) - }) - - t.Run("When there are unsupported connectors in the trigger interface", func(t *testing.T) { - testFlowDocument := flowDocument { - integration { - map[string]flowInterface { - "trigger-interface1": { - ConnectorType: "test", - }, - "trigger-interface2": { - ConnectorType: "foo", - }, - }, - map[string]flowInterface { - "action-interface2": { - ConnectorType: "test", - }, - }, - }, - } - disabledConnectors := findDisabledConnectorInFlow(testFlowDocument, testLogger) - require.Equal(t, "foo", disabledConnectors) - }) - - t.Run("When there are unsupported connectors in the action interface", func(t *testing.T) { - testFlowDocument := flowDocument { - integration { - map[string]flowInterface { - "trigger-interface1": { - ConnectorType: "test", - }, - }, - map[string]flowInterface { - "action-interface1": { - ConnectorType: "test", - }, - "action-interface2": { - ConnectorType: "bar", - }, - }, - }, - } - disabledConnectors := findDisabledConnectorInFlow(testFlowDocument, testLogger) - require.Equal(t, "bar", disabledConnectors) - }) - - t.Run("When there are unsupported connectors in both the trigger interface and the action interface", func(t *testing.T) { - testFlowDocument := flowDocument { - integration { - map[string]flowInterface { - "trigger-interface1": { - ConnectorType: "test", - }, - "trigger-interface2": { - ConnectorType: "foo", - }, - }, - map[string]flowInterface { - "action-interface1": { - ConnectorType: "test", - }, - "action-interface2": { - ConnectorType: "bar", - }, - }, - }, - } - disabledConnectors := findDisabledConnectorInFlow(testFlowDocument, testLogger) - require.Equal(t, "foo, bar", disabledConnectors) - }) - - isLicenseToggleEnabled = oldIsLicenseToggleEnabled -} - -func TestCopy(t *testing.T) { - basedir, err := os.Getwd() - require.NoError(t, err) - - src := basedir + string(os.PathSeparator) + "src.txt" - dst := basedir + string(os.PathSeparator) + "dst.txt" - - t.Run("When failing to open the src file", func (t *testing.T) { - oldOsOpen := osOpen - osOpen = func (string) (*os.File, error) { - return nil, errors.New("Test") - } - err = copy(src, dst, testLogger) - require.Error(t, err) - osOpen = oldOsOpen - }) - - t.Run("When succeeding to open the src file", func (t *testing.T) { - file, err := os.Create(src) - assert.NoError(t, err) - _, err = file.WriteString("src string") - assert.NoError(t, err) - - t.Run("When failing to create the dst file", func (t *testing.T) { - oldOsCreate := osCreate - osCreate = func (string) (*os.File, error) { - return nil, errors.New("Test") - } - - err = copy(src, dst, testLogger) - assert.Error(t, err) - osCreate = oldOsCreate - }) - - t.Run("When succeeding to create the dst file", func (t *testing.T) { - t.Run("When the copying fails", func (t *testing.T) { - oldIoCopy := ioCopy - ioCopy = func (io.Writer, io.Reader) (int64, error) { - return 0, errors.New("Test") - } - - err = copy(src, dst, testLogger) - assert.Error(t, err) - ioCopy = oldIoCopy - }) - - t.Run("When the copying succeeds", func (t *testing.T) { - err = copy(src, dst, testLogger) - assert.NoError(t, err) - - contents, err := ioutil.ReadFile(dst) - assert.NoError(t, err) - assert.Equal(t, "src string", string(contents)) - }) - }) - }) - - err = os.Remove(src) - assert.NoError(t, err) - err = os.Remove(dst) - assert.NoError(t, err) -} - -func TestReplaceFlow(t *testing.T) { - basedir, err := os.Getwd() - require.NoError(t, err) - flow := "Test" - - // setup folders - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server", 0777) - assert.NoError(t, err) - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run", 0777) - assert.NoError(t, err) - - t.Run("When deleting the /run/PolicyProject folder fails", func (t *testing.T) { - oldRemoveAll := removeAll - removeAll = func (string) error { - return errors.New("Fail delete /run/PolicyProject") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - removeAll = oldRemoveAll - }) - - t.Run("When deleting the /run/PolicyProject folder does not fail", func (t *testing.T) { - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "PolicyProject", 0777) - assert.NoError(t, err) - - t.Run("When renaming the /run/ folder fails", func (t *testing.T) { - oldRename := rename - rename = func (string, string) error { - return errors.New("Fail rename /run/") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - rename = oldRename - }) - - t.Run("When renaming the /run/ folder succeeds", func (t *testing.T) { - t.Run("When deleting the /run//gen folder fails", func (t *testing.T) { - oldRemoveAll := removeAll - count := 0 - removeAll = func (string) error { - if count == 0 { - return nil - } - count ++; - return errors.New("Fail delete /run//gen") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - removeAll = oldRemoveAll - }) - - t.Run("When deleting the /run//gen folder succeeds", func (t *testing.T) { - var setupFlow = func () { - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow, 0777) - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "test.msgflow") - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "test.subflow") - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "restapi.descriptor") - assert.NoError(t, err) - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen", 0777) - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "valid.msgflow") - assert.NoError(t, err) - } - - var cleanupFlow = func () { - err = os.RemoveAll(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "_invalid_license") - assert.NoError(t, err) - } - - t.Run("When recreating the /run//gen folder fails", func (t *testing.T) { - oldMkdir:= mkdir - mkdir = func (string, os.FileMode) error { - return errors.New("Fail recreate /run//gen") - } - - setupFlow() - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - cleanupFlow() - - mkdir = oldMkdir - }) - - t.Run("When recreating the /run//gen folder succeeds", func (t *testing.T) { - t.Run("When reading the /temp/gen folder fails", func (t *testing.T) { - oldReadDir := readDir - readDir = func(string) ([]os.FileInfo, error) { - return nil, errors.New("Fail read /temp/gen") - } - setupFlow() - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - cleanupFlow() - readDir = oldReadDir - }) - - t.Run("When reading the /temp/gen folder succeeds", func (t *testing.T) { - err = os.Mkdir(basedir + string(os.PathSeparator) + "temp", 0777) - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "temp" + string(os.PathSeparator) + "application.descriptor") - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "temp" + string(os.PathSeparator) + "invalid.flow") - assert.NoError(t, err) - err = os.Mkdir(basedir + string(os.PathSeparator) + "temp" + string(os.PathSeparator) + "gen", 0777) - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "temp" + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "invalid.msgflow") - assert.NoError(t, err) - - oldCopy := copy - t.Run("When copying the files under /temp/gen to /run//gen fails", func(t *testing.T) { - setupFlow() - copy = func (string, string, logger.LoggerInterface) error { - return errors.New("Fail copy /temp/gen to /run//gen") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - cleanupFlow() - copy = oldCopy - }) - - t.Run("When copying the files under /temp/gen to /run//gen succeeds", func(t *testing.T) { - t.Run("When reading the / folder fails", func (t *testing.T) { - oldReadDir := readDir - count := 0 - readDir = func(string) ([]os.FileInfo, error) { - if count == 0 { - return nil, nil - } - count++; - return nil, errors.New("Fail read /") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - readDir = oldReadDir - }) - - t.Run("When reading the / folder succeeds", func (t *testing.T) { - t.Run("When removing .msgflow, .subflow and, restapi.descriptor from /run/ fails", func(t *testing.T) { - oldRemove := remove - remove = func (string) error { - return errors.New("Fail removing .msgflow, .subflow and, restapi.descriptor") - } - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - remove = oldRemove - }) - - t.Run("When removing .msgflow, .subflow and, restapi.descriptor from /run/ succeeds", func(t *testing.T) { - t.Run("When replacing restapi.descriptor with application.descriptor fails", func(t *testing.T) { - copy = func (src string, dst string, logger logger.LoggerInterface) error { - return errors.New("Fail copying .msgflow, .subflow and, restapi.descriptor") - } - setupFlow() - - err := replaceFlow(flow, testLogger, basedir) - require.Error(t, err) - - cleanupFlow() - copy = oldCopy - }) - - t.Run("When replacing restapi.descriptor with application.descriptor succeeds", func(t *testing.T) { - setupFlow() - assert.True(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "valid.msgflow")) - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "invalid.msgflow")) - - assert.True(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "restapi.descriptor")) - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + string(os.PathSeparator) + "application.descriptor")) - - err := replaceFlow(flow, testLogger, basedir) - require.NoError(t, err) - - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "_invalid_license" + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "valid.msgflow")) - assert.True(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "_invalid_license" + string(os.PathSeparator) + "gen" + string(os.PathSeparator) + "invalid.msgflow")) - - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "_invalid_license" + string(os.PathSeparator) + "restapi.descriptor")) - assert.True(t, dirExists(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + flow + "_invalid_license" + string(os.PathSeparator) + "application.descriptor")) - - cleanupFlow() - }) - }) - }) - }) - copy = oldCopy - }) - }) - }) - - // rename = oldRename - }) - - err = os.RemoveAll(basedir + string(os.PathSeparator) + "ace-server") - assert.NoError(t, err) - err = os.RemoveAll(basedir + string(os.PathSeparator) + "temp") - assert.NoError(t, err) - }) -} - -func TestCleanupInvalidBarResources(t *testing.T) { - basedir, err := os.Getwd() - require.NoError(t, err) - - t.Run("When the directory exists", func(t *testing.T) { - // setup folder - err = os.Mkdir(basedir + string(os.PathSeparator) + "temp", 0777) - assert.NoError(t, err) - _, err = os.Create(basedir + string(os.PathSeparator) + "temp" + string(os.PathSeparator) + "test.bar") - assert.NoError(t, err) - - // test function - assert.True(t, dirExists(basedir + string(os.PathSeparator) + "temp" )) - err = cleanupInvalidBarResources(basedir) - assert.NoError(t, err) - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "temp")) - }) - - t.Run("When the directory does not exist", func(t *testing.T) { - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "temp")) - err := cleanupInvalidBarResources(basedir) - assert.NoError(t, err) - assert.False(t, dirExists(basedir + string(os.PathSeparator) + "temp")) - }) -} - -func TestIsFlowValid(t *testing.T) { - t.Run("When failing to parse flow", func (t *testing.T) { - findDisabledConnectorInFlowCalls := 0 - findDisabledConnectorInFlow = func (flowDocument, logger.LoggerInterface) string { - findDisabledConnectorInFlowCalls++; - return "" - } - - _, err := IsFlowValid(testLogger, "Test", []byte("foo")) - assert.Error(t, err) - - assert.Equal(t, 0, findDisabledConnectorInFlowCalls) - }) - - t.Run("When findDisabledConnectorInFlow does not return a connector", func (t *testing.T) { - findDisabledConnectorInFlowCalls := 0 - findDisabledConnectorInFlow = func (flowDocument, logger.LoggerInterface) string { - findDisabledConnectorInFlowCalls++; - return "" - } - - valid, err := IsFlowValid(testLogger, "Test", []byte(flowDocumentYAML)) - assert.NoError(t, err) - assert.True(t, valid) - - assert.Equal(t, 1, findDisabledConnectorInFlowCalls) - }) - - t.Run("When findDisabledConnectorInFlow does return a connector", func (t *testing.T) { - findDisabledConnectorInFlowCalls := 0 - findDisabledConnectorInFlow = func (flowDocument, logger.LoggerInterface) string { - findDisabledConnectorInFlowCalls++; - return "test" - } - - valid, err := IsFlowValid(testLogger, "Test", []byte(flowDocumentYAML)) - assert.NoError(t, err) - assert.False(t, valid) - - assert.Equal(t, 1, findDisabledConnectorInFlowCalls) - }) -} - -func TestValidateFlow(t *testing.T) { - basedir, err := os.Getwd() - require.NoError(t, err) - - t.Run("When the folders are not setup", func (t *testing.T) { - err := ValidateFlows(testLogger, basedir) - require.Error(t, err) - }) - - t.Run("When the folders are setup", func (t *testing.T) { - // setup folders - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server", 0777) - assert.NoError(t, err) - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run", 0777) - assert.NoError(t, err) - // designer flow - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + "Test", 0777) - assert.NoError(t, err) - err = os.Mkdir(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + "TestPolicyProject", 0777) - assert.NoError(t, err) - - file, err := os.Create(basedir + string(os.PathSeparator) + "ace-server" + string(os.PathSeparator) + "run" + string(os.PathSeparator) + "Test" + string(os.PathSeparator) + "Test.yaml") - assert.NoError(t, err) - _, err = file.WriteString(flowDocumentYAML) - assert.NoError(t, err) - file.Close() - - oldIsFlowValid := IsFlowValid - - t.Run("When IsFlowValid returns an error", func (t *testing.T) { - IsFlowValidCalls := 0 - IsFlowValid = func (logger.LoggerInterface, string, []byte) (bool, error) { - IsFlowValidCalls++; - return true, errors.New("IsFlowValid fails") - } - - oldreplaceFlowNumCalls := 0 - oldreplaceFlow := replaceFlow - replaceFlow = func (string, logger.LoggerInterface, string) error { - oldreplaceFlowNumCalls++ - return nil - } - - err := ValidateFlows(testLogger, basedir) - assert.Error(t, err) - - assert.Equal(t, 1, IsFlowValidCalls) - assert.Equal(t, 0, oldreplaceFlowNumCalls) - - replaceFlow = oldreplaceFlow - }) - - t.Run("When IsFlowValid returns true", func (t *testing.T) { - // setup the toolkit flow every time, since it gets deleted at the end of the function - err = os.Mkdir(basedir + string(os.PathSeparator) + "temp", 0777) - assert.NoError(t, err) - - IsFlowValidCalls := 0 - IsFlowValid = func (logger.LoggerInterface, string, []byte) (bool, error) { - IsFlowValidCalls++; - return true, nil - } - - oldreplaceFlowNumCalls := 0 - oldreplaceFlow := replaceFlow - replaceFlow = func (string, logger.LoggerInterface, string) error { - oldreplaceFlowNumCalls++ - return nil - } - - err := ValidateFlows(testLogger, basedir) - assert.NoError(t, err) - - assert.Equal(t, 1, IsFlowValidCalls) - assert.Equal(t, 0, oldreplaceFlowNumCalls) - - replaceFlow = oldreplaceFlow - }) - - t.Run("When IsFlowValid returns false", func (t *testing.T) { - // setup the toolkit flow every time, since it gets deleted at the end of the function - err = os.Mkdir(basedir + string(os.PathSeparator) + "temp", 0777) - assert.NoError(t, err) - - IsFlowValidCalls := 0 - IsFlowValid = func (logger.LoggerInterface, string, []byte) (bool, error) { - IsFlowValidCalls++; - return false, nil - } - - t.Run("When replaceFlow fails", func (t *testing.T) { - IsFlowValidCalls = 0 - oldreplaceFlowNumCalls := 0 - oldreplaceFlow := replaceFlow - replaceFlow = func (string, logger.LoggerInterface, string) error { - oldreplaceFlowNumCalls++ - return errors.New("Test") - } - - err := ValidateFlows(testLogger, basedir) - assert.Error(t, err) - - assert.Equal(t, 1, IsFlowValidCalls) - assert.Equal(t, 1, oldreplaceFlowNumCalls) - replaceFlow = oldreplaceFlow - }) - - t.Run("When replaceFlow does not fail", func (t *testing.T) { - IsFlowValidCalls = 0 - oldreplaceFlowNumCalls := 0 - oldreplaceFlow := replaceFlow - replaceFlow = func (string, logger.LoggerInterface, string) error { - oldreplaceFlowNumCalls++ - return nil - } - - err := ValidateFlows(testLogger, basedir) - assert.NoError(t, err) - - assert.Equal(t, 1, IsFlowValidCalls) - assert.Equal(t, 1, oldreplaceFlowNumCalls) - replaceFlow = oldreplaceFlow - }) - }) - - IsFlowValid = oldIsFlowValid - - // cleanup folders - err = os.RemoveAll(basedir + string(os.PathSeparator) + "ace-server") - assert.NoError(t, err) - }) -} - -var flowDocumentYAML string = `$integration: 'http://ibm.com/appconnect/integration/v2/integrationFile' -integration: - type: api - trigger-interfaces: - trigger-interface-1: - triggers: - retrieveTest: - assembly: - $ref: '#/integration/assemblies/assembly-1' - input-context: - data: test - output-context: - data: test - options: - resources: - - business-object: test - model: - $ref: '#/models/test' - triggers: - retrieve: retrieveTest - type: api-trigger - action-interfaces: - action-interface-1: - type: api-action - business-object: mail - connector-type: gmail - account-name: Account 1 - actions: - CREATE: {} - assemblies: - assembly-1: - assembly: - execute: - - create-action: - name: Gmail Create email - target: - $ref: '#/integration/action-interfaces/action-interface-1' - map: - mappings: - - To: - template: test@gmail.com - $map: 'http://ibm.com/appconnect/map/v1' - input: - - variable: api - $ref: '#/trigger/api/parameters' - - response: - name: response-1 - reply-maps: - - title: test successfully retrieved - status-code: '200' - map: - $map: 'http://ibm.com/appconnect/map/v1' - input: - - variable: api - $ref: '#/trigger/api/parameters' - - variable: GmailCreateemail - $ref: '#/node-output/Gmail Create email/response/payload' - mappings: [] - input: - - variable: api - $ref: '#/trigger/api/parameters' - - variable: GmailCreateemail - $ref: '#/node-output/Gmail Create email/response/payload' - name: Untitled API 1 -models: {}` \ No newline at end of file diff --git a/common/designer/license_toggles.go b/common/designer/license_toggles.go deleted file mode 100644 index 54c6b3f..0000000 --- a/common/designer/license_toggles.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -// Package designer contains code for the designer specific logic -package designer - -import ( - "os" - "encoding/json" -) - -var globalLicenseToggles map[string]bool - -// ConvertAppConnectLicenseToggleEnvironmentVariable converts the string representation of the environment variable -// into a : representation -func ConvertAppConnectLicenseToggleEnvironmentVariable (environmentVariable string, licenseToggles map[string]bool) error { - var licenseTogglesValues map[string]int - if environmentVariable != "" { - err := json.Unmarshal([]byte(environmentVariable), &licenseTogglesValues) - if err != nil { - return err - } - } - - for licenseToggle, value := range licenseTogglesValues { - if value == 1 { - licenseToggles[licenseToggle] = true - } else { - licenseToggles[licenseToggle] = false - } - } - return nil -} -// GetLicenseTogglesFromEnvironmentVariables reads the APP_CONNECT_LICENSE_TOGGLES and APP_CONNECT_LICENSE_TOGGLES_OVERRIDE environment variables -// it sets the license toggles to APP_CONNECT_LICENSE_TOGGLES and overrides the values using APP_CONNECT_LICENSE_TOGGLES_OVERRIDE -func GetLicenseTogglesFromEnvironmentVariables () (map[string]bool, error) { - licenseToggles := map[string]bool{} - - err := ConvertAppConnectLicenseToggleEnvironmentVariable(os.Getenv("APP_CONNECT_LICENSE_TOGGLES"), licenseToggles) - if err != nil { - return nil, err - } - err = ConvertAppConnectLicenseToggleEnvironmentVariable(os.Getenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE"), licenseToggles) - if err != nil { - return nil, err - } - return licenseToggles, nil -} - -// isLicenseToggleEnabled checks if a toggle is enabled -// if not defined, then it's considered enabled -var isLicenseToggleEnabled = func (toggle string) bool { - enabled, ok := globalLicenseToggles[toggle] - return !ok || enabled -} - -// InitialiseLicenseToggles initialises the globalLicenseToggles map -func InitialiseLicenseToggles(licenseToggles map[string]bool) { - globalLicenseToggles = licenseToggles -} \ No newline at end of file diff --git a/common/designer/license_toggles_test.go b/common/designer/license_toggles_test.go deleted file mode 100644 index 2c62b30..0000000 --- a/common/designer/license_toggles_test.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -© Copyright IBM Corporation 2020 - -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. -*/ - -package designer - -import ( - "os" - - "github.com/stretchr/testify/require" - "testing" -) - -func TestConvertAppConnectLicenseToggleEnvironmentVariable(t *testing.T) { - t.Run("When environment variable is empty", func(t *testing.T) { - licenseToggles := map[string]bool{} - err := ConvertAppConnectLicenseToggleEnvironmentVariable("", licenseToggles) - require.NoError(t, err) - require.Equal(t, 0, len(licenseToggles)) - }) - - t.Run("When environment variable is invalid JSON", func(t *testing.T) { - licenseToggles := map[string]bool{} - err := ConvertAppConnectLicenseToggleEnvironmentVariable("{\"foo\":1,\"bar\":}", licenseToggles) - require.Error(t, err) - require.Equal(t, 0, len(licenseToggles)) - }) - - t.Run("When environment variable is valid JSON", func(t *testing.T) { - licenseToggles := map[string]bool{} - err := ConvertAppConnectLicenseToggleEnvironmentVariable("{\"foo\":1,\"bar\":0}", licenseToggles) - require.NoError(t, err) - require.Equal(t, 2, len(licenseToggles)) - require.True(t, licenseToggles["foo"]) - require.False(t, licenseToggles["bar"]) - }) -} - -func TestGetLicenseTogglesFromEnvironmentVariables(t *testing.T) { - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES") - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE") - - t.Run("When only APP_CONNECT_LICENSE_TOGGLES is invalid JSON and fails to convert", func(t *testing.T) { - os.Setenv("APP_CONNECT_LICENSE_TOGGLES", "{\"foo\":1,\"bar\":0") - _, err := GetLicenseTogglesFromEnvironmentVariables() - require.Error(t, err) - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES") - }) - - t.Run("When only APP_CONNECT_LICENSE_TOGGLES_OVERRIDE is invalid JSON and fails to convert", func(t *testing.T) { - os.Setenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE", "{\"foo\":0") - _, err := GetLicenseTogglesFromEnvironmentVariables() - require.Error(t, err) - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE") - }) - - t.Run("When neither APP_CONNECT_LICENSE_TOGGLES and APP_CONNECT_LICENSE_TOGGLES_OVERRIDE are empty", func(t *testing.T) { - os.Setenv("APP_CONNECT_LICENSE_TOGGLES", "{\"foo\":1,\"bar\":0}") - os.Setenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE", "{\"bar\":1}") - licenseToggles, err := GetLicenseTogglesFromEnvironmentVariables() - require.NoError(t, err) - require.True(t, licenseToggles["foo"]) - require.True(t, licenseToggles["bar"]) - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES") - os.Unsetenv("APP_CONNECT_LICENSE_TOGGLES_OVERRIDE") - }) -} - -func TestIsLicenseToggleEnabled (t *testing.T) { - oldGlobalLicenseToggles := globalLicenseToggles - globalLicenseToggles = map[string]bool{ - "foo": true, - "bar": false, - } - - require.True(t, isLicenseToggleEnabled("foo")) - require.False(t, isLicenseToggleEnabled("bar")) - require.True(t, isLicenseToggleEnabled("unknown")) - globalLicenseToggles = oldGlobalLicenseToggles -} - -func TestInitialiseLicenseToggles (t *testing.T) { - licenseToggles := map[string]bool{ - "foo": true, - "bar": false, - } - InitialiseLicenseToggles(licenseToggles) - require.True(t, globalLicenseToggles["foo"]) - require.False(t, globalLicenseToggles["bar"]) -} \ No newline at end of file diff --git a/common/logger/logger.go b/common/logger/logger.go deleted file mode 100644 index abcdbc5..0000000 --- a/common/logger/logger.go +++ /dev/null @@ -1,219 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package logger provides utility functions for logging purposes -package logger - -import ( - "encoding/json" - "fmt" - "io" - "os" - "os/user" - "strconv" - "sync" - "time" - - "github.com/imdario/mergo" -) - -// timestampFormat matches the format used by MQ messages (includes milliseconds) -const timestampFormat string = "2006-01-02T15:04:05.000Z07:00" -const debugLevel string = "DEBUG" -const infoLevel string = "INFO" -const errorLevel string = "ERROR" - -// A Logger is used to log messages to stdout -type Logger struct { - mutex sync.Mutex - writer io.Writer - debug bool - json bool - processName string - pid string - serverName string - host string - user *user.User - jsonElements map[string]interface{} -} - -// Define the interface to keep the internal and external loggers in sync -// Every reference to logger in the code must reference this interface -// Every function used by the logger must be defined in the interface -type LoggerInterface interface { - LogDirect(string) - Debug(...interface{}) - Debugf(string, ...interface{}) - Print(...interface{}) - Println(...interface{}) - Printf(string, ...interface{}) - PrintString(string) - Error(...interface{}) - Errorf(string, ...interface{}) - Fatalf(string, ...interface{}) -} - -// NewLogger creates a new logger -func NewLogger(writer io.Writer, debug bool, json bool, serverName string) (*Logger, error) { - hostname, err := os.Hostname() - if err != nil { - return nil, err - } - user, err := user.Current() - if err != nil { - return nil, err - } - jsonElements, err := getAdditionalJsonElements(json) - if err != nil { - return nil, err - } - - return &Logger{ - mutex: sync.Mutex{}, - writer: writer, - debug: debug, - json: json, - processName: os.Args[0], - pid: strconv.Itoa(os.Getpid()), - serverName: serverName, - host: hostname, - user: user, - jsonElements: jsonElements, - }, nil -} - -func getAdditionalJsonElements(isJson bool) (map[string]interface{}, error) { - if isJson { - jsonElements := os.Getenv("MQSI_LOG_ADDITIONAL_JSON_ELEMENTS") - if jsonElements != "" { - logEntries := make(map[string]interface{}) - unmarshalErr := json.Unmarshal([]byte("{"+jsonElements+"}"), &logEntries) - if unmarshalErr != nil { - return nil, unmarshalErr - } - return logEntries, nil - } - } - - return nil, nil -} - -func (l *Logger) format(entry map[string]interface{}) (string, error) { - if l.json { - if l.jsonElements != nil { - // Merge the value of MQSI_LOG_ADDITIONAL_JSON_ELEMENTS with entry - mergo.Merge(&entry, l.jsonElements) - } - - b, err := json.Marshal(entry) - if err != nil { - return "", err - } - return string(b), err - } - return fmt.Sprintf("%v %v\n", entry["ibm_datetime"], entry["message"]), nil -} - -// log logs a message at the specified level. The message is enriched with -// additional fields. -func (l *Logger) log(level string, msg string) { - t := time.Now() - entry := map[string]interface{}{ - "message": fmt.Sprint(msg), - "ibm_datetime": t.Format(timestampFormat), - "loglevel": level, - "host": l.host, - "ibm_serverName": l.serverName, - "ibm_processName": l.processName, - "ibm_processId": l.pid, - "ibm_userName": l.user.Username, - "type": "ace_containerlog", - "ibm_product": "IBM App Connect Enterprise", - "ibm_recordtype": "log", - "module": "integration_server.container", - } - - s, err := l.format(entry) - l.mutex.Lock() - defer l.mutex.Unlock() - - if err != nil { - // TODO: Fix this - fmt.Println(err) - } - if l.json { - fmt.Fprintln(l.writer, s) - } else { - fmt.Fprint(l.writer, s) - } -} - -// LogDirect logs a message directly to stdout -func (l *Logger) LogDirect(msg string) { - l.mutex.Lock() - defer l.mutex.Unlock() - fmt.Fprint(l.writer, msg) -} - -// Debug logs a line as debug -func (l *Logger) Debug(args ...interface{}) { - if l.debug { - l.log(debugLevel, fmt.Sprint(args...)) - } -} - -// Debugf logs a line as debug using format specifiers -func (l *Logger) Debugf(format string, args ...interface{}) { - if l.debug { - l.log(debugLevel, fmt.Sprintf(format, args...)) - } -} - -// Print logs a message as info -func (l *Logger) Print(args ...interface{}) { - l.log(infoLevel, fmt.Sprint(args...)) -} - -// Println logs a message -func (l *Logger) Println(args ...interface{}) { - l.Print(args...) -} - -// Printf logs a message as info using format specifiers -func (l *Logger) Printf(format string, args ...interface{}) { - l.log(infoLevel, fmt.Sprintf(format, args...)) -} - -// PrintString logs a string as info -func (l *Logger) PrintString(msg string) { - l.log(infoLevel, msg) -} - -// Error logs a message as error -func (l *Logger) Error(args ...interface{}) { - l.log(errorLevel, fmt.Sprint(args...)) -} - -// Errorf logs a message as error using format specifiers -func (l *Logger) Errorf(format string, args ...interface{}) { - l.log(errorLevel, fmt.Sprintf(format, args...)) -} - -// Fatalf logs a message as fatal using format specifiers -// TODO: Remove this -func (l *Logger) Fatalf(format string, args ...interface{}) { - l.log("FATAL", fmt.Sprintf(format, args...)) -} diff --git a/common/logger/logger_test.go b/common/logger/logger_test.go deleted file mode 100644 index 9d5bf2f..0000000 --- a/common/logger/logger_test.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -package logger_test - -import ( - "bytes" - "encoding/json" - "fmt" - "os" - "strings" - "testing" - - "github.com/ot4i/ace-docker/common/logger" -) - -func TestJSONLogger(t *testing.T) { - const logSourceCRN, saveServiceCopy, newParam = "testCRN", false, "123" - os.Setenv("MQSI_LOG_ADDITIONAL_JSON_ELEMENTS", fmt.Sprintf("\"logSourceCRN\":%q, \"saveServiceCopy\":%t, \"newParam\":%q", logSourceCRN, saveServiceCopy, newParam)) - - buf := new(bytes.Buffer) - l, err := logger.NewLogger(buf, true, true, t.Name()) - if err != nil { - t.Fatal(err) - } - s := "Hello world" - l.Print(s) - var e map[string]interface{} - err = json.Unmarshal([]byte(buf.String()), &e) - if err != nil { - t.Error(err) - } - if s != e["message"] { - t.Errorf("Expected JSON to contain message=%v; got %v", s, buf.String()) - } - - if e["logSourceCRN"] != logSourceCRN { - t.Errorf("Expected JSON to contain logSourceCRN=%v; got %v", e["logSourceCRN"], buf.String()) - } - - if e["saveServiceCopy"] != saveServiceCopy { - t.Errorf("Expected JSON to contain saveServiceCopy=%v; got %v", e["saveServiceCopy"], buf.String()) - } - - if e["newParam"] != newParam { - t.Errorf("Expected JSON to contain newParam=%v; got %v", e["newParam"], buf.String()) - } -} - -func TestSimpleLogger(t *testing.T) { - os.Setenv("MQSI_LOG_ADDITIONAL_JSON_ELEMENTS", "\"logSourceCRN\":\"testCRN\"") - - buf := new(bytes.Buffer) - l, err := logger.NewLogger(buf, true, false, t.Name()) - if err != nil { - t.Fatal(err) - } - s := "Hello world" - l.Print(s) - if !strings.Contains(buf.String(), s) { - t.Errorf("Expected log output to contain %v; got %v", s, buf.String()) - } - - if strings.Contains(buf.String(), "logSourceCRN") { - t.Errorf("Expected log output to without %v; got %v", "logSourceCRN", buf.String()) - } -} diff --git a/deps/.gitignore b/deps/.gitignore deleted file mode 100644 index 4498535..0000000 --- a/deps/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.tar.gz -*.tgz -OpenTracing/config/* -OpenTracing/library/* -!OpenTracing/config/README -!OpenTracing/library/README \ No newline at end of file diff --git a/deps/CSAPI/META-INF/bar-refresh.links b/deps/CSAPI/META-INF/bar-refresh.links deleted file mode 100644 index 44e994c..0000000 --- a/deps/CSAPI/META-INF/bar-refresh.links +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/deps/CSAPI/META-INF/broker.xml b/deps/CSAPI/META-INF/broker.xml deleted file mode 100644 index 1526b46..0000000 --- a/deps/CSAPI/META-INF/broker.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/deps/CSAPI/META-INF/manifest.mf b/deps/CSAPI/META-INF/manifest.mf deleted file mode 100644 index 55f313d..0000000 --- a/deps/CSAPI/META-INF/manifest.mf +++ /dev/null @@ -1 +0,0 @@ -srcSelected=false;showSrc=true;esql21VersionSelected=false; \ No newline at end of file diff --git a/deps/CSAPI/META-INF/service.log b/deps/CSAPI/META-INF/service.log deleted file mode 100644 index e6de405..0000000 --- a/deps/CSAPI/META-INF/service.log +++ /dev/null @@ -1,36 +0,0 @@ - -============================================== - -!Wed Mar 23 13:16:28 GMT 2022 -Message flow CSAPI/Proxy.msgflow successfully loaded -Message flow CSAPI/Proxy.msgflow successfully compiled -Message flow CSAPI/Proxy.msgflow successfully added to archive file - -Node Flow Version Reason ----------------------------------------------------------------------------------------------------- -Failure Handler Proxy 5.0 Generate 5.0 compatible ESQL by default. -This compatibility level supports ESQL source code debugging. -Deploying 5.0 compatible ESQL code will cause a syntax error on version 2.1 or previous brokers. -Configure Request Proxy 5.0 Generate 5.0 compatible ESQL by default. -This compatibility level supports ESQL source code debugging. -Deploying 5.0 compatible ESQL code will cause a syntax error on version 2.1 or previous brokers. -Message flow CSAPI/Proxy.msgflow successfully loaded -Message flow CSAPI/Proxy.msgflow successfully compiled -Message flow CSAPI/Proxy.msgflow successfully added to archive file - -Node Flow Version Reason ----------------------------------------------------------------------------------------------------- -Failure Handler Proxy 5.0 Generate 5.0 compatible ESQL by default. -This compatibility level supports ESQL source code debugging. -Deploying 5.0 compatible ESQL code will cause a syntax error on version 2.1 or previous brokers. -Configure Request Proxy 5.0 Generate 5.0 compatible ESQL by default. -This compatibility level supports ESQL source code debugging. -Deploying 5.0 compatible ESQL code will cause a syntax error on version 2.1 or previous brokers. - -Successfully added file CSAPI/application.descriptor to BAR file. - -Successfully added file CSAPI/application.descriptor to BAR file. - -Successfully added file CSAPI/application.descriptor to BAR file. - -Successfully added file CSAPI/application.descriptor to BAR file. diff --git a/deps/CSAPI/META-INF/user.log b/deps/CSAPI/META-INF/user.log deleted file mode 100644 index 1257a13..0000000 --- a/deps/CSAPI/META-INF/user.log +++ /dev/null @@ -1,37 +0,0 @@ - -============================================== - -!Wed Mar 23 13:16:28 GMT 2022 - -Processing file CSAPI/Proxy.msgflow -Successfully added file CSAPI/Proxy.msgflow to archive file -Elapsed time: 0.082 second(s). - -Processing file CSAPI/Proxy.msgflow -Successfully added file CSAPI/Proxy.msgflow to archive file -Elapsed time: 0.082 second(s). - -Processing file CSAPI/Proxy.msgflow -Message flow "Proxy.msgflow" can be deployed as source since it does not include any subflows defined in the MSGFLOW files -or any nodes unsupported by the source deploy. You may select -deployAsSource flag when building the -BAR with MQSICREATEBAR command or do not select "Compile and in-line resources" build option on the BAR editor. - -============================================== - -!Wed Mar 23 13:16:28 GMT 2022 - -Processing file CSAPI/application.descriptor. -Successfully added file CSAPI/application.descriptor to BAR file. -Elapsed time: 0 second(s). - -Successfully added file CSAPI/application.descriptor to BAR file. - -============================================== - -!Wed Mar 23 13:16:28 GMT 2022 - -Processing file CSAPI/application.descriptor. -Successfully added file CSAPI/application.descriptor to BAR file. -Elapsed time: 0 second(s). - -Successfully added file CSAPI/application.descriptor to BAR file. diff --git a/deps/CSAPI/Proxy.cmf b/deps/CSAPI/Proxy.cmf deleted file mode 100644 index 3f91329..0000000 --- a/deps/CSAPI/Proxy.cmf +++ /dev/null @@ -1,75 +0,0 @@ - - -CREATE SCHEMA "" PATH "" - -CREATE COMPUTE MODULE Proxy_Configure_Request - CREATE FUNCTION Main() RETURNS BOOLEAN - BEGIN - - SET OutputRoot = InputRoot; - - /* -LE section when "Set destination list" is checked on the input node: - - (0x01000000:Name):HTTP = ( - (0x01000000:Name):Input = ( - (0x01000000:Name):RequestLine = ( - (0x03000000:NameValue):Method = 'GET' (CHARACTER) - (0x03000000:NameValue):RequestURI = '/csapi/abc/def' (CHARACTER) - (0x03000000:NameValue):HTTPVersion = 'HTTP/1.1' (CHARACTER) - ) - ) - ) -*/ - -- Keep everything after /csapi (include the slash) - IF LENGTH( InputRoot.HTTPInputHeader."X-Query-String" ) > 0 THEN - SET OutputLocalEnvironment.Destination.HTTP.RequestLine.RequestURI = SUBSTRING(InputLocalEnvironment.HTTP.Input.RequestLine.RequestURI FROM 7) || '?' || InputRoot.HTTPInputHeader."X-Query-String"; - ELSE - SET OutputLocalEnvironment.Destination.HTTP.RequestLine.RequestURI = SUBSTRING(InputLocalEnvironment.HTTP.Input.RequestLine.RequestURI FROM 7); - END IF; - SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = InputLocalEnvironment.HTTP.Input.RequestLine.Method; - - RETURN TRUE; - END; - -END MODULE; -CREATE SCHEMA "" PATH "" - -CREATE COMPUTE MODULE Proxy_Failure_Handler - CREATE FUNCTION Main() RETURNS BOOLEAN - BEGIN - SET OutputRoot = InputRoot; - - -- Set response code - SET OutputLocalEnvironment.Destination.HTTP.ReplyStatusCode = 500; - - if InputExceptionList IS NOT NULL THEN - -- Check the BIP message and put out an appropriate error message - DECLARE messageNumber INTEGER; - DECLARE messageText char; - CALL getLastExceptionDetail(InputExceptionList, messageNumber, messageText); - - SET OutputRoot.JSON.Data.BIP.Number = messageNumber; - SET OutputRoot.JSON.Data.BIP.Message = messageText; - END IF; - - -- Just forward on the original message - - - END; -END MODULE;CREATE PROCEDURE getLastExceptionDetail(IN InputTree reference, OUT messageNumber integer, OUT messageText char) -BEGIN - -- Create a reference to the first child of the exception list - declare ptrException reference to InputTree.*[1]; - -- keep looping while the moves to the child of exception list work - WHILE lastmove(ptrException) DO - -- store the current values for the error number and text - IF ptrException.Number is not null THEN - SET messageNumber = ptrException.Number; - SET messageText = ptrException.Text; - END IF; - -- now move to the last child which should be the next exceptionlist - move ptrException lastchild; - END WHILE; -END; - \ No newline at end of file diff --git a/deps/CSAPI/application.descriptor b/deps/CSAPI/application.descriptor deleted file mode 100644 index 166bf9e..0000000 --- a/deps/CSAPI/application.descriptor +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/deps/OpenTracing/config/README b/deps/OpenTracing/config/README deleted file mode 100644 index e9d10f0..0000000 --- a/deps/OpenTracing/config/README +++ /dev/null @@ -1 +0,0 @@ -Any configuration files needed for the Loadable Exit Library (LEL) should be placed in this directory \ No newline at end of file diff --git a/deps/OpenTracing/library/README b/deps/OpenTracing/library/README deleted file mode 100644 index 13f5064..0000000 --- a/deps/OpenTracing/library/README +++ /dev/null @@ -1 +0,0 @@ -The Loadable Exit Library (LEL) file to support tracing should be placed in this directory. \ No newline at end of file diff --git a/deps/package-connectors.json b/deps/package-connectors.json deleted file mode 100644 index e056389..0000000 --- a/deps/package-connectors.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "ace", - "version": "1.0.0", - "description": "ace", - "private": true, - "dependencies": { - "loopback-connector-mongodb": "5.4.0", - "loopback-connector-postgresql": "5.1.0" - } -} \ No newline at end of file diff --git a/experimental/ace-basic/Dockerfile.ubuntu b/experimental/ace-basic/Dockerfile.ubuntu index fad5110..7c0d392 100644 --- a/experimental/ace-basic/Dockerfile.ubuntu +++ b/experimental/ace-basic/Dockerfile.ubuntu @@ -12,7 +12,8 @@ MAINTAINER Trevor Dolby (@tdolby) # # This might require a local directory with the right permissions, or changing the userid further down . . . - +ARG USERNAME +ARG PASSWORD ARG DOWNLOAD_URL=http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/integration/12.0.2.0-ACE-LINUX64-DEVELOPER.tar.gz ARG PRODUCT_LABEL=ace-12.0.2.0 @@ -22,7 +23,8 @@ ENV DEBIAN_FRONTEND noninteractive # Install ACE v12.0.2.0 and accept the license RUN apt-get update && apt-get install -y --no-install-recommends curl && \ mkdir /opt/ibm && echo Downloading package ${DOWNLOAD_URL} && \ - curl ${DOWNLOAD_URL} | tar zx --exclude=tools --directory /opt/ibm && \ + if [ -z $USERNAME ]; then curl ${DOWNLOAD_URL}; else curl -u ${USERNAME}:{PASSWORD} ${DOWNLOAD_URL}; fi | \ + tar zx --exclude=tools --exclude server/bin/TADataCollector.sh --exclude server/transformationAdvisor/ta-plugin-ace.jar --directory /opt/ibm && \ mv /opt/ibm/${PRODUCT_LABEL} /opt/ibm/ace-12 && \ /opt/ibm/ace-12/ace make registry global accept license deferred diff --git a/git.commit b/git.commit deleted file mode 100644 index 087e0e0..0000000 --- a/git.commit +++ /dev/null @@ -1 +0,0 @@ -UPDATEME \ No newline at end of file diff --git a/go.mod b/go.mod deleted file mode 100644 index ec8fd03..0000000 --- a/go.mod +++ /dev/null @@ -1,55 +0,0 @@ -module github.com/ot4i/ace-docker - -go 1.17 - -require ( - github.com/Jeffail/gabs v1.4.0 - github.com/aymerick/raymond v2.0.2+incompatible - github.com/fsnotify/fsnotify v1.5.1 - github.com/ghodss/yaml v1.0.0 - github.com/gorilla/websocket v1.4.2 - github.com/imdario/mergo v0.3.12 - github.com/prometheus/client_golang v1.11.1 - github.com/prometheus/client_model v0.2.0 - github.com/stretchr/testify v1.7.0 - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 - golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 - gopkg.in/yaml.v2 v2.4.0 - k8s.io/apimachinery v0.22.3 - k8s.io/client-go v0.22.3 - software.sslmate.com/src/go-pkcs12 v0.0.0-20210415151418-c5206de65a78 -) - -require ( - cloud.google.com/go v0.97.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v0.4.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.6 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/googleapis/gnostic v0.5.5 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect - golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect - k8s.io/api v0.22.3 // indirect - k8s.io/klog/v2 v2.9.0 // indirect - k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 2d1ae38..0000000 --- a/go.sum +++ /dev/null @@ -1,778 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0 h1:3DXvAyifywvq64LfkKaMOmkWPS1CikIQdMe2lY9vxU8= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= -github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0= -github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= -github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= -github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= -github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s= -github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211020060615-d418f374d309 h1:A0lJIi+hcTR6aajJH4YqKWwohY4aW9RO7oRMcdv+HKI= -golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE= -golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.22.3 h1:wOoES2GoSkUsdped2RB4zYypPqWtvprGoKCENTOOjP4= -k8s.io/api v0.22.3/go.mod h1:azgiXFiXqiWyLCfI62/eYBOu19rj2LKmIhFPP4+33fs= -k8s.io/apimachinery v0.22.3 h1:mrvBG5CZnEfwgpVqWcrRKvdsYECTrhAR6cApAgdsflk= -k8s.io/apimachinery v0.22.3/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= -k8s.io/client-go v0.22.3 h1:6onkOSc+YNdwq5zXE0wFXicq64rrym+mXwHu/CPVGO4= -k8s.io/client-go v0.22.3/go.mod h1:ElDjYf8gvZsKDYexmsmnMQ0DYO8W9RwBjfQ1PI53yow= -k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.9.0 h1:D7HV+n1V57XeZ0m6tdRkfknthUaM06VFbWldOFh8kzM= -k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZxKn3tKo5k/eYcs= -k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -software.sslmate.com/src/go-pkcs12 v0.0.0-20210415151418-c5206de65a78 h1:SqYE5+A2qvRhErbsXFfUEUmpWEKxxRSMgGLkvRAFOV4= -software.sslmate.com/src/go-pkcs12 v0.0.0-20210415151418-c5206de65a78/go.mod h1:B7Wf0Ya4DHF9Yw+qfZuJijQYkWicqDa+79Ytmmq3Kjg= diff --git a/internal/command/command.go b/internal/command/command.go deleted file mode 100644 index 5ad664b..0000000 --- a/internal/command/command.go +++ /dev/null @@ -1,252 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package command contains code to run external commands -package command - -import ( - "bufio" - "errors" - "fmt" - "os/exec" - "os/user" - "runtime" - "strconv" - "strings" - "syscall" - - "github.com/ot4i/ace-docker/common/logger" -) - -// A BackgroundCmd provides a handle to a backgrounded command and its completion state. -type BackgroundCmd struct { - Cmd *exec.Cmd - ReturnCode int - ReturnError error - Started bool - Finished bool - finishChan chan bool -} - -// RunCmd runs an OS command. On Linux it waits for the command to -// complete and returns the exit status (return code). -// Do not use this function to run shell built-ins (like "cd"), because -// the error handling works differently -func RunCmd(cmd *exec.Cmd) (string, int, error) { - // Run the command and wait for completion - out, err := cmd.Output() - if err != nil { - // Assert that this is an ExitError - exiterr, ok := err.(*exec.ExitError) - // If the type assertion was correct, and we're on Linux - if ok && runtime.GOOS == "linux" { - status, ok := exiterr.Sys().(syscall.WaitStatus) - if ok { - return string(out), status.ExitStatus(), fmt.Errorf("%v: %v: %v", cmd.Path, err, string(exiterr.Stderr)) - } - } - return string(out), -1, err - } - return string(out), 0, nil -} - -// Run runs an OS command. On Linux it waits for the command to -// complete and returns the exit status (return code). -// Do not use this function to run shell built-ins (like "cd"), because -// the error handling works differently -func Run(name string, arg ...string) (string, int, error) { - return RunCmd(exec.Command(name, arg...)) -} - -// RunCmdBackground runs an OS command. On Linux it runs the command in -// the background, piping stdout/stderr to log.LogDirect. -// It returns a BackgroundCmd, containing the os/exec/cmd, an int channel -// and error channel that will have the return code and error written respectively, -// when the process exits -func RunCmdBackground(cmd *exec.Cmd, log logger.LoggerInterface) BackgroundCmd { - bgCmd := BackgroundCmd{cmd, 0, nil, false, false, make(chan bool)} - - stdoutChildPipe, err := cmd.StdoutPipe() - if err != nil { - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - return bgCmd - } - stderrChildPipe, err := cmd.StderrPipe() - if err != nil { - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - return bgCmd - } - - // Write both stdout and stderr of the child to our logs - stdoutScanner := bufio.NewScanner(stdoutChildPipe) - stderrScanner := bufio.NewScanner(stderrChildPipe) - - go func() { - for stdoutScanner.Scan() { - log.LogDirect(stdoutScanner.Text() + "\n") - } - }() - go func() { - for stderrScanner.Scan() { - log.LogDirect(stderrScanner.Text() + "\n") - } - }() - - // Start the command in the background - err = cmd.Start() - if err != nil { - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - return bgCmd - } - - bgCmd.Started = true - - // Wait on the command and mark as finished when done - go func() { - err := cmd.Wait() - bgCmd.ReturnCode = 0 - bgCmd.ReturnError = nil - if err != nil { - // Assert that this is an ExitError - exiterr, ok := err.(*exec.ExitError) - // If the type assertion was correct, and we're on Linux - if ok && runtime.GOOS == "linux" { - status, ok := exiterr.Sys().(syscall.WaitStatus) - if ok { - bgCmd.ReturnCode = status.ExitStatus() - bgCmd.ReturnError = fmt.Errorf("%v: %v", cmd.Path, err) - } - } - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - } - bgCmd.Finished = true - bgCmd.finishChan <- true - close(bgCmd.finishChan) - }() - - return bgCmd -} - -// SigIntBackground sends the signal SIGINT to the backgrounded command wrapped by -// the BackgroundCommand struct -func SigIntBackground(bgCmd BackgroundCmd) { - if bgCmd.Started && !bgCmd.Finished { - bgCmd.Cmd.Process.Signal(syscall.SIGINT) // TODO returns an error - } -} - -// WaitOnBackground will wait until the process is marked as finished. -func WaitOnBackground(bgCmd BackgroundCmd) { - if !bgCmd.Finished { - bgCmd.Finished = <-bgCmd.finishChan - } -} - -// RunBackground runs an OS command. On Linux it runs the command in the background -// and returns a channel to int that will have the return code written when -// the process exits -func RunBackground(name string, log logger.LoggerInterface, arg ...string) BackgroundCmd { - return RunCmdBackground(exec.Command(name, arg...), log) -} - -// RunAsUser runs the specified command as the aceuser user. If the current user -// already is the specified user then this calls through to RunCmd. -func RunAsUser(username string, name string, arg ...string) (string, int, error) { - thisUser, err := user.Current() - if err != nil { - return "", 0, err - } - cmd := exec.Command(name, arg...) - if strings.Compare(username, thisUser.Username) != 0 { - cmd.SysProcAttr = &syscall.SysProcAttr{} - uid, gid, groups, err := LookupUser(username) - if err != nil { - return "", 0, err - } - cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uid, Gid: gid, Groups: groups} - } - return RunCmd(cmd) -} - -// RunAsUserBackground runs the specified command as the aceuser user in the background. -// It returns a BackgroundCmd, containing the os/exec/cmd, an int channel -// and error channel that will have the return code and error written respectively, -// when the process exits -func RunAsUserBackground(username string, name string, log logger.LoggerInterface, arg ...string) BackgroundCmd { - cmd := exec.Command(name, arg...) - thisUser, err := user.Current() - if err != nil { - bgCmd := BackgroundCmd{cmd, 0, nil, false, false, make(chan bool)} - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - return bgCmd - } - if strings.Compare(username, thisUser.Username) != 0 { - cmd.SysProcAttr = &syscall.SysProcAttr{} - uid, gid, groups, err := LookupUser(username) - if err != nil { - bgCmd := BackgroundCmd{cmd, 0, nil, false, false, make(chan bool)} - bgCmd.ReturnCode = -1 - bgCmd.ReturnError = err - return bgCmd - } - cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uid, Gid: gid, Groups: groups} - } - return RunCmdBackground(cmd, log) -} - -// LookupAceuser looks up the UID, GID and supplementary groups of the aceuser user. This is only -// allowed if the current user is "root"; otherwise this returns an error. -func LookupUser(username string) (uint32, uint32, []uint32, error) { - thisUser, err := user.Current() - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - if strings.Compare("root", thisUser.Username) != 0 { - return uint32(0), uint32(0), []uint32{}, errors.New("Not permitted: the current user attempted to look up user but is not permitted.") - } - - user, err := user.Lookup(username) - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - userUID, err := strconv.Atoi(user.Uid) - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - userGID, err := strconv.Atoi(user.Gid) - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - userSupplementaryGIDStrings, err := user.GroupIds() - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - var userSupplementaryGIDs []uint32 - for _, idString := range userSupplementaryGIDStrings { - id, err := strconv.Atoi(idString) - if err != nil { - return uint32(0), uint32(0), []uint32{}, err - } - userSupplementaryGIDs = append(userSupplementaryGIDs, uint32(id)) - } - - return uint32(userUID), uint32(userGID), userSupplementaryGIDs, nil -} diff --git a/internal/command/command_test.go b/internal/command/command_test.go deleted file mode 100644 index a4d6464..0000000 --- a/internal/command/command_test.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package command_test - -import ( - "runtime" - "testing" - - "github.com/ot4i/ace-docker/internal/command" -) - -var commandTests = []struct { - name string - arg []string - rc int -}{ - {"ls", []string{}, 0}, - {"ls", []string{"madeup"}, 2}, - {"bash", []string{"-c", "exit 99"}, 99}, -} - -func TestRun(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skip("Skipping tests for package which only works on Linux") - } - for _, table := range commandTests { - arg := table.arg - _, rc, err := command.Run(table.name, arg...) - if rc != table.rc { - t.Errorf("Run(%v,%v) - expected %v, got %v", table.name, table.arg, table.rc, rc) - } - if rc != 0 && err == nil { - t.Errorf("Run(%v,%v) - expected error for non-zero return code (rc=%v)", table.name, table.arg, rc) - } - } -} diff --git a/internal/configuration/configuration.go b/internal/configuration/configuration.go deleted file mode 100644 index 693dfb6..0000000 --- a/internal/configuration/configuration.go +++ /dev/null @@ -1,659 +0,0 @@ -package configuration - -import ( - "archive/zip" - "bytes" - "context" - "crypto/tls" - "crypto/x509" - "encoding/base64" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "path" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/Jeffail/gabs" - - "github.com/ot4i/ace-docker/common/logger" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/kubernetes" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" - "k8s.io/client-go/rest" -) - -const workdirName = "ace-server" -const truststoresName = "truststores" -const keystoresName = "keystores" -const genericName = "generic" -const odbcIniName = "odbc" -const adminsslName = "adminssl" -const aceInstall = "/opt/ibm/ace-12/server/bin" -const initialConfig = "initial-config" -const workdiroverrides = "workdir_overrides" - -var ContentServer = true - -var ( - configurationClassGVR = schema.GroupVersionResource{ - Group: "appconnect.ibm.com", - Version: "v1beta1", - Resource: "configurations", - } - - integrationServerClassGVR = schema.GroupVersionResource{ - Group: "appconnect.ibm.com", - Version: "v1beta1", - Resource: "integrationservers", - } -) - -/** -* START: FUNCTIONS CREATES EXTERNAL REQUESTS - */ - -func getPodNamespace() (string, error) { - if data, err := ioutilReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { - if ns := strings.TrimSpace(string(data)); len(ns) > 0 { - return ns, nil - } - return "default", err - } - return "default", nil -} - -func writeConfigurationFile(dir string, fileName string, contents []byte) error { - makeDirErr := osMkdirAll(dir, 0740) - if makeDirErr != nil { - return makeDirErr - } - return ioutilWriteFile(dir+string(os.PathSeparator)+fileName, contents, 0740) -} - -func unzip(log logger.LoggerInterface, dir string, contents []byte) error { - var filenames []string - zipReader, err := zip.NewReader(bytes.NewReader(contents), int64(len(contents))) - if err != nil { - log.Printf("%s: %#v", "Failed to read zip contents", err) - return err - } - - for _, file := range zipReader.File { - - // Store filename/path for returning and using later on - filePath := filepath.Join(dir, file.Name) - - // Check for ZipSlip. - if !strings.HasPrefix(filePath, filepath.Clean(dir)+string(os.PathSeparator)) { - if err != nil { - log.Printf("%s: %#v", "Illegal file path:"+filePath, err) - return err - } - } - - filenames = append(filenames, filePath) - - if file.FileInfo().IsDir() { - // Make Folder - osMkdirAll(filePath, os.ModePerm) - continue - } - - // Make File - err = osMkdirAll(filepath.Dir(filePath), os.ModePerm) - - if err != nil { - log.Printf("%s: %#v", "Illegal file path:"+filePath, err) - return err - } - - outFile, err := osOpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode()) - - if err != nil { - log.Printf("%s: %#v", "Cannot create file writer"+filePath, err) - return err - } - - fileReader, err := file.Open() - - if err != nil { - log.Printf("%s: %#v", "Cannot open file"+filePath, err) - return err - } - - _, err = ioCopy(outFile, fileReader) - // Close the file without defer to close before next iteration of loop - outFile.Close() - fileReader.Close() - - if err != nil { - log.Printf("%s: %#v", "Cannot write file"+filePath, err) - return err - } - - } - return nil -} - -/** -* END: FUNCTIONS CREATES EXTERNAL REQUESTS - */ - -type configurationObject struct { - name string - configType string - contents []byte -} - -func getAllConfigurationsImpl(log logger.LoggerInterface, namespace string, configurationsNames []string, dynamicClient dynamic.Interface) ([]*unstructured.Unstructured, error) { - - list := make([]*unstructured.Unstructured, len(configurationsNames)) - for index, configurationName := range configurationsNames { - - res := dynamicClient.Resource(configurationClassGVR).Namespace(namespace) - configuration, err := res.Get(context.TODO(), configurationName, metav1.GetOptions{}) - if err != nil { - log.Printf("%s: %#v", "Failed to get configuration: "+configurationName, err) - return nil, err - } - list[index] = configuration - } - return list, nil -} - -var getAllConfigurations = getAllConfigurationsImpl - -func getSecretImpl(basedir string, secretName string) ([]byte, error) { - content, err := ioutil.ReadFile(basedir + string(os.PathSeparator) + "secrets" + string(os.PathSeparator) + secretName + string(os.PathSeparator) + "configuration") - return content, err -} - -var getSecret = getSecretImpl - -func parseConfigurationList(log logger.LoggerInterface, basedir string, list []*unstructured.Unstructured) ([]configurationObject, error) { - output := make([]configurationObject, len(list)) - for index, item := range list { - name := item.GetName() - configType, exists, err := unstructured.NestedString(item.Object, "spec", "type") - - if !exists || err != nil { - log.Printf("%s: %#v", "A configuration must has a type", errors.New("A configuration must has a type")) - return nil, errors.New("A configuration must has a type") - } - switch configType { - case "policyproject", "odbc", "serverconf": - fld, exists, err := unstructured.NestedString(item.Object, "spec", "contents") - if !exists || err != nil { - log.Printf("%s: %#v", "A configuration with type: "+configType+" must has a contents field", errors.New("A configuration with type: "+configType+" must has a contents field")) - return nil, errors.New("A configuration with type: " + configType + " must has a contents field") - } - contents, err := base64.StdEncoding.DecodeString(fld) - if err != nil { - log.Printf("%s: %#v", "Failed to decode contents", err) - return nil, errors.New("Failed to decode contents") - } - output[index] = configurationObject{name: name, configType: configType, contents: contents} - case "truststorecertificate", "truststore", "keystore", "setdbparms", "generic", "adminssl", "agentx", "agenta", "accounts", "loopbackdatasource", "barauth", "workdiroverride", "resiliencekafkacredentials", "persistencerediscredentials": - secretName, exists, err := unstructured.NestedString(item.Object, "spec", "secretName") - if !exists || err != nil { - log.Printf("%s: %#v", "A configuration with type: "+configType+" must have a secretName field", errors.New("A configuration with type: "+configType+" must have a secretName field")) - return nil, errors.New("A configuration with type: " + configType + " must have a secretName field") - } - secretVal, err := getSecret(basedir, secretName) - if err != nil { - log.Printf("%s: %#v", "Failed to get secret", err) - return nil, err - } - output[index] = configurationObject{name: name, configType: configType, contents: secretVal} - } - } - return output, nil -} - -var dynamicNewForConfig = dynamic.NewForConfig -var kubernetesNewForConfig = kubernetes.NewForConfig - -func setupClientsImpl() (dynamic.Interface, error) { - config, err := rest.InClusterConfig() - if err != nil { - return nil, err - } - dynamicClient, err := dynamicNewForConfig(config) - - if err != nil { - return nil, err - - } - return dynamicClient, nil - -} - -var setupClients = setupClientsImpl - -func SetupConfigurationsFiles(log logger.LoggerInterface, basedir string) error { - configurationNames, ok := os.LookupEnv("ACE_CONFIGURATIONS") - if ok && configurationNames != "" { - log.Printf("Setup configuration files - configuration names: %s", configurationNames) - - return SetupConfigurationsFilesInternal(log, strings.SplitN(configurationNames, ",", -1), basedir) - } else { - return nil - } -} -func SetupConfigurationsFilesInternal(log logger.LoggerInterface, configurationNames []string, basedir string) error { - // set up k8s client - dynamicClient, err := setupClients() - if err != nil { - return err - } - // get pod namespace - namespace, err := getPodNamespace() - if err != nil { - return err - } - // get contents for all configurations - rawConfigurations, err := getAllConfigurations(log, namespace, configurationNames, dynamicClient) - - if err != nil { - return err - } - configurationObjects, err := parseConfigurationList(log, basedir, rawConfigurations) - if err != nil { - return err - } - - for _, configObject := range configurationObjects { - // create files on the system - err := constructConfigurationsOnFileSystem(log, basedir, configObject.name, configObject.configType, configObject.contents) - if err != nil { - return err - } - } - return nil -} - -func constructConfigurationsOnFileSystem(log logger.LoggerInterface, basedir string, configName string, configType string, contents []byte) error { - log.Printf("Construct a configuration on the filesystem - configuration name: %s type: %s", configName, configType) - switch configType { - case "policyproject": - return constructPolicyProjectOnFileSystem(log, basedir, contents) - case "truststore": - return constructTrustStoreOnFileSystem(log, basedir, configName, contents) - case "keystore": - return constructKeyStoreOnFileSystem(log, basedir, configName, contents) - case "odbc": - return constructOdbcIniOnFileSystem(log, basedir, contents) - case "serverconf": - return constructServerConfYamlOnFileSystem(log, basedir, contents) - case "setdbparms": - return executeSetDbParms(log, basedir, contents) - case "generic": - return constructGenericOnFileSystem(log, basedir, contents) - case "loopbackdatasource": - return constructLoopbackDataSourceOnFileSystem(log, basedir, contents) - case "adminssl": - return constructAdminSSLOnFileSystem(log, basedir, contents) - case "accounts": - return SetupTechConnectorsConfigurations(log, basedir, contents) - case "agentx": - return constructAgentxOnFileSystem(log, basedir, contents) - case "agenta": - return constructAgentaOnFileSystem(log, basedir, contents) - case "truststorecertificate": - return addTrustCertificateToCAcerts(log, basedir, configName, contents) - case "barauth": - return downloadBarFiles(log, basedir, contents) - case "workdiroverride": - return constructWorkdirOverrideOnFileSystem(log, basedir, configName, contents) - case "resiliencekafkacredentials": - log.Println("Do nothing for resiliencykafkacredentials") - return nil - case "persistencerediscredentials": - log.Println("Do nothing for persistencerediscredentials") - return nil - default: - return errors.New("Unknown configuration type") - } -} - -func constructPolicyProjectOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct policy project on the filesystem") - return unzip(log, basedir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"overrides", contents) -} - -func constructTrustStoreOnFileSystem(log logger.LoggerInterface, basedir string, name string, contents []byte) error { - log.Printf("Construct truststore on the filesystem - Truststore name: %s", name) - return writeConfigurationFile(basedir+string(os.PathSeparator)+truststoresName, name, contents) -} - -func constructKeyStoreOnFileSystem(log logger.LoggerInterface, basedir string, name string, contents []byte) error { - log.Printf("Construct keystore on the filesystem - Keystore name: %s", name) - return writeConfigurationFile(basedir+string(os.PathSeparator)+keystoresName, name, contents) -} - -func constructOdbcIniOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct odbc.Ini on the filesystem") - return writeConfigurationFile(basedir+string(os.PathSeparator)+workdirName, "odbc.ini", contents) -} - -func constructGenericOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct generic files on the filesystem") - return unzip(log, basedir+string(os.PathSeparator)+genericName, contents) -} - -func constructLoopbackDataSourceOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct loopback connector files on the filesystem") - return unzip(log, basedir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config"+string(os.PathSeparator)+"connectors"+string(os.PathSeparator)+"loopback", contents) -} - -func constructAdminSSLOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct adminssl on the filesystem") - return unzip(log, basedir+string(os.PathSeparator)+adminsslName, contents) -} - -func constructServerConfYamlOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct serverconfyaml on the filesystem") - return writeConfigurationFile(basedir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"overrides", "server.conf.yaml", contents) -} - -func constructAgentxOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct agentx on the filesystem") - return writeConfigurationFile(basedir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agentx", "agentx.json", contents) -} - -func constructAgentaOnFileSystem(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Construct agenta on the filesystem") - return writeConfigurationFile(basedir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agenta", "agenta.json", contents) -} - -func addTrustCertificateToCAcerts(log logger.LoggerInterface, basedir string, name string, contents []byte) error { - log.Println("Adding trust certificate to CAcerts") - // creating temporary file based on the content - tmpFile := creatingTempFile(log, contents, name) - // cleans up the file afterwards - defer os.Remove(tmpFile.Name()) - // adding this file to CAcerts - commandCreateArgsJKS := []string{"-import", "-file", tmpFile.Name(), "-alias", name, "-keystore", "$MQSI_JREPATH/lib/security/cacerts", "-storepass", "changeit", "-noprompt", "-storetype", "JKS"} - return internalRunKeytoolCommand(log, commandCreateArgsJKS) -} - -func constructWorkdirOverrideOnFileSystem(log logger.LoggerInterface, basedir string, name string, contents []byte) error { - log.Printf("Construct workdiroverride on the filesystem - Workdiroveride name: %s", name) - return writeConfigurationFile(basedir+string(os.PathSeparator)+initialConfig+string(os.PathSeparator)+workdiroverrides, name, contents) -} - -func creatingTempFile(log logger.LoggerInterface, contents []byte, name string) *os.File { - tmpFile, err := ioutil.TempFile(os.TempDir(), name) - if err != nil { - log.Println("Cannot create temporary file", err) - } - - // writing content to the file - if _, err = tmpFile.Write(contents); err != nil { - log.Println("Failed to write to temporary file", err) - } - - // Close the file - if err := tmpFile.Close(); err != nil { - log.Println("Failed to close the file", err) - } - return tmpFile -} - -func executeSetDbParms(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Execute mqsisetdbparms command") - for index, m := range strings.Split(string(contents), "\n") { - // ignore empty lines - if len(strings.TrimSpace(m)) > 0 { - contentsArray := strings.Fields(strings.TrimSpace(m)) - log.Printf("Execute line %d with number of args: %d", index, len(contentsArray)) - var trimmedArray []string - for _, m := range contentsArray { - escapedQuote := strings.Replace(m, "'", "'\\''", -1) - trimmedArray = append(trimmedArray, "'"+strings.TrimSpace(escapedQuote)+"'") - } - if len(trimmedArray) > 2 { - if trimmedArray[0] == "'mqsisetdbparms'" { - if !Contains(trimmedArray, "'-w'") { - trimmedArray = append(trimmedArray, "'-w'") - trimmedArray = append(trimmedArray, "'"+basedir+string(os.PathSeparator)+workdirName+"'") - } - err := internalRunSetdbparmsCommand(log, "mqsisetdbparms", trimmedArray[1:]) - if err != nil { - return err - } - } else if len(trimmedArray) == 3 { - args := []string{"'-n'", trimmedArray[0], "'-u'", trimmedArray[1], "'-p'", trimmedArray[2], "'-w'", "'" + basedir + string(os.PathSeparator) + workdirName + "'"} - err := internalRunSetdbparmsCommand(log, "mqsisetdbparms", args) - if err != nil { - return err - } - } else { - return errors.New("Invalid mqsisetdbparms entry - too many parameters") - } - } else { - return errors.New("Invalid mqsisetdbparms entry - too few parameters") - } - } - } - return nil - -} -func runSetdbparmsCommand(log logger.LoggerInterface, command string, params []string) error { - realCommand := command - return runCommand(log, realCommand, params) -} - -func runCommand(log logger.LoggerInterface, command string, params []string) error { - realCommand := "source " + aceInstall + "/mqsiprofile && " + command + " " + strings.Join(params[:], " ") - cmd := exec.Command("/bin/sh", "-c", realCommand) - cmd.Stdin = strings.NewReader("some input") - var stderr bytes.Buffer - cmd.Stderr = &stderr - var stdout bytes.Buffer - cmd.Stdout = &stdout - err := cmd.Run() - if err != nil { - log.Printf("Error executing command: %s %s", stdout.String(), stderr.String()) - - } else { - log.Printf("Successfully executed command.") - } - return err - -} - -func runKeytoolCommand(log logger.LoggerInterface, params []string) error { - return runCommand(log, "keytool", params) - -} - -var internalRunSetdbparmsCommand = runSetdbparmsCommand -var internalRunKeytoolCommand = runKeytoolCommand - -func Contains(a []string, x string) bool { - for _, n := range a { - if x == n { - return true - } - } - return false -} -func main() { -} - -func downloadBarFiles(log logger.LoggerInterface, basedir string, contents []byte) error { - log.Println("Downloading bar file using supplied credentials") - ContentServer = false - log.Debug("Configuration: " + string(contents)) - barAuthParsed, err := gabs.ParseJSON(contents) - if err != nil { - return errors.New("Unable to parse JSON") - } - authType := barAuthParsed.Path("authType").Data().(string) - switch authType { - case "BASIC_AUTH": - return downloadBASIC_AUTH(log, basedir, barAuthParsed) - default: - return errors.New("Unknown barauth type: " + authType) - } -} - -func downloadBASIC_AUTH(log logger.LoggerInterface, basedir string, barAuthParsed *gabs.Container) error { - log.Println("BasicAuth Credentials") - - // Get the SystemCertPool, continue with an empty pool on error - rootCAs, _ := x509.SystemCertPool() - if rootCAs == nil { - rootCAs = x509.NewCertPool() - } - - // Append optional cert to the system pool - if (barAuthParsed.Path("credentials.caCert").Data() != nil) && (barAuthParsed.Path("credentials.caCert").Data().(string) != "") { - caCert := barAuthParsed.Path("credentials.caCert").Data().(string) - if ok := rootCAs.AppendCertsFromPEM([]byte(caCert)); !ok { - return errors.New("CaCert provided but failed to append, Cert provided: " + caCert) - } else { - log.Println("Appending supplied cert via configuration to system pool") - } - } else if (barAuthParsed.Path("credentials.caCertSecret").Data() != nil) && (barAuthParsed.Path("credentials.caCertSecret").Data().(string) != "") { - // Read in the cert file - caCert, err := ioutil.ReadFile(`/home/aceuser/barurlendpoint/ca.crt`) - if err != nil { - return errors.New("CaCertSecret provided but failed to append, Cert provided: " + string(caCert)) - } - if ok := rootCAs.AppendCertsFromPEM(caCert); !ok { - log.Println("No certs appended, using system certs only") - } else { - log.Println("Appending supplied cert via secret to system pool") - } - } else { - log.Println("No certs provided, using system certs only") - } - - var tr *http.Transport - // Allow insecure if insecureSsl is set - if (barAuthParsed.Path("credentials.insecureSsl").Data() != nil) && (barAuthParsed.Path("credentials.insecureSsl").Data().(string) == "true") { - tr = &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - DisableCompression: true, - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - RootCAs: rootCAs, - }, - } - log.Println("insecureSsl set so accepting/ignoring all server SSL certificates ") - } else { - tr = &http.Transport{ - MaxIdleConns: 10, - IdleConnTimeout: 30 * time.Second, - DisableCompression: true, - TLSClientConfig: &tls.Config{ - RootCAs: rootCAs, - }, - } - } - client := &http.Client{Transport: tr} - - urls := os.Getenv("ACE_CONTENT_SERVER_URL") - if urls == "" { - return errors.New("No bar url available") - } - - err := os.Mkdir("/home/aceuser/initial-config/bars", os.ModePerm) - if err != nil { - log.Errorf("Error creating directory /home/aceuser/initial-config/bars: %v", err) - return err - } - - urlArray := strings.Split(urls, ",") - for _, url := range urlArray { - - req, err := http.NewRequest("GET", url, nil) - if err != nil { - log.Errorf("Failed creating request - err:", err) - return err - } - - var filename string - - if len(urlArray) == 1 { - // Temporarily override the bar name with "barfile.bar" if we only have ONE bar file until mq connector is fixed to support any bar name - filename = "/home/aceuser/initial-config/bars/barfile.bar" - } else { - // Case where multiple bars. Need to check what file path is available - filename = determineAvailableFilename(log, "/home/aceuser/initial-config/bars/"+path.Base(req.URL.Path)) - } - - file, err := os.Create(filename) - if err != nil { - log.Errorf("Error creating file %v: %v", file, err) - return err - } - defer file.Close() - - req.SetBasicAuth(barAuthParsed.Path("credentials.username").Data().(string), barAuthParsed.Path("credentials.password").Data().(string)) - resp, err := client.Do(req) - if err != nil { - log.Errorf("HTTP call failed - err:", err) - return err - } - if resp.StatusCode != http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - log.Errorf("Failed to convert body", err) - return err - } - log.Println("Response: " + string(body)) - return errors.New("Non-OK HTTP status: " + strconv.Itoa(resp.StatusCode)) - } else { - log.Println("Downloaded bar file from: " + url) - } - - _, err = io.Copy(file, resp.Body) - if err != nil { - log.Errorf("Error writing file %v: %v", file, err) - return err - } - log.Printf("Saved bar file to " + filename) - } - return nil -} - -func determineAvailableFilename(log logger.LoggerInterface, basepath string) string { - var filename string - filenameBase := basepath - // Initially strip off the .bar at the end if present - if filenameBase[len(filenameBase)-4:] == ".bar" { - filenameBase = filenameBase[:len(filenameBase)-4] - } - isAvailable := false - count := 0 - for !isAvailable { - if count == 0 { - filename = filenameBase + ".bar" - } else { - filename = filenameBase + "-" + fmt.Sprint(count) + ".bar" - log.Printf("Previous path already in use. Testing filename: " + filename) - } - - if _, err := osStat(filename); os.IsNotExist(err) { - log.Printf("No existing file on that path so continuing") - isAvailable = true - } - count++ - } - return filename -} diff --git a/internal/configuration/configuration_test.go b/internal/configuration/configuration_test.go deleted file mode 100644 index 9f4e1e6..0000000 --- a/internal/configuration/configuration_test.go +++ /dev/null @@ -1,1037 +0,0 @@ -package configuration - -import ( - "encoding/base64" - "errors" - "io" - "io/ioutil" - "os" - "testing" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/stretchr/testify/assert" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/client-go/dynamic" -) - -const testBaseDir = "/tmp/tests" - -var testSecretValue = []byte("test secret") - -const secretName = "setdbparms.txt-wb2dc" - -var testLogger, err = logger.NewLogger(os.Stdout, true, true, "test") - -var osMkdirAllRestore = osMkdirAll -var ioutilWriteFileRestore = ioutilWriteFile -var ioutilReadFileRestore = ioutilReadFile -var getSecretRestore = getSecret -var setupClientsRestore = setupClients -var getAllConfigurationsRestore = getAllConfigurations -var osOpenFileRestore = osOpenFile -var ioCopyRestore = ioCopy -var RunCommandRestore = internalRunSetdbparmsCommand -var RunKeytoolCommandRestore = internalRunKeytoolCommand -var setupMqAccountsKdbFileRestore = setupMqAccountsKdbFile - -const policyProjectContent = "UEsDBAoAAAAAAFelclAAAAAAAAAAAAAAAAAJABwAcHJvamVjdDEvVVQJAAPFh3JeyIdyXnV4CwABBPUBAAAEFAAAAFBLAwQUAAAACABgpHJQn5On0w0AAAARAAAAEQAcAHByb2plY3QxL3Rlc3QueG1sVVQJAAPzhXJeHoZyXnV4CwABBPUBAAAEFAAAALMpSS0usQMRNvpgJgBQSwECHgMKAAAAAABXpXJQAAAAAAAAAAAAAAAACQAYAAAAAAAAABAA7UEAAAAAcHJvamVjdDEvVVQFAAPFh3JedXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAYKRyUJ+Tp9MNAAAAEQAAABEAGAAAAAAAAQAAAKSBQwAAAHByb2plY3QxL3Rlc3QueG1sVVQFAAPzhXJedXgLAAEE9QEAAAQUAAAAUEsFBgAAAAACAAIApgAAAJsAAAAAAA==" -const genericContent = "UEsDBAoAAAAAAFelclAAAAAAAAAAAAAAAAAJABwAcHJvamVjdDEvVVQJAAPFh3JeyIdyXnV4CwABBPUBAAAEFAAAAFBLAwQUAAAACABgpHJQn5On0w0AAAARAAAAEQAcAHByb2plY3QxL3Rlc3QueG1sVVQJAAPzhXJeHoZyXnV4CwABBPUBAAAEFAAAALMpSS0usQMRNvpgJgBQSwECHgMKAAAAAABXpXJQAAAAAAAAAAAAAAAACQAYAAAAAAAAABAA7UEAAAAAcHJvamVjdDEvVVQFAAPFh3JedXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAYKRyUJ+Tp9MNAAAAEQAAABEAGAAAAAAAAQAAAKSBQwAAAHByb2plY3QxL3Rlc3QueG1sVVQFAAPzhXJedXgLAAEE9QEAAAQUAAAAUEsFBgAAAAACAAIApgAAAJsAAAAAAA==" -const adminsslcontent = "UEsDBAoAAAAAAD1epVBBsFEJCgAAAAoAAAAGABwAY2EuY3J0VVQJAAPWRLFe1kSxXnV4CwABBPUBAAAEFAAAAGZha2UgY2VydApQSwECHgMKAAAAAAA9XqVQQbBRCQoAAAAKAAAABgAYAAAAAAABAAAApIEAAAAAY2EuY3J0VVQFAAPWRLFedXgLAAEE9QEAAAQUAAAAUEsFBgAAAAABAAEATAAAAEoAAAAAAA==" -const loopbackdatasourcecontent = "UEsDBBQAAAAIALhhL1E16fencwAAAKQAAAAQABwAZGF0YXNvdXJjZXMuanNvblVUCQAD7KFgX+yhYF91eAsAAQT1AQAABBQAAACrVsrNz0vPT0lSsqpWykvMTVWyUoAJxaeklinpKCXn5+WlJpfkFyFJAYUz8otLQCKGRuZ6BkBoqKSjoFSQXwQSNDI3MDTXUUpJLElMSiwGmwk0y8UJpKS0OLUIZhFQMBTIBetMLC4uzy9KgQoHwLi1tVwAUEsDBAoAAAAAAH1hL1EAAAAAAAAAAAAAAAAGABwAbW9uZ28vVVQJAAN9oWBffaFgX3V4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIALhhL1E16fencwAAAKQAAAAQABgAAAAAAAEAAACkgQAAAABkYXRhc291cmNlcy5qc29uVVQFAAPsoWBfdXgLAAEE9QEAAAQUAAAAUEsBAh4DCgAAAAAAfWEvUQAAAAAAAAAAAAAAAAYAGAAAAAAAAAAQAO1BvQAAAG1vbmdvL1VUBQADfaFgX3V4CwABBPUBAAAEFAAAAFBLBQYAAAAAAgACAKIAAAD9AAAAAAA=" - -func restore() { - osMkdirAll = osMkdirAllRestore - ioutilWriteFile = ioutilWriteFileRestore - ioutilReadFile = ioutilReadFileRestore - getSecret = getSecretRestore - getAllConfigurations = getAllConfigurationsRestore - setupClients = setupClientsRestore - osOpenFile = osOpenFileRestore - ioCopy = ioCopyRestore - internalRunSetdbparmsCommand = RunCommandRestore - internalRunKeytoolCommand = RunKeytoolCommandRestore - setupMqAccountsKdbFile = setupMqAccountsKdbFileRestore -} - -func reset() { - // default error mocks - osMkdirAll = func(path string, perm os.FileMode) error { - panic("Should be mocked") - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - panic("Should be mocked") - } - getSecret = func(basedir string, secretName string) ([]byte, error) { - panic("Should be mocked") - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - - panic("Should be mocked") - } - - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - panic("Should be mocked") - } - - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - panic("Should be mocked") - } - - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - panic("Should be mocked") - } - - internalRunKeytoolCommand = func(log logger.LoggerInterface, params []string) error { - panic("Should be mocked") - } - - // common mock - setupClients = func() (dynamic.Interface, error) { - return nil, nil - - } - - ioutilReadFile = func(filename string) ([]byte, error) { - return []byte("ace"), nil - } - - setupMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return nil - } -} - -func TestUnzip(t *testing.T) { - zipContents, _ := base64.StdEncoding.DecodeString(policyProjectContent) - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"project1", path) - return nil - } - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"project1"+string(os.PathSeparator)+"test.xml", name) - return &os.File{}, nil - } - - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - b, err := ioutil.ReadAll(src) - assert.Equal(t, "test", string(b)) - return 12, nil - } - // test working unzip file - assert.Nil(t, unzip(testLogger, testBaseDir, zipContents)) - // test failing ioCopy - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - return 1, errors.New("failed ioCopy") - } - { - err := unzip(testLogger, testBaseDir, zipContents) - if assert.Error(t, err, "Failed to copy file") { - assert.Equal(t, errors.New("failed ioCopy"), err) - } - } - // test open file fail - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - return &os.File{}, errors.New("failed file open") - } - { - err := unzip(testLogger, testBaseDir, zipContents) - if assert.Error(t, err, "Failed to copy file") { - assert.Equal(t, errors.New("failed file open"), err) - } - } - // fail mkdir - osMkdirAll = func(path string, perm os.FileMode) error { - return errors.New("failed mkdir") - } - { - err := unzip(testLogger, testBaseDir, zipContents) - if assert.Error(t, err, "Failed to copy file") { - assert.Equal(t, errors.New("failed mkdir"), err) - } - } -} -func TestSetupConfigurationsFiles(t *testing.T) { - // Test env ACE_CONFIGURATIONS not being set - os.Unsetenv("ACE_CONFIGURATIONS") - reset() - assert.Nil(t, SetupConfigurationsFiles(testLogger, testBaseDir)) - // Test env ACE_CONFIGURATIONS being set - os.Setenv("ACE_CONFIGURATIONS", "server.conf.yaml,odbc.ini") - reset() - configContents := "ZmFrZUZpbGUK" - // Test env ACE_CONFIGURATIONS set to an array of two configurations - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - if path != testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"overrides" && - path != testBaseDir+string(os.PathSeparator)+workdirName { - t.Errorf("Incorrect path for mkdir: %s", path) - } - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - if fn != testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"overrides"+string(os.PathSeparator)+"server.conf.yaml" && - fn != testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"odbc.ini" { - t.Errorf("Incorrect path for writing to a file: %s", fn) - } - return nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, "server.conf.yaml", cn[0]) - assert.Equal(t, "odbc.ini", cn[1]) - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "server.conf.yaml", - }, - "spec": map[string]interface{}{ - "type": "serverconf", - "contents": configContents, - }, - }, - }, { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "odbc.ini", - }, - "spec": map[string]interface{}{ - "type": "odbc", - "contents": configContents, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFiles(testLogger, testBaseDir)) -} - -func TestRunCommand(t *testing.T) { - // check get an error when command is rubbish - err := runCommand(testLogger, "fakeCommand", []string{"fake"}) - if err == nil { - assert.Equal(t, errors.New("Command should have failed"), err) - } -} - -func TestSetupConfigurationsFilesInternal(t *testing.T) { - - configContents := "ZmFrZUZpbGUK" - // Test missing type fails - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "bad.type") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "bad.type", - }, - "spec": map[string]interface{}{}, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"bad.type"}, testBaseDir) - if assert.Error(t, err, "A configuration must has a type") { - assert.Equal(t, errors.New("A configuration must has a type"), err) - } - } - // Test missing contents fails - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "bad.type") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "bad.type", - }, - "spec": map[string]interface{}{ - "type": "serverconf", - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"bad.type"}, testBaseDir) - if assert.Error(t, err, "A configuration with type: serverconf must has a contents field") { - assert.Equal(t, errors.New("A configuration with type: serverconf must has a contents field"), err) - } - } - // Test missing secret fails - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "bad.type") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "bad.type", - }, - "spec": map[string]interface{}{ - "type": "setdbparms", - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"bad.type"}, testBaseDir) - if assert.Error(t, err, "A configuration with type: setdbparms must have a secretName field") { - assert.Equal(t, errors.New("A configuration with type: setdbparms must have a secretName field"), err) - } - } // Test secret file is missing - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return nil, errors.New("missing secret file") - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "bad.type") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "bad.type", - }, - "spec": map[string]interface{}{ - "type": "setdbparms", - "secretName": secretName, - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"bad.type"}, testBaseDir) - if assert.Error(t, err, "missing secret file") { - assert.Equal(t, errors.New("missing secret file"), err) - } - } - // Test invalid type fails - reset() - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "bad.type") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "bad.type", - }, - "spec": map[string]interface{}{ - "type": "badtype", - "contents": configContents, - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"bad.type"}, testBaseDir) - assert.Equal(t, errors.New("Unknown configuration type"), err) - } - // Test base64 decode fails of content - reset() - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "server.conf.yaml") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "server.conf.yaml", - }, - "spec": map[string]interface{}{ - "type": "serverconf", - "contents": "not base64", - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"server.conf.yaml"}, testBaseDir) - if assert.Error(t, err, "Fails to decode") { - assert.Equal(t, errors.New("Failed to decode contents"), err) - } - } - - // Test accounts.yaml - reset() - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "accounts-1") - - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "accounts-1", - }, - "spec": map[string]interface{}{ - "type": "accounts", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"accounts-1"}, testBaseDir)) - // Test agentx.json - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agentx", path) - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agentx"+string(os.PathSeparator)+"agentx.json", fn) - return nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "agentx-1") - - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "agentx-1", - }, - "spec": map[string]interface{}{ - "type": "agentx", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"agentx-1"}, testBaseDir)) - // Test agenta.json - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agenta", path) - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config/iibswitch/agenta"+string(os.PathSeparator)+"agenta.json", fn) - return nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "agenta-1") - - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "agenta-1", - }, - "spec": map[string]interface{}{ - "type": "agenta", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"agenta-1"}, testBaseDir)) - // Test odbc.ini using contents field - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName, path) - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"odbc.ini", fn) - return nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "odbc-ini") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "odbc-ini", - }, - "spec": map[string]interface{}{ - "type": "odbc", - "contents": configContents, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"odbc-ini"}, testBaseDir)) - // Test Truststore - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"truststores", path) - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"truststores"+string(os.PathSeparator)+"truststore-1", fn) - return nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "truststore-1") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "truststore-1", - }, - "spec": map[string]interface{}{ - "type": "truststore", - "secretName": secretName}, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"truststore-1"}, testBaseDir)) - // Test Keystore - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"keystores", path) - return nil - } - ioutilWriteFile = func(fn string, data []byte, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+"keystores"+string(os.PathSeparator)+"keystore-1", fn) - return nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "keystore-1") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "keystore-1", - }, - "spec": map[string]interface{}{ - "type": "keystore", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"keystore-1"}, testBaseDir)) - // Test setdbparms.txt - reset() - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "setdbparms.txt") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "setdbparms.txt", - }, - "spec": map[string]interface{}{ - "type": "setdbparms", - "secretName": secretName, - }, - }, - }, - }, nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir) - assert.Equal(t, errors.New("Invalid mqsisetdbparms entry - too few parameters"), err) - } - // Test setdbparms with too many parameters - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("name user pass extra"), nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir) - assert.Equal(t, errors.New("Invalid mqsisetdbparms entry - too many parameters"), err) - } - // Test setdbparms with just name, user and password but command fails - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("name user pass"), nil - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - testParams := []string{"'-n'", "'name'", "'-u'", "'user'", "'-p'", "'pass'", "'-w'", "'/tmp/tests/ace-server'"} - assert.Equal(t, params, testParams) - return errors.New("command fails") - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir) - assert.Equal(t, errors.New("command fails"), err) - } - // Test setdbparms with full command but command fails - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("mqsisetdbparms -n name -u user -p pass -w /tmp/tests/ace-server"), nil - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - testParams := []string{"'-n'", "'name'", "'-u'", "'user'", "'-p'", "'pass'", "'-w'", "'/tmp/tests/ace-server'"} - assert.Equal(t, params, testParams) - return errors.New("command fails") - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir) - assert.Equal(t, errors.New("command fails"), err) - } - // Test setdbparms with just name, user and password - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("name user pass"), nil - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - testParams := []string{"'-n'", "'name'", "'-u'", "'user'", "'-p'", "'pass'", "'-w'", "'/tmp/tests/ace-server'"} - assert.Equal(t, params, testParams) - return nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir)) - - // Test setdbparms with several lines, spaces and single quotes - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("\n name1 user1 pass1 \n name2 user2 pass2' "), nil - - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - var testParams []string - if params[1] == "'name1'" { - testParams = []string{"'-n'", "'name1'", "'-u'", "'user1'", "'-p'", "'pass1'", "'-w'", "'/tmp/tests/ace-server'"} - } else { - testParams = []string{"'-n'", "'name2'", "'-u'", "'user2'", "'-p'", "'pass2'\\'''", "'-w'", "'/tmp/tests/ace-server'"} - - } - assert.Equal(t, params, testParams) - return nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir)) - // Test setdbparms with full syntax - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return []byte("mqsisetdbparms -n name -u user -p pass"), nil - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - testParams := []string{"'-n'", "'name'", "'-u'", "'user'", "'-p'", "'pass'", "'-w'", "'/tmp/tests/ace-server'"} - assert.Equal(t, params, testParams) - return nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir)) - - // Test setdbparms with spaces and -w included - getSecret = func(basdir string, name string) ([]byte, error) { - - assert.Equal(t, name, secretName) - return []byte("mqsisetdbparms -n name -u user -p pass -w /tmp/tests/ace-server"), nil - } - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, command, "mqsisetdbparms") - testParams := []string{"'-n'", "'name'", "'-u'", "'user'", "'-p'", "'pass'", "'-w'", "'/tmp/tests/ace-server'"} - assert.Equal(t, params, testParams) - return nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"setdbparms.txt"}, testBaseDir)) - - // policy project with an invalid zip file - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "policy-project") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "policy-project", - }, - "spec": map[string]interface{}{ - "type": "policyproject", - "contents": configContents, - }, - }, - }, - }, nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"policy-project"}, testBaseDir) - assert.Equal(t, errors.New("zip: not a valid zip file"), err) - } - // Test adminssl - reset() - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+adminsslName, path) - return nil - } - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+adminsslName+string(os.PathSeparator)+"ca.crt", name) - return &os.File{}, nil - } - - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - b, err := ioutil.ReadAll(src) - assert.Equal(t, "fake cert\n", string(b)) - return 12, nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return base64.StdEncoding.DecodeString(adminsslcontent) - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "adminssl1") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "adminssl1", - }, - "spec": map[string]interface{}{ - "type": "adminssl", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"adminssl1"}, testBaseDir)) - // Test adminssl with invalid zip file - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("not a zip"), nil - } - - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"adminssl1"}, testBaseDir) - assert.Equal(t, errors.New("zip: not a valid zip file"), err) - } - reset() - // Test generic - osMkdirAll = func(path string, perm os.FileMode) error { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+genericName+string(os.PathSeparator)+"project1", path) - return nil - } - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+genericName+string(os.PathSeparator)+"project1"+string(os.PathSeparator)+"test.xml", name) - return &os.File{}, nil - } - - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - b, err := ioutil.ReadAll(src) - assert.Equal(t, "test", string(b)) - return 12, nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return base64.StdEncoding.DecodeString(genericContent) - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "generic1") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "generic1", - }, - "spec": map[string]interface{}{ - "type": "generic", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"generic1"}, testBaseDir)) - // Test generic with invalid zip file - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("not a zip"), nil - } - - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"generic1"}, testBaseDir) - assert.Equal(t, errors.New("zip: not a valid zip file"), err) - } - reset() - // Test loopbackdatasource - countMkDir := 0 - osMkdirAll = func(path string, perm os.FileMode) error { - if countMkDir == 0 { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config"+string(os.PathSeparator)+"connectors"+string(os.PathSeparator)+"loopback", path) - } else { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config"+string(os.PathSeparator)+"connectors"+string(os.PathSeparator)+"loopback"+string(os.PathSeparator)+"mongo", path) - } - countMkDir++ - return nil - } - osOpenFile = func(name string, flat int, perm os.FileMode) (*os.File, error) { - assert.Equal(t, testBaseDir+string(os.PathSeparator)+workdirName+string(os.PathSeparator)+"config"+string(os.PathSeparator)+"connectors"+string(os.PathSeparator)+"loopback"+string(os.PathSeparator)+"datasources.json", name) - return &os.File{}, nil - } - - ioCopy = func(dst io.Writer, src io.Reader) (written int64, err error) { - b, err := ioutil.ReadAll(src) - assert.Equal(t, "{\"mongodb\":{\"name\": \"mongodb_dev\",\"connector\": \"mongodb\",\"host\": \"127.0.0.1\", \"port\": 27017,\"database\": \"devDB\", \"username\": \"devUser\", \"password\": \"devPassword\"}}\n", string(b)) - return 12, nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return base64.StdEncoding.DecodeString(loopbackdatasourcecontent) - } - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "loopback1") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "loopback1", - }, - "spec": map[string]interface{}{ - "type": "loopbackdatasource", - "secretName": secretName, - }, - }, - }, - }, nil - } - assert.Nil(t, SetupConfigurationsFilesInternal(testLogger, []string{"loopback1"}, testBaseDir)) - // Test loopbackdatasource with invalid zip file - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return []byte("not a zip"), nil - } - - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"loopback1"}, testBaseDir) - - assert.Equal(t, errors.New("zip: not a valid zip file"), err) - - } - - // Test truststore certificates - getAllConfigurations = func(log logger.LoggerInterface, ns string, cn []string, dc dynamic.Interface) ([]*unstructured.Unstructured, error) { - assert.Equal(t, cn[0], "truststorecert") - return []*unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "kind": "Configurations", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "name": "truststorecert", - }, - "spec": map[string]interface{}{ - "type": "truststorecertificate", - "secretName": secretName, - }, - }, - }, - }, nil - } - getSecret = func(basdir string, name string) ([]byte, error) { - assert.Equal(t, name, secretName) - return testSecretValue, nil - } - - // Test keytool command to be called with the correct params - internalRunKeytoolCommandCallCount := 0 - internalRunKeytoolCommand = func(log logger.LoggerInterface, params []string) error { - testParams := []string{"-import", "-file", "-alias", "truststorecert", "-keystore", "$MQSI_JREPATH/lib/security/cacerts", "-storepass", "changeit", "-noprompt", "-storetype", "JKS"} - for i := range params { - if i < 2 { - assert.Equal(t, params[i], testParams[i]) - } else if i > 2 { - assert.Equal(t, params[i], testParams[i-1]) - } - } - internalRunKeytoolCommandCallCount++ - return nil - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"truststorecert"}, testBaseDir) - assert.Equal(t, 1, internalRunKeytoolCommandCallCount) - assert.Equal(t, nil, err) - } - - // Test keytool command throw an error - internalRunKeytoolCommand = func(log logger.LoggerInterface, params []string) error { - return errors.New("command fails") - } - { - err := SetupConfigurationsFilesInternal(testLogger, []string{"truststorecert"}, testBaseDir) - assert.Equal(t, errors.New("command fails"), err) - } - - // restore - restore() -} - -func TestDetermineAvailableFilename(t *testing.T) { - - var osStatRestore = osStat - createdFiles := map[string]bool{} - - var reset = func() { - osStat = func(file string) (os.FileInfo, error) { - if createdFiles[file] { - return nil, os.ErrExist - } else { - return nil, os.ErrNotExist - } - } - } - - var restore = func() { - osStat = osStatRestore - } - - reset() - defer restore() - - t.Run("No existing files just returns the path.bar when basepath has no .bar", func(t *testing.T) { - createdFiles = map[string]bool{} - filename := determineAvailableFilename(testLogger, "my_server/my_bar") - assert.Equal(t, "my_server/my_bar.bar", filename) - }) - - t.Run("No existing files just returns the path.bar when basepath already has .bar", func(t *testing.T) { - createdFiles = map[string]bool{} - filename := determineAvailableFilename(testLogger, "my_server/my_bar.bar") - assert.Equal(t, "my_server/my_bar.bar", filename) - }) - - t.Run("Multiple files with different base paths all save as normal", func(t *testing.T) { - createdFiles = map[string]bool{} - - filename1 := determineAvailableFilename(testLogger, "my_server/my_bar1") - createdFiles[filename1] = true - - filename2 := determineAvailableFilename(testLogger, "my_server/my_bar2") - createdFiles[filename2] = true - - filename3 := determineAvailableFilename(testLogger, "my_server2/my_bar") - createdFiles[filename3] = true - - assert.Equal(t, "my_server/my_bar1.bar", filename1) - assert.Equal(t, "my_server/my_bar2.bar", filename2) - assert.Equal(t, "my_server2/my_bar.bar", filename3) - }) - - t.Run("Multiple files all the same basepath append an incrementing index with no .bar", func(t *testing.T) { - createdFiles = map[string]bool{} - basePath := "my_server/my_bar" - - filename1 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename1] = true - - filename2 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename2] = true - - filename3 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename3] = true - - assert.Equal(t, "my_server/my_bar.bar", filename1) - assert.Equal(t, "my_server/my_bar-1.bar", filename2) - assert.Equal(t, "my_server/my_bar-2.bar", filename3) - }) - - t.Run("Multiple files all the same basepath append an incrementing index and already have a .bar", func(t *testing.T) { - createdFiles = map[string]bool{} - basePath := "my_server/my_bar.bar" - - filename1 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename1] = true - - filename2 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename2] = true - - filename3 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename3] = true - - assert.Equal(t, "my_server/my_bar.bar", filename1) - assert.Equal(t, "my_server/my_bar-1.bar", filename2) - assert.Equal(t, "my_server/my_bar-2.bar", filename3) - }) - - t.Run("Multiple files all the same basepath append an incrementing index with mixed present and missing .bar", func(t *testing.T) { - createdFiles = map[string]bool{} - basePath := "my_server/my_bar.bar" - basePathBar := "my_server/my_bar" - - filename1 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename1] = true - - filename2 := determineAvailableFilename(testLogger, basePathBar) - createdFiles[filename2] = true - - filename3 := determineAvailableFilename(testLogger, basePath) - createdFiles[filename3] = true - - assert.Equal(t, "my_server/my_bar.bar", filename1) - assert.Equal(t, "my_server/my_bar-1.bar", filename2) - assert.Equal(t, "my_server/my_bar-2.bar", filename3) - }) -} diff --git a/internal/configuration/ioutil.go b/internal/configuration/ioutil.go deleted file mode 100644 index 49af32d..0000000 --- a/internal/configuration/ioutil.go +++ /dev/null @@ -1,41 +0,0 @@ -package configuration - -import ( - "io" - "io/ioutil" - "os" -) - -var ioutilReadFile = ioutil.ReadFile -var osMkdirAll = os.MkdirAll -var osMkdir = os.Mkdir -var osCreate = os.Create -var ioutilWriteFile = ioutil.WriteFile -var osOpenFile = os.OpenFile -var ioCopy = io.Copy -var osStat = os.Stat -var osIsNotExist = os.IsNotExist -var osRemoveAll = os.RemoveAll - -var internalAppendFile = func(fileName string, fileContent []byte, filePerm os.FileMode) error { - - file, err := os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePerm) - - if err != nil { - return err - } - - defer file.Close() - - _, err = file.Write(fileContent) - - if err == nil { - err = file.Sync() - } - - if err != nil { - return err - } - - return nil -} diff --git a/internal/configuration/techConnectorsConfiguration.go b/internal/configuration/techConnectorsConfiguration.go deleted file mode 100644 index ae18732..0000000 --- a/internal/configuration/techConnectorsConfiguration.go +++ /dev/null @@ -1,951 +0,0 @@ -package configuration - -import ( - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "log" - "math/rand" - "os" - "path/filepath" - "regexp" - "strconv" - "strings" - - "github.com/aymerick/raymond" - "github.com/ghodss/yaml" - "github.com/ot4i/ace-docker/common/logger" - yamlv2 "gopkg.in/yaml.v2" -) - -// JdbcCredentials Credentials structure for jdbc credentials object, can be extended for other tech connectors -type JdbcCredentials struct { - AuthType interface{} `json:"authType"` - DbType interface{} `json:"dbType"` - Hostname interface{} `json:"hostname"` - Port interface{} `json:"port"` - DbName interface{} `json:"dbName"` - Username interface{} `json:"username"` - Password interface{} `json:"password"` - MaxPoolSize interface{} `json:"maxPoolSize"` - AdditonalParams interface{} `json:"additonalParams"` -} - -// MQCredentials Credentials structure for mq account credentials object -type MQCredentials struct { - AuthType string `json:"authType"` - QueueManager string `json:"queueManager"` - Hostname string `json:"hostname"` - Port interface{} `json:"port"` - Username string `json:"username"` - Password string `json:"password"` - ChannelName string `json:"channelName"` - CipherSpec string `json:"sslCipherSpec"` - PeerName string `json:"sslPeerName"` - ServerCertificate string `json:"sslServerCertificate"` - ClientCertificate string `json:"sslClientCertificate"` - ClientCertificatePassword string `json:"sslClientCertificatePassword"` - ClientCertificateLabel string `json:"sslClientCertificateLabel"` -} - -// JdbcAccountInfo structure for jdbc connector accounts -type JdbcAccountInfo struct { - Name string - Credentials JdbcCredentials -} - -// MQAccountInfo Account info structure mq connector accounts -type MQAccountInfo struct { - Name string - Credentials MQCredentials -} - -// AccountInfo structure for individual account -type AccountInfo struct { - Name string `json:"name"` - Credentials json.RawMessage `json:"credentials"` -} - -// Accounts connectos account object -type Accounts struct { - Accounts map[string][]AccountInfo `json:"accounts"` -} - -var processMqConnectorAccounts = processMQConnectorAccountsImpl -var processJdbcConnectorAccounts = processJdbcConnectorAccountsImpl -var runOpenSslCommand = runOpenSslCommandImpl -var runMqakmCommand = runMqakmCommandImpl -var createMqAccountsKdbFile = createMqAccountsKdbFileImpl -var setupMqAccountsKdbFile = setupMqAccountsKdbFileImpl -var convertMqAccountSingleLinePEM = convertMQAccountSingleLinePEMImpl -var importMqAccountCertificates = importMqAccountCertificatesImpl -var raymondParse = raymond.Parse - -func convertToString(unknown interface{}) string { - switch unknown.(type) { - case float64: - return fmt.Sprintf("%v", unknown) - case string: - return unknown.(string) - default: - return "" - } -} - -func convertToNumber(unknown interface{}) float64 { - switch i := unknown.(type) { - case float64: - return i - case string: - f, _ := strconv.ParseFloat(i, 64) - return f - default: - return 0 - } -} - -// SetupTechConnectorsConfigurations entry point for all technology connector configurations -func SetupTechConnectorsConfigurations(log logger.LoggerInterface, basedir string, contents []byte) error { - - kdbError := setupMqAccountsKdbFile(log) - - if kdbError != nil { - log.Printf("#SetupTechConnectorsConfigurations setupMqAccountsKdb failed: %v\n", kdbError) - return kdbError - } - - techConnectors := map[string]func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error{ - "jdbc": processJdbcConnectorAccounts, - "mq": processMqConnectorAccounts} - - log.Println("#SetupTechConnectorsConfigurations: extracting accounts info") - jsonContents, err := yaml.YAMLToJSON(contents) - if err != nil { - log.Printf("#SetupTechConnectorsConfigurations YAMLToJSON: %v\n", err) - return err - } - - var jsonContentsObjForCredParse Accounts - err = json.Unmarshal(jsonContents, &jsonContentsObjForCredParse) - if err != nil { - log.Fatalf("#SetupTechConnectorsConfigurations Unmarshal: %v", err) - return nil - } - - for connector, connectorFunc := range techConnectors { - connectorAccounts := jsonContentsObjForCredParse.Accounts[connector] - - if len(connectorAccounts) > 0 { - log.Printf("Processing connector %s accounts \n", connector) - err := connectorFunc(log, basedir, connectorAccounts) - - if err != nil { - log.Printf("An error occured while proccessing connector accounts %s %v\n", connector, err) - return err - } else { - log.Printf("Connector %s accounts processed %v", connector, len(connectorAccounts)) - } - } else { - log.Printf("No accounts found for connector %s", connector) - } - } - - return nil -} - -func processJdbcConnectorAccountsImpl(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - - designerAuthMode, ok := os.LookupEnv("DEVELOPMENT_MODE") - - if ok && designerAuthMode == "true" { - log.Println("Ignore jdbc accounts in designer authoring integration server") - return nil - } - - jdbcAccounts := unmarshalJdbcAccounts(accounts) - err := setDSNForJDBCApplication(log, basedir, jdbcAccounts) - - if err != nil { - log.Printf("#SetupTechConnectorsConfigurations: encountered an error in setDSNForJDBCApplication: %v\n", err) - return err - } - err = buildJDBCPolicies(log, basedir, jdbcAccounts) - if err != nil { - log.Printf("#SetupTechConnectorsConfigurations: encountered an error in buildJDBCPolicies: %v\n", err) - return err - } - - return nil -} - -var setDSNForJDBCApplication = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - log.Println("#setDSNForJDBCApplication: Execute mqsisetdbparms command ") - - for _, accountContent := range jdbcAccounts { - log.Printf("#setDSNForJDBCApplication: setting up config for account - %v\n", accountContent.Name) - jdbcCurrAccountCredInfo := accountContent.Credentials - - hostName := convertToString(jdbcCurrAccountCredInfo.Hostname) - dbPort := convertToString(jdbcCurrAccountCredInfo.Port) - dbName := convertToString(jdbcCurrAccountCredInfo.DbName) - userName := convertToString(jdbcCurrAccountCredInfo.Username) - password := convertToString(jdbcCurrAccountCredInfo.Password) - - if len(hostName) == 0 || len(dbPort) == 0 || len(dbName) == 0 || len(userName) == 0 || len(password) == 0 { - log.Printf("#setDSNForJDBCApplication: skipping executing mqsisetdbparms for account - %v as one of the required fields found empty\n", accountContent.Name) - continue - } - shaInputRawText := hostName + ":" + dbPort + ":" + dbName + ":" + userName - hash := sha256.New() - hash.Write([]byte(shaInputRawText)) - shaHashEncodedText := hex.EncodeToString(hash.Sum(nil)) - args := []string{"'-n'", "jdbc::" + shaHashEncodedText, "'-u'", userName, "'-p'", password, "'-w'", "'" + basedir + string(os.PathSeparator) + workdirName + "'"} - err := internalRunSetdbparmsCommand(log, "mqsisetdbparms", args) - if err != nil { - return err - } - } - return nil -} - -func unmarshalJdbcAccounts(accounts []AccountInfo) []JdbcAccountInfo { - - jdbcAccountsInfo := make([]JdbcAccountInfo, len(accounts)) - - for i, accountInfo := range accounts { - jdbcAccountsInfo[i].Name = accountInfo.Name - json.Unmarshal(accountInfo.Credentials, &jdbcAccountsInfo[i].Credentials) - - } - - return jdbcAccountsInfo -} - -var buildJDBCPolicies = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - var supportedDBs = map[string]string{ - "IBM Db2 Linux, UNIX, or Windows (LUW) - client managed": "db2luw", - "IBM Db2 Linux, UNIX, or Windows (LUW) - IBM Cloud": "db2cloud", - "IBM Db2 for i": "db2i", - "Oracle": "oracle", - "PostgreSQL": "postgresql", - "Microsoft SQL Server": "sqlserver", - } - - policyDirName := basedir + string(os.PathSeparator) + workdirName + string(os.PathSeparator) + "overrides" + string(os.PathSeparator) + "gen.jdbcConnectorPolicies" - log.Printf("#buildJDBCPolicies: jdbc policy directory %v\n", policyDirName) - - policyNameSuffix := ".policyxml" - - policyxmlDescriptor := ` - - - ` - - policyTemplate := ` - - - {{{dbName}}} - {{{dbType}}} - - {{{jdbcClassName}}} - {{{jdbcType4DataSourceName}}} - {{{jdbcURL}}} - - - - - - {{{hostname}}} - {{{port}}} - - useProvidedSchemaNames - - {{{maxPoolSize}}} - {{{securityIdentity}}} - - false - true - - -` - - if _, err := osStat(policyDirName); osIsNotExist(err) { - log.Printf("#buildJDBCPolicies: %v does not exist, creating afresh..", policyDirName) - err := osMkdirAll(policyDirName, os.ModePerm) - if err != nil { - return err - } - } else { - log.Printf("#buildJDBCPolicies: %v already exists", policyDirName) - } - - for _, accountContent := range jdbcAccounts { - log.Printf("#buildJDBCPolicies: building policy for account : \"%v\"", accountContent.Name) - jdbcAccountInfo := accountContent.Credentials - - dbType := convertToString(jdbcAccountInfo.DbType) - hostName := convertToString(jdbcAccountInfo.Hostname) - dbPort := convertToString(jdbcAccountInfo.Port) - dbName := convertToString(jdbcAccountInfo.DbName) - userName := convertToString(jdbcAccountInfo.Username) - password := convertToString(jdbcAccountInfo.Password) - additionalParams := convertToString(jdbcAccountInfo.AdditonalParams) - - if len(hostName) == 0 || len(dbPort) == 0 || len(dbName) == 0 || len(userName) == 0 || len(password) == 0 { - log.Printf("#buildJDBCPolicies: skipping building policy for account - %v as one of the required fields found empty\n", accountContent.Name) - continue - } - - rawText := hostName + ":" + dbPort + ":" + dbName + ":" + userName - hash := sha256.New() - hash.Write([]byte(rawText)) - uuid := hex.EncodeToString(hash.Sum(nil)) - - databaseType := supportedDBs[dbType] - - policyAttributes, err := getJDBCPolicyAttributes(log, databaseType, hostName, dbPort, dbName, additionalParams) - if err != nil { - log.Printf("#buildJDBCPolicies: getJDBCPolicyAttributes returned an error - %v", err) - return err - } - - policyName := databaseType + "-" + uuid - context := map[string]interface{}{ - "policyName": policyName, - "dbName": dbName, - "dbType": databaseType, - "jdbcClassName": policyAttributes["jdbcClassName"], - "jdbcType4DataSourceName": policyAttributes["jdbcType4DataSourceName"], - "jdbcURL": policyAttributes["jdbcURL"], - "hostname": hostName, - "port": convertToNumber(jdbcAccountInfo.Port), - "maxPoolSize": convertToNumber(jdbcAccountInfo.MaxPoolSize), - "securityIdentity": uuid, - } - - result, err := transformXMLTemplate(string(policyTemplate), context) - if err != nil { - log.Printf("#buildJDBCPolicies: failed to transform policy xml - %v", err) - return err - } - - policyFileName := policyName + policyNameSuffix - - err = ioutilWriteFile(policyDirName+string(os.PathSeparator)+policyFileName, []byte(result), os.ModePerm) - if err != nil { - log.Printf("#buildJDBCPolicies: failed to write to the policy file %v - %v", policyFileName, err) - return err - } - } - - err := ioutilWriteFile(policyDirName+string(os.PathSeparator)+"policy.descriptor", []byte(policyxmlDescriptor), os.ModePerm) - if err != nil { - log.Printf("#buildJDBCPolicies: failed to write to the policy.descriptor - %v", err) - return err - } - return nil -} - -func getJDBCPolicyAttributes(log logger.LoggerInterface, dbType, hostname, port, dbName, additonalParams string) (map[string]string, error) { - - var policyAttributes = make(map[string]string) - var classNames = map[string]string{ - "DB2NativeDriverClassName": "com.ibm.db2.jcc.DB2Driver", - "DB2NativeDataSourceClassName": "com.ibm.db2.jcc.DB2XADataSource", - "DB2DriverClassName": "com.ibm.appconnect.jdbc.db2.DB2Driver", - "DB2DataSourceClassName": "com.ibm.appconnect.jdbcx.db2.DB2DataSource", - "OracleDriverClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "OracleDataSourceClassName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "MySQLDriverClassName": "com.ibm.appconnect.jdbc.mysql.MySQLDriver", - "MySQLDataSourceClassName": "com.ibm.appconnect.jdbcx.mysql.MySQLDataSource", - "SqlServerDriverClassName": "com.ibm.appconnect.jdbc.sqlserver.SQLServerDriver", - "SqlServerDataSourceClassName": "com.ibm.appconnect.jdbcx.sqlserver.SQLServerDataSource", - "PostgresDriveClassName": "com.ibm.appconnect.jdbc.postgresql.PostgreSQLDriver", - "PostgresDataSourceClassName": "com.ibm.appconnect.jdbcx.postgresql.PostgreSQLDataSource", - "HiveDriverClassName": "com.ibm.appconnect.jdbc.hive.HiveDriver", - "HiveDataSourceClassName": "com.ibm.appconnect.jdbcx.hive.HiveDataSource", - } - - var jdbcURL, jdbcClassName, jdbcType4DataSourceName string - var endDemiliter = "" - - var err error - switch dbType { - case "db2luw", "db2cloud": - jdbcURL = "jdbc:db2://" + hostname + ":" + port + "/" + dbName + ":user=[user];password=[password]" - jdbcClassName = classNames["DB2NativeDriverClassName"] - jdbcType4DataSourceName = classNames["DB2NativeDataSourceClassName"] - endDemiliter = ";" - case "db2i": - jdbcURL = "jdbc:ibmappconnect:db2://" + hostname + ":" + port + ";DatabaseName=" + dbName + ";user=[user];password=[password]" - jdbcClassName = classNames["DB2DriverClassName"] - jdbcType4DataSourceName = classNames["DB2DataSourceClassName"] - case "oracle": - jdbcURL = "jdbc:ibmappconnect:oracle://" + hostname + ":" + port + ";user=[user];password=[password]" - - if !strings.Contains(strings.ToLower(additonalParams), "servicename=") && !strings.Contains(strings.ToLower(additonalParams), "sid=") { - jdbcURL = jdbcURL + ";DatabaseName=" + dbName - } - - if !strings.Contains(strings.ToLower(additonalParams), "fetchdateastimestamp=") { - jdbcURL = jdbcURL + ";FetchDateAsTimestamp=false" - } - - jdbcClassName = classNames["OracleDriverClassName"] - jdbcType4DataSourceName = classNames["OracleDataSourceClassName"] - case "sqlserver": - jdbcURL = "jdbc:ibmappconnect:sqlserver://" + hostname + ":" + port + ";DatabaseName=" + dbName + ";user=[user];password=[password]" - - if !strings.Contains(strings.ToLower(additonalParams), "authenticationmethod=") { - jdbcURL = jdbcURL + ";AuthenticationMethod=userIdPassword" - } - - jdbcClassName = classNames["SqlServerDriverClassName"] - jdbcType4DataSourceName = classNames["SqlServerDataSourceClassName"] - case "postgresql": - jdbcURL = "jdbc:ibmappconnect:postgresql://" + hostname + ":" + port + ";DatabaseName=" + dbName + ";user=[user];password=[password]" - jdbcClassName = classNames["PostgresDriveClassName"] - jdbcType4DataSourceName = classNames["PostgresDataSourceClassName"] - default: - err = errors.New("Unsupported database type: " + dbType) - return nil, err - } - - // default timeout - if !strings.Contains(strings.ToLower(additonalParams), "logintimeout=") { - jdbcURL = jdbcURL + ";loginTimeout=40" - } - - if additonalParams != "" { - jdbcURL = jdbcURL + ";" + additonalParams - } - - if endDemiliter != "" { - jdbcURL += endDemiliter - } - - policyAttributes["jdbcURL"] = jdbcURL - policyAttributes["jdbcClassName"] = jdbcClassName - policyAttributes["jdbcType4DataSourceName"] = jdbcType4DataSourceName - return policyAttributes, err -} - -var processMQConnectorAccountsImpl = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - - mqAccounts := unmarshalMQAccounts(accounts) - - designerAuthMode, ok := os.LookupEnv("DEVELOPMENT_MODE") - - isDesignerAuthoringMode := false - if ok && designerAuthMode == "true" { - isDesignerAuthoringMode = true - } - - for _, mqAccount := range mqAccounts { - log.Printf("MQ account %v Q Manager %v", mqAccount.Name, mqAccount.Credentials.QueueManager) - err := processMqAccount(log, basedir, mqAccount, isDesignerAuthoringMode) - if err != nil { - log.Printf("#SetupTechConnectorsConfigurations encountered an error while processing mq account %v\n", err) - return err - } - } - - return nil -} - -var unmarshalMQAccounts = func(accounts []AccountInfo) []MQAccountInfo { - - mqAccountsInfo := make([]MQAccountInfo, len(accounts)) - - for i, accountInfo := range accounts { - mqAccountsInfo[i].Name = accountInfo.Name - json.Unmarshal(accountInfo.Credentials, &mqAccountsInfo[i].Credentials) - - } - - return mqAccountsInfo -} - -var processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - err := createMqAccountDbParams(log, baseDir, mqAccount) - - if err != nil { - log.Println("#processMQAccounts create db params failed") - return err - } - - err = importMqAccountCertificates(log, mqAccount) - - if err != nil { - log.Printf("Importing of certificates failed for %v", mqAccount.Name) - return err - } - - if isDesignerAuthoringMode { - return nil - } - - err = createMQPolicy(log, baseDir, mqAccount) - if err != nil { - log.Println("#processMQAccounts build mq policies failed") - return err - } - - err = createMQFlowBarOverridesProperties(log, baseDir, mqAccount) - - if err != nil { - log.Println("#processMQAccounts create mq flow bar overrides failed") - return err - } - - return nil -} - -func getMQAccountSHA(mqAccountInfo *MQAccountInfo) string { - mqCredentials := mqAccountInfo.Credentials - shaInputRawText := mqCredentials.Hostname + ":" + convertToString(mqCredentials.Port) + ":" + mqCredentials.QueueManager + ":" + mqCredentials.Username + ":" + mqCredentials.ChannelName - hash := sha256.New() - hash.Write([]byte(shaInputRawText)) - uuid := hex.EncodeToString(hash.Sum(nil)) - return uuid -} - -var createMQPolicy = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - - policyDirName := basedir + string(os.PathSeparator) + workdirName + string(os.PathSeparator) + "overrides" + string(os.PathSeparator) + "gen.MQPolicies" - log.Printf("#buildMQPolicyies: mq policy directory %v\n", policyDirName) - - policyNameSuffix := ".policyxml" - - policyxmlDescriptor := ` - - - ` - - policyxmlTemplate := ` - - - CLIENT - {{{queueManager}}} - {{{hostName}}} - {{{port}}} - {{{channelName}}} - {{{securityIdentity}}} - {{useSSL}} - {{sslPeerName}} - {{sslCipherSpec}} - {{sslCertificateLabel}} - - -` - - if _, err := osStat(policyDirName); osIsNotExist(err) { - log.Printf("#createMQPolicy: %v does not exist, creating afresh..", policyDirName) - err := osMkdirAll(policyDirName, os.ModePerm) - if err != nil { - return err - } - } else { - log.Printf("#createMQPolicy: %v already exists", policyDirName) - } - - log.Printf("#createMQPolicy: building policy for account : \"%v\"", mqAccount.Name) - - specialCharsRegEx, err := regexp.Compile("[^a-zA-Z0-9]") - mqAccountName := convertToString(mqAccount.Name) - - if err != nil { - log.Printf("#createMQPolicy: Failed to compile regex") - return err - } - - policyName := specialCharsRegEx.ReplaceAllString(mqAccountName, "_") - - securityIdentity := "" - - if mqAccount.Credentials.Username == "" && mqAccount.Credentials.Password == "" { - log.Println("#createMQPolicy - setting security identity empty") - } else { - securityIdentity = "gen_" + getMQAccountSHA(&mqAccount) - } - - useSSL := mqAccount.Credentials.CipherSpec != "" - - context := map[string]interface{}{ - "policyName": policyName, - "queueManager": mqAccount.Credentials.QueueManager, - "hostName": mqAccount.Credentials.Hostname, - "port": mqAccount.Credentials.Port, - "channelName": mqAccount.Credentials.ChannelName, - "securityIdentity": securityIdentity, - "useSSL": useSSL, - "sslPeerName": mqAccount.Credentials.PeerName, - "sslCipherSpec": mqAccount.Credentials.CipherSpec, - "sslCertificateLabel": mqAccount.Credentials.ClientCertificateLabel, - } - - result, err := transformXMLTemplate(string(policyxmlTemplate), context) - if err != nil { - log.Printf("#createMQPolicy: transformXmlTemplate failed with an error - %v", err) - return err - } - - policyFileName := policyName + policyNameSuffix - - err = ioutilWriteFile(policyDirName+string(os.PathSeparator)+policyFileName, []byte(result), os.ModePerm) - if err != nil { - log.Printf("#createMQPolicy: failed to write to the policy file %v - %v", policyFileName, err) - return err - } - - err = ioutilWriteFile(policyDirName+string(os.PathSeparator)+"policy.descriptor", []byte(policyxmlDescriptor), os.ModePerm) - if err != nil { - log.Printf("#createMQPolicy: failed to write to the policy.descriptor - %v", err) - return err - } - return nil -} - -var createMqAccountDbParams = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - - if mqAccount.Credentials.Username == "" && mqAccount.Credentials.Password == "" { - log.Println("#createMqAccountDbParams - skipping setdbparams empty credentials") - return nil - } - - log.Printf("#createMqAccountDbParams: setdbparams for account - %v\n", mqAccount.Name) - - securityIdentityName := "gen_" + getMQAccountSHA(&mqAccount) - args := []string{"'-n'", "mq::" + securityIdentityName, "'-u'", "'" + mqAccount.Credentials.Username + "'", "'-p'", "'" + mqAccount.Credentials.Password + "'", "'-w'", "'" + basedir + string(os.PathSeparator) + workdirName + "'"} - err := internalRunSetdbparmsCommand(log, "mqsisetdbparms", args) - if err != nil { - return err - } - - return nil -} - -var createMQFlowBarOverridesProperties = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - log.Println("#createMQFlowBarOverridesProperties: Execute mqapplybaroverride command") - - barOverridesConfigDir := "/home/aceuser/initial-config/workdir_overrides" - - if _, err := osStat(barOverridesConfigDir); osIsNotExist(err) { - err = osMkdirAll(barOverridesConfigDir, os.ModePerm) - if err != nil { - log.Printf("#createMQFlowBarOverridesProperties Failed to create workdir_overrides folder %v", err) - return err - } - } - - specialCharsRegEx, err := regexp.Compile("[^a-zA-Z0-9]") - - if err != nil { - log.Printf("#createMQFlowBarOverridesProperties failed to compile regex") - return err - } - - barPropertiesFileContent := "" - - log.Printf("#createMQFlowBarOverridesProperties: setting up config for account - %v\n", mqAccount.Name) - - mqAccountName := convertToString(mqAccount.Name) - plainAccountName := specialCharsRegEx.ReplaceAllString(mqAccountName, "_") - accountFlowName := "gen.mq_" + plainAccountName - accountSha := getMQAccountSHA(&mqAccount) - accountIDUdfProperty := accountFlowName + "#mqRuntimeAccountId=" + plainAccountName + "~" + accountSha - - barPropertiesFileContent += accountIDUdfProperty + "\n" - - barPropertiesFilePath := "/home/aceuser/initial-config/workdir_overrides/mqconnectorbarfile.properties" - err = internalAppendFile(barPropertiesFilePath, []byte(barPropertiesFileContent), 0644) - - if err != nil { - log.Println("#createMQFlowBarOverridesProperties failed to append to barfile.properties") - return err - } - - return nil -} - -var transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - tpl, err := raymondParse(string(xmlTemplate)) - if err != nil { - log.Printf("#createMQPolicy: failed to parse the template - %v", err) - return "", err - } - - result, err := tpl.Exec(context) - if err != nil { - log.Printf("#createMQPolicy: rendering failed with an error - %v", err) - return "", err - } - - return result, nil -} - -func setupMqAccountsKdbFileImpl(log logger.LoggerInterface) error { - - serverconfMap := make(map[interface{}]interface{}) - - serverConfContents, err := readServerConfFile() - - updateServConf := true - - if err != nil { - log.Println("server.conf.yaml not found, proceeding with creating one") - } else { - - unmarshallError := yamlv2.Unmarshal(serverConfContents, &serverconfMap) - - if unmarshallError != nil { - log.Errorf("Error unmarshalling server.conf.yaml: %v", unmarshallError) - return unmarshallError - } - } - - if serverconfMap["BrokerRegistry"] == nil { - serverconfMap["BrokerRegistry"] = map[string]interface{}{ - "mqKeyRepository": strings.TrimSuffix(getMqAccountsKdbPath(), ".kdb"), - } - } else { - brokerRegistry := serverconfMap["BrokerRegistry"].(map[interface{}]interface{}) - - if brokerRegistry["mqKeyRepository"] == nil { - log.Println("Adding mqKeyRepository to server.conf.yml") - brokerRegistry["mqKeyRepository"] = strings.TrimSuffix(getMqAccountsKdbPath(), ".kdb") - } else { - log.Printf("An existing mq key repository already found in server.conf %v", brokerRegistry["mqKeyRepository"]) - updateServConf = false - } - } - - kdbError := createMqAccountsKdbFile(log) - - if kdbError != nil { - log.Errorf("Error while creating mq accounts kdb file %v\n", kdbError) - return kdbError - } - - serverconfYaml, marshallError := yamlv2.Marshal(&serverconfMap) - - if marshallError != nil { - log.Errorf("Error marshalling server.conf.yaml: %v", marshallError) - return marshallError - } - - if updateServConf { - err = writeServerConfFile(serverconfYaml) - - if err != nil { - log.Errorf("Error while writingg server.conf", err) - return err - } - } - - return nil -} - -var importMqAccountCertificatesImpl = func(log logger.LoggerInterface, mqAccount MQAccountInfo) error { - - tempDir := filepath.FromSlash("/tmp/mqssl-work") - - serverCertPem := filepath.FromSlash("/tmp/mqssl-work/servercrt.pem") - clientCertPem := filepath.FromSlash("/tmp/mqssl-work/clientcrt.pem") - clientCertP12 := filepath.FromSlash("/tmp/mqssl-work/clientcrt.p12") - - var cleanUp = func() { - osRemoveAll(tempDir) - } - - defer cleanUp() - - mkdirErr := osMkdirAll(tempDir, os.ModePerm) - - if mkdirErr != nil { - return fmt.Errorf("Failed to create mp dir to import certificates,Error: %v", mkdirErr.Error()) - } - - if mqAccount.Credentials.ServerCertificate != "" { - serverPem, err := convertMqAccountSingleLinePEM(mqAccount.Credentials.ServerCertificate) - if err != nil { - log.Errorf("An error while creating server certificate PEM for %v, error: %v", mqAccount.Name, err) - return err - } - err = ioutilWriteFile(serverCertPem, []byte(serverPem), os.ModePerm) - - if err != nil { - log.Errorf("An error while saving server certificate pem for %v, error: %v", mqAccount.Name, err) - return err - } - - err = importServerCertificate(log, serverCertPem) - - if err != nil { - log.Errorf("An error while converting server certificate PEM for %v, error: %v", mqAccount.Name, err.Error()) - return err - } - - log.Printf("Imported server certificate for %v", mqAccount.Name) - } - - if mqAccount.Credentials.ClientCertificate != "" { - - if mqAccount.Credentials.ClientCertificateLabel == "" { - return fmt.Errorf("Certificate label should not be empty for %v", mqAccount.Name) - } - - clientPem, err := convertMqAccountSingleLinePEM(mqAccount.Credentials.ClientCertificate) - if err != nil { - log.Errorf("An error while converting client certificate PEM for %v, error: %v", mqAccount.Name, err) - return err - } - - err = ioutilWriteFile(clientCertPem, []byte(clientPem), os.ModePerm) - - if err != nil { - log.Errorf("An error while saving pem client certificate pem for %v, error: %v", mqAccount.Name, err) - return err - } - - p12Pass := randomString(10) - - err = createPkcs12(log, clientCertP12, p12Pass, clientCertPem, mqAccount.Credentials.ClientCertificatePassword, mqAccount.Credentials.ClientCertificateLabel) - - if err != nil { - log.Errorf("An error while creating P12 of %v %v", mqAccount.Name, err) - return err - } - - err = importP12(log, clientCertP12, p12Pass, mqAccount.Credentials.ClientCertificateLabel) - - if err != nil { - log.Errorf("An error while importing P12 of %v %v", mqAccount.Name, err) - return err - } - - log.Printf("Imported client certificate for %v", mqAccount.Name) - - } - - return nil -} - -// readServerConfFile returns the content of the server.conf.yaml file in the overrides folder -func readServerConfFile() ([]byte, error) { - content, err := ioutilReadFile("/home/aceuser/ace-server/overrides/server.conf.yaml") - return content, err -} - -// writeServerConfFile writes the yaml content to the server.conf.yaml file in the overrides folder -// It creates the file if it doesn't already exist -func writeServerConfFile(content []byte) error { - return ioutilWriteFile("/home/aceuser/ace-server/overrides/server.conf.yaml", content, 0644) -} - -func createMqAccountsKdbFileImpl(log logger.LoggerInterface) error { - - mkdirError := osMkdirAll(filepath.FromSlash("/home/aceuser/kdb"), os.ModePerm) - - if mkdirError != nil { - return fmt.Errorf("Failed to create directory to create kdb file, Error %v", mkdirError.Error()) - } - - kdbPass := randomString(10) - - createKdbArgs := []string{"-keydb", "-create", "-type", "cms", "-db", getMqAccountsKdbPath(), "-pw", kdbPass} - err := runMqakmCommand(log, createKdbArgs) - if err != nil { - return fmt.Errorf("Create kdb failed, Error %v ", err.Error()) - } - - createSthArgs := []string{"-keydb", "-stashpw", "-type", "cms", "-db", getMqAccountsKdbPath(), "-pw", kdbPass} - err = runMqakmCommand(log, createSthArgs) - if err != nil { - return fmt.Errorf("Create stash file failed, Error %v", err.Error()) - } - - return nil - -} - -func importServerCertificate(log logger.LoggerInterface, pemFilePath string) error { - - cmdArgs := []string{"-cert", "-add", "-db", getMqAccountsKdbPath(), "-stashed", "-file", pemFilePath} - return runMqakmCommand(log, cmdArgs) -} - -func importP12(log logger.LoggerInterface, p12File string, p12Password string, certLabel string) error { - runMqakmCmdArgs := []string{"-cert", "-import", "-type", "p12", "-file", p12File, "-pw", p12Password, "-target_type", "cms", "-target", getMqAccountsKdbPath(), "-target_stashed"} - - if certLabel != "" { - runMqakmCmdArgs = append(runMqakmCmdArgs, "-new_label") - runMqakmCmdArgs = append(runMqakmCmdArgs, certLabel) - } - - return runMqakmCommand(log, runMqakmCmdArgs) -} - -func createPkcs12(log logger.LoggerInterface, p12OutFile string, p12Password string, pemFilePath string, pemPassword string, certLabel string) error { - openSslCmdArgs := []string{"pkcs12", "-export", "-out", p12OutFile, "-passout", "pass:" + p12Password, "-in", pemFilePath} - - if pemPassword != "" { - openSslCmdArgs = append(openSslCmdArgs, "-passin") - openSslCmdArgs = append(openSslCmdArgs, "pass:"+pemPassword) - } - - return runOpenSslCommand(log, openSslCmdArgs) -} - -func runOpenSslCommandImpl(log logger.LoggerInterface, cmdArgs []string) error { - return runCommand(log, "openssl", cmdArgs) -} - -func runMqakmCommandImpl(log logger.LoggerInterface, cmdArgs []string) error { - return runCommand(log, "runmqakm", cmdArgs) -} - -func getMqAccountsKdbPath() string { - return filepath.FromSlash(`/home/aceuser/kdb/mq.kdb`) -} - -func convertMQAccountSingleLinePEMImpl(singleLinePem string) (string, error) { - pemRegExp, err := regexp.Compile(`(?m)-----BEGIN (.*?)-----\s(.*?)-----END (.*?)-----\s?`) - if err != nil { - return "", err - } - - var pemContent strings.Builder - - matches := pemRegExp.FindAllStringSubmatch(singleLinePem, -1) - - if matches == nil { - return "", errors.New("PEM is not in expected format") - } - - for _, subMatches := range matches { - - if len(subMatches) != 4 { - return "", fmt.Errorf("PEM is not in expected format, found %v", len(subMatches)) - } - - pemContent.WriteString(fmt.Sprintf("-----BEGIN %v-----\n", subMatches[1])) - pemContent.WriteString(strings.ReplaceAll(subMatches[2], " ", "\n")) - pemContent.WriteString(fmt.Sprintf("-----END %v-----\n", subMatches[3])) - } - - return pemContent.String(), nil - -} - -func randomString(n int) string { - var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") - - s := make([]rune, n) - for i := range s { - s[i] = letters[rand.Intn(len(letters))] - } - return string(s) -} diff --git a/internal/configuration/techConnectorsConfiguration_test.go b/internal/configuration/techConnectorsConfiguration_test.go deleted file mode 100644 index 0aa64d1..0000000 --- a/internal/configuration/techConnectorsConfiguration_test.go +++ /dev/null @@ -1,2018 +0,0 @@ -package configuration - -import ( - "encoding/json" - "errors" - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/ot4i/ace-docker/common/logger" -) - -var processMqAccountRestore = processMqAccount -var processMqConnectorAccountsRestore = processMqConnectorAccounts -var processJdbcConnectorAccountsRestore = processJdbcConnectorAccounts -var mqAccount1Sha = "21659a449a678a235f7c14b8d8a196feedc0691124556624e57f2de60b5729d9" -var jdbcAccount1Sha = "569be438050b9875e183d092b133fa55e0ea57cfcdabe566c2d5613ab8492d50" -var runMqakmCommandRestore = runMqakmCommand -var runOpenSslCommandRestore = runOpenSslCommand -var createMqAccountsKdbFileRestore = createMqAccountsKdbFile - -func TestSetupTechConnectorsConfigurations(t *testing.T) { - - var reset = func() { - processMqAccount = func(log logger.LoggerInterface, basedir string, account MQAccountInfo, isDesignerAuthoringMode bool) error { - panic("should be mocked") - } - - processMqConnectorAccounts = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - panic("should be mocked") - } - - processJdbcConnectorAccounts = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - panic("should be mocked") - } - - setupMqAccountsKdbFile = func(log logger.LoggerInterface) error { - panic("should be mocked") - } - - runOpenSslCommand = func(log logger.LoggerInterface, params []string) error { - panic("should be mocked") - } - } - - var restore = func() { - processMqAccount = processMqAccountRestore - processMqConnectorAccounts = processMqConnectorAccountsRestore - processJdbcConnectorAccounts = processJdbcConnectorAccountsRestore - setupMqAccountsKdbFile = setupMqAccountsKdbFileRestore - runMqakmCommand = runMqakmCommandRestore - runOpenSslCommand = runOpenSslCommandRestore - setupMqAccountsKdbFile = setupMqAccountsKdbFileRestore - createMqAccountsKdbFile = createMqAccountsKdbFileRestore - } - - var accountsYaml = ` -accounts: - mq: - - name: mq-account-1 - endpoint: {} - credentials: - authType: BASIC - queueManager: QM1 - hostname: localhost1 - port: 123 - username: abc - password: xyz - channelName: CH.1 - applicationType: online - applicationVersion: v1 - authType: BASIC - default: true -` - - t.Run("Setups mq kdb file before processing accounts", func(t *testing.T) { - - reset() - defer restore() - - t.Run("Returns error if setupMqaccounts failed", func(t *testing.T) { - - setupMqAccountsError := errors.New("set up mq accounts kdb failed") - setupMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return setupMqAccountsError - } - - err := SetupTechConnectorsConfigurations(testLogger, testBaseDir, []byte(accountsYaml)) - - assert.Error(t, err) - }) - - t.Run("when setupMqaccounts succeeded,process accounts ", func(t *testing.T) { - - setupMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return nil - } - - t.Run("when accounts.yml contains mq accounts, process all mq accounts", func(t *testing.T) { - - processMqConnectorAccounts = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - assert.NotNil(t, accounts) - assert.Equal(t, 1, len(accounts)) - assert.Equal(t, "mq-account-1", accounts[0].Name) - assert.NotNil(t, accounts[0].Credentials) - - return nil - } - - err := SetupTechConnectorsConfigurations(testLogger, testBaseDir, []byte(accountsYaml)) - - assert.Nil(t, err) - }) - - t.Run("when converting accounts.yml to json failed, returns nil ", func(t *testing.T) { - - var invalidYaml = ` -accounts: - mq: - - name: test1 - invalid-entry: abc` - - err := SetupTechConnectorsConfigurations(testLogger, testBaseDir, []byte(invalidYaml)) - - assert.Nil(t, err) - }) - - t.Run("when accounts yaml contains both jdbc and mq accounts, processes both mq and jdbc account", func(t *testing.T) { - var accountsYaml = ` -accounts: - jdbc: - - name: jdbc-account-a - endpoint: {} - credentials: - dbType: 'IBM Db2 Linux, UNIX, or Windows (LUW) - client managed' - dbName: testdb - hostname: dbhost - port: '50000' - username: user1 - password: pwd1 - applicationType: online - applicationVersion: v1 - authType: BASIC - default: true - mq: - - name: mq-account-b - endpoint: {} - credentials: - authType: BASIC - queueManager: QM1 - hostname: localhost1 - port: '123' - username: abc - password: xyz - channelName: CH.1 - applicationType: online - applicationVersion: v1 - authType: BASIC - default: true -` - - processJdbcConnectorAccounts = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - assert.NotNil(t, accounts) - assert.Equal(t, 1, len(accounts)) - assert.Equal(t, "jdbc-account-a", accounts[0].Name) - assert.NotNil(t, accounts[0].Credentials) - - return nil - } - - processMqConnectorAccounts = func(log logger.LoggerInterface, basedir string, accounts []AccountInfo) error { - assert.NotNil(t, accounts) - assert.Equal(t, 1, len(accounts)) - assert.Equal(t, "mq-account-b", accounts[0].Name) - assert.NotNil(t, accounts[0].Credentials) - - return nil - } - - err := SetupTechConnectorsConfigurations(testLogger, testBaseDir, []byte(accountsYaml)) - - assert.Nil(t, err) - }) - }) - }) -} - -func TestSetMqAccountsKdbFileTests(t *testing.T) { - - var reset = func() { - ioutilReadFile = func(file string) ([]byte, error) { - panic("should be mocked") - } - - createMqAccountsKdbFile = func(log logger.LoggerInterface) error { - panic("should be mocked") - } - - ioutilWriteFile = func(file string, content []byte, perm os.FileMode) error { - panic("should be mocked") - } - } - - var restore = func() { - ioutilWriteFile = ioutilWriteFileRestore - ioutilReadFile = ioutilReadFileRestore - createMqAccountsKdbFile = createMqAccountsKdbFileRestore - } - - reset() - defer restore() - - t.Run("when no server.conf.yaml not found, continues to create kdb file", func(t *testing.T) { - - serverConfFilePath := "/home/aceuser/ace-server/overrides/server.conf.yaml" - ioutilReadFile = func(file string) ([]byte, error) { - assert.Equal(t, serverConfFilePath, file) - return nil, errors.New("File not found") - } - - t.Run("Returns error if failed to create kdb file", func(t *testing.T) { - - createMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return errors.New("create mq accounts kdb failed") - } - - err := setupMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "create mq accounts kdb failed") - }) - }) - - t.Run("when no server.conf.yaml found, continues to create kdb", func(t *testing.T) { - - t.Run("does not update server.conf if it already has mq key repository", func(t *testing.T) { - serverConfContent := "BrokerRegistry:\n mqKeyRepository: /home/aceuser/somekdbfile" - - ioutilReadFile = func(file string) ([]byte, error) { - return []byte(serverConfContent), nil - } - - ioutilWriteFile = func(file string, content []byte, perm os.FileMode) error { - assert.Fail(t, "shouldn't update server conf ") - return nil - } - - setupMqAccountsKdbFile(testLogger) - }) - - t.Run("Returns error if failed to create kdb file when server conf doesnot contain mqKeyRepository", func(t *testing.T) { - - serverConfContent := "" - - ioutilReadFile = func(file string) ([]byte, error) { - return []byte(serverConfContent), nil - } - - createMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return errors.New("Failed to create kdb") - } - - err := setupMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "Failed to create kdb") - }) - }) - - t.Run("when create kdb succeeded, writes server conf yaml with mqKeyRepsitory", func(t *testing.T) { - - createMqAccountsKdbFile = func(log logger.LoggerInterface) error { - return nil - } - - t.Run("Return error when write to server.conf failed", func(t *testing.T) { - - ioutilWriteFile = func(file string, contents []byte, fileMode os.FileMode) error { - return errors.New("server.conf write failed") - } - - err := setupMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "server.conf write failed") - }) - - t.Run("Return nil when write server.conf failed succeeded", func(t *testing.T) { - - ioutilWriteFile = func(file string, contents []byte, fileMode os.FileMode) error { - serverConfContent := "BrokerRegistry:\n mqKeyRepository: /home/aceuser/kdb/mq\n" - serverConfFilePath := "/home/aceuser/ace-server/overrides/server.conf.yaml" - - assert.Equal(t, serverConfFilePath, file) - assert.Equal(t, serverConfContent, string(contents)) - assert.Equal(t, os.FileMode(0644), fileMode) - return nil - } - - err := setupMqAccountsKdbFile(testLogger) - - assert.Nil(t, err) - }) - }) -} - -func TestCreateMqAccountsKdbFileImpl(t *testing.T) { - - var reset = func() { - osMkdirAll = func(path string, filePerm os.FileMode) error { - panic("should be mocked") - } - runMqakmCommand = func(logger logger.LoggerInterface, cmdArgs []string) error { - panic("should be mocked") - } - } - - var restore = func() { - osMkdirAll = osMkdirAllRestore - runMqakmCommand = runMqakmCommandRestore - } - - reset() - defer restore() - - t.Run("creats directory mq-connector for kdb file", func(t *testing.T) { - - t.Run("Returns error if failed to create dir", func(t *testing.T) { - - osMkdirAll = func(path string, filePerm os.FileMode) error { - return errors.New("mkdir failed") - } - - err := createMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "Failed to create directory to create kdb file, Error mkdir failed") - - }) - - t.Run("when create dir succeeded, creates kdb file ", func(t *testing.T) { - - osMkdirAll = func(path string, filePerm os.FileMode) error { - dirPath := "/home/aceuser/kdb" - - assert.Equal(t, dirPath, path) - assert.Equal(t, os.ModePerm, filePerm) - - return nil - } - - t.Run("Returns error when runmqakam failed to create kdb", func(t *testing.T) { - runMqakmCommand = func(logger logger.LoggerInterface, cmdArgs []string) error { - - assert.Equal(t, "-keydb", cmdArgs[0]) - assert.Equal(t, "-create", cmdArgs[1]) - assert.Equal(t, "-type", cmdArgs[2]) - assert.Equal(t, "cms", cmdArgs[3]) - assert.Equal(t, "-db", cmdArgs[4]) - assert.Equal(t, "/home/aceuser/kdb/mq.kdb", cmdArgs[5]) - assert.Equal(t, "-pw", cmdArgs[6]) - assert.NotEmpty(t, cmdArgs[7]) - - return errors.New("runmqakam failed") - } - - err := createMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "Create kdb failed, Error runmqakam failed") - }) - - t.Run("when create kdb succeeded, creates stash file", func(t *testing.T) { - - t.Run("Returns error when create stash failed failed", func(t *testing.T) { - - runMqakmCommand = func(logger logger.LoggerInterface, cmdArgs []string) error { - if cmdArgs[1] == "-stashpw" { - assert.Equal(t, "-keydb", cmdArgs[0]) - assert.Equal(t, "-stashpw", cmdArgs[1]) - assert.Equal(t, "-type", cmdArgs[2]) - assert.Equal(t, "cms", cmdArgs[3]) - assert.Equal(t, "-db", cmdArgs[4]) - assert.Equal(t, "/home/aceuser/kdb/mq.kdb", cmdArgs[5]) - assert.Equal(t, "-pw", cmdArgs[6]) - assert.NotEmpty(t, cmdArgs[7]) - - return errors.New("create sth file failed") - } - - return nil - } - - err := createMqAccountsKdbFile(testLogger) - - assert.Error(t, err, "Create sth failed, Error runmqakam failed") - }) - - t.Run("Returns nil when creation of stash file succeeded", func(t *testing.T) { - - runMqakmCommand = func(logger logger.LoggerInterface, cmdArgs []string) error { - return nil - } - - err := createMqAccountsKdbFile(testLogger) - - assert.Nil(t, err) - }) - }) - }) - }) -} - -func TestProcessJdbcAccounts(t *testing.T) { - var setDSNForJDBCApplicationRestore = setDSNForJDBCApplication - var buildJDBCPoliciesRestore = buildJDBCPolicies - var reset = func() { - setDSNForJDBCApplication = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - panic("should be mocked") - } - - buildJDBCPolicies = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - panic("should be mocked") - } - } - - var restore = func() { - setDSNForJDBCApplication = setDSNForJDBCApplicationRestore - buildJDBCPolicies = buildJDBCPoliciesRestore - } - - accounts := []AccountInfo{ - { - Name: "acc 1", - Credentials: json.RawMessage(`{"authType":"BASIC","dbType":"Oracle","hostname":"abc","port":"123","Username":"user1","Password":"password1","dbName":"test"}`)}} - - unmarshalledJDBCAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "abc", - Port: "123", - Username: "user1", - Password: "password1", - DbName: "test"}}} - - reset() - defer restore() - - t.Run("Returns error when failed to setDSN for jdbc account", func(t *testing.T) { - - setDSNError := errors.New("set dsn failed") - setDSNForJDBCApplication = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - return setDSNError - } - - errorReturned := processJdbcConnectorAccounts(testLogger, testBaseDir, accounts) - - assert.Equal(t, setDSNError, errorReturned) - }) - - t.Run("When setDSN succeeded, build jdbc policies", func(t *testing.T) { - setDSNForJDBCApplication = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - assert.Equal(t, unmarshalledJDBCAccounts, jdbcAccounts) - - return nil - } - - t.Run("Returns error when buildJdbcPolicies failed", func(t *testing.T) { - - buildPolicyError := errors.New("set dsn failed") - buildJDBCPolicies = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - return buildPolicyError - } - - errorReturned := processJdbcConnectorAccounts(testLogger, testBaseDir, accounts) - - assert.Equal(t, buildPolicyError, errorReturned) - }) - - t.Run("Returns nil when build jdbcPolicies succeeded", func(t *testing.T) { - - buildJDBCPolicies = func(log logger.LoggerInterface, basedir string, jdbcAccounts []JdbcAccountInfo) error { - assert.Equal(t, unmarshalledJDBCAccounts, jdbcAccounts) - return nil - } - - errorReturned := processJdbcConnectorAccounts(testLogger, testBaseDir, accounts) - - assert.Nil(t, errorReturned) - }) - }) - -} - -func TestSetDSNForJDBCApplication(t *testing.T) { - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "abc", - Port: "123", - Username: "user1", - Password: "password1", - DbName: "test"}}} - - var internalRunSetdbparmsCommandRestore = internalRunSetdbparmsCommand - var reset = func() { - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - panic("should be mocked") - } - } - - var restore = func() { - internalRunSetdbparmsCommand = internalRunSetdbparmsCommandRestore - } - - reset() - defer restore() - - t.Run("invokes mqsisetdbparmas command with resource name which is sha of account", func(t *testing.T) { - - resourceName := "jdbc::" + jdbcAccount1Sha - workdir := "'" + testBaseDir + string(os.PathSeparator) + workdirName + "'" - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, "mqsisetdbparms", command) - assert.Equal(t, []string{"'-n'", resourceName, "'-u'", jdbAccounts[0].Credentials.Username.(string), "'-p'", jdbAccounts[0].Credentials.Password.(string), "'-w'", workdir}, params) - return nil - } - - setDSNForJDBCApplication(testLogger, testBaseDir, jdbAccounts) - - }) - - t.Run("when mqsisetdbparmas command failed returns error", func(t *testing.T) { - - err := errors.New("run setdb params failed") - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - return err - } - - errReturned := setDSNForJDBCApplication(testLogger, testBaseDir, jdbAccounts) - - assert.Equal(t, err, errReturned) - }) - - t.Run("when mqsisetdbparmas command succeeds returns nil", func(t *testing.T) { - - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - return nil - } - - errReturned := setDSNForJDBCApplication(testLogger, testBaseDir, jdbAccounts) - - assert.Nil(t, errReturned) - }) -} - -func TestBuildJDBCPolicies(t *testing.T) { - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "abc", - Port: "123", - Username: "user1", - Password: "password1", - DbName: "test"}}} - - var osStatRestore = osStat - var osIsNotExistRestore = osIsNotExist - var osMkdirAllRestore = osMkdirAll - var transformXMLTemplateRestore = transformXMLTemplate - var ioutilWriteFileRestore = ioutilWriteFile - - var reset = func() { - osStat = func(dirName string) (os.FileInfo, error) { - panic("should be mocked") - } - osIsNotExist = func(err error) bool { - panic("should be mocked") - } - - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - panic("should be mocked") - } - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - panic("should be mocked") - } - - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - panic("should be mocked") - } - } - - var restore = func() { - osStat = osStatRestore - osIsNotExist = osIsNotExistRestore - osMkdirAll = osMkdirAllRestore - transformXMLTemplate = transformXMLTemplateRestore - ioutilWriteFile = ioutilWriteFileRestore - } - - policyDirName := testBaseDir + string(os.PathSeparator) + workdirName + string(os.PathSeparator) + "overrides" + string(os.PathSeparator) + "gen.jdbcConnectorPolicies" - - reset() - defer restore() - - t.Run("Returns error when failed to create 'gen.jdbcConnectorPolicies' directory if not exists", func(t *testing.T) { - - osStatError := errors.New("osStat failed") - - osStat = func(dirName string) (os.FileInfo, error) { - assert.Equal(t, policyDirName, dirName) - return nil, osStatError - } - - osIsNotExist = func(err error) bool { - assert.Equal(t, osStatError, err) - return true - } - - osMakeDirError := errors.New("os make dir error failed") - osMkdirAll = func(dirPath string, perm os.FileMode) error { - assert.Equal(t, policyDirName, dirPath) - assert.Equal(t, os.ModePerm, perm) - return osMakeDirError - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - - assert.Equal(t, osMakeDirError, errorReturned) - - t.Run("When creation of 'gen.jdbcConnectorPolicies' succeeds, transforms policy xml template", func(t *testing.T) { - - osMkdirAll = func(dirPath string, perm os.FileMode) error { - assert.Equal(t, policyDirName, dirPath) - assert.Equal(t, os.ModePerm, perm) - return nil - } - - t.Run("Returns error when failed to transform policy xml template", func(t *testing.T) { - - transformError := errors.New("transform xml template failed") - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - return "", transformError - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Equal(t, transformError, errorReturned) - }) - - t.Run("when transform xml template succeeds, writes transforrmed policy xml in 'gen.MQPolicies' dir with the file name of account name", func(t *testing.T) { - - trasformedXML := "abc" - policyName := "oracle-" + jdbcAccount1Sha - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": policyName, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "oracle", - "jdbcClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "jdbcURL": "jdbc:ibmappconnect:oracle://abc:123;user=[user];password=[password];DatabaseName=test;FetchDateAsTimestamp=false;loginTimeout=40", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": jdbcAccount1Sha, - }, context) - - return trasformedXML, nil - } - - t.Run("Returns error when failed to write to account name policy file", func(t *testing.T) { - - writeFileError := errors.New("write file failed") - policyFileNameForAccount1 := string(policyDirName + string(os.PathSeparator) + policyName + ".policyxml") - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - assert.Equal(t, policyFileNameForAccount1, filename) - assert.Equal(t, trasformedXML, string(data)) - assert.Equal(t, os.ModePerm, perm) - return writeFileError - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Equal(t, writeFileError, errorReturned) - }) - - t.Run("When write policyxml succeeds, writes policy descriptor", func(t *testing.T) { - - t.Run("Returns error when write policy descriptor failed", func(t *testing.T) { - - policyDescriptorWriteError := errors.New("policy descriptor write failed") - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - _, fileName := filepath.Split(filenameWithPath) - if fileName == "policy.descriptor" { - return policyDescriptorWriteError - } - - return nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Equal(t, policyDescriptorWriteError, errorReturned) - }) - - t.Run("Returns nil when write policy descriptor succeeeded", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - }) - - t.Run("When write policyxml succeeds for Oracle server account", func(t *testing.T) { - t.Run("Returns nil on success", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "oracle.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "jdbcBehaviour=1"}}} - - oracleAccountSha := "6a9b827dae7d8af68ec78086404cc9ec64b49da76da996887c2d65d6b9abb96e" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "oracle-" + oracleAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "oracle", - "jdbcClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "jdbcURL": "jdbc:ibmappconnect:oracle://oracle.com:1521;user=[user];password=[password];DatabaseName=test;FetchDateAsTimestamp=false;loginTimeout=40;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": oracleAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - - t.Run("Returns nil on success - overrides DatabaseName attribute with serviceName in the jdbcURL when found in additional params", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "oracle.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "serviceName=dummy;jdbcBehaviour=1"}}} - - oracleAccountSha := "6a9b827dae7d8af68ec78086404cc9ec64b49da76da996887c2d65d6b9abb96e" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "oracle-" + oracleAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "oracle", - "jdbcClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "jdbcURL": "jdbc:ibmappconnect:oracle://oracle.com:1521;user=[user];password=[password];FetchDateAsTimestamp=false;loginTimeout=40;serviceName=dummy;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": oracleAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - - t.Run("Returns nil on success - overrides DatabaseName attribute with sid in the jdbcURL when found in additional params", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "oracle.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "sid=dummy;jdbcBehaviour=1"}}} - - oracleAccountSha := "6a9b827dae7d8af68ec78086404cc9ec64b49da76da996887c2d65d6b9abb96e" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "oracle-" + oracleAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "oracle", - "jdbcClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "jdbcURL": "jdbc:ibmappconnect:oracle://oracle.com:1521;user=[user];password=[password];FetchDateAsTimestamp=false;loginTimeout=40;sid=dummy;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": oracleAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - - t.Run("Returns nil on success - overrides fetchdateastimestamp in the jdbcURL when found in additional params", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Oracle", - Hostname: "oracle.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "FetchDateAsTimestamp=true;jdbcBehaviour=1"}}} - - oracleAccountSha := "6a9b827dae7d8af68ec78086404cc9ec64b49da76da996887c2d65d6b9abb96e" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "oracle-" + oracleAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "oracle", - "jdbcClassName": "com.ibm.appconnect.jdbc.oracle.OracleDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.oracle.OracleDataSource", - "jdbcURL": "jdbc:ibmappconnect:oracle://oracle.com:1521;user=[user];password=[password];DatabaseName=test;loginTimeout=40;FetchDateAsTimestamp=true;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": oracleAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - }) - - t.Run("When write policyxml succeeds for SQL server account", func(t *testing.T) { - t.Run("Returns nil on success", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Microsoft SQL Server", - Hostname: "sqlserver.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "jdbcBehaviour=1"}}} - - sqlserverAccountSha := "4fcfc055979498885b02297e168978a1baccc8bce130dac5277fca7342a48cdf" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "sqlserver-" + sqlserverAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "sqlserver", - "jdbcClassName": "com.ibm.appconnect.jdbc.sqlserver.SQLServerDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.sqlserver.SQLServerDataSource", - "jdbcURL": "jdbc:ibmappconnect:sqlserver://sqlserver.com:1521;DatabaseName=test;user=[user];password=[password];AuthenticationMethod=userIdPassword;loginTimeout=40;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": sqlserverAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - - t.Run("Returns nil on success - override AuthenticationMethod in the jdbcURL", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Microsoft SQL Server", - Hostname: "sqlserver.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "AuthenticationMethod=ntlmjava;jdbcBehaviour=1"}}} - - sqlserverAccountSha := "4fcfc055979498885b02297e168978a1baccc8bce130dac5277fca7342a48cdf" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "sqlserver-" + sqlserverAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "sqlserver", - "jdbcClassName": "com.ibm.appconnect.jdbc.sqlserver.SQLServerDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.sqlserver.SQLServerDataSource", - "jdbcURL": "jdbc:ibmappconnect:sqlserver://sqlserver.com:1521;DatabaseName=test;user=[user];password=[password];loginTimeout=40;AuthenticationMethod=ntlmjava;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": sqlserverAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - - t.Run("Returns nil on success - override loginTimeout in the jdbcURL", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - jdbAccounts := []JdbcAccountInfo{{ - Name: "acc 1", - Credentials: JdbcCredentials{ - AuthType: "BASIC", - DbType: "Microsoft SQL Server", - Hostname: "sqlserver.com", - Port: "1521", - Username: "user1", - Password: "password1", - DbName: "test", - AdditonalParams: "loginTimeout=100;jdbcBehaviour=1"}}} - - sqlserverAccountSha := "4fcfc055979498885b02297e168978a1baccc8bce130dac5277fca7342a48cdf" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - - assert.Equal(t, map[string]interface{}{ - "policyName": "sqlserver-" + sqlserverAccountSha, - "dbName": jdbAccounts[0].Credentials.DbName, - "dbType": "sqlserver", - "jdbcClassName": "com.ibm.appconnect.jdbc.sqlserver.SQLServerDriver", - "jdbcType4DataSourceName": "com.ibm.appconnect.jdbcx.sqlserver.SQLServerDataSource", - "jdbcURL": "jdbc:ibmappconnect:sqlserver://sqlserver.com:1521;DatabaseName=test;user=[user];password=[password];AuthenticationMethod=userIdPassword;loginTimeout=100;jdbcBehaviour=1", - "hostname": jdbAccounts[0].Credentials.Hostname, - "port": convertToNumber(jdbAccounts[0].Credentials.Port), - "maxPoolSize": convertToNumber(jdbAccounts[0].Credentials.MaxPoolSize), - "securityIdentity": sqlserverAccountSha, - }, context) - - return trasformedXML, nil - } - - errorReturned := buildJDBCPolicies(testLogger, testBaseDir, jdbAccounts) - assert.Nil(t, errorReturned) - }) - }) - }) - }) - }) -} - -func TestProcessMqConnectorAccounts(t *testing.T) { - - var reset = func() { - processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - panic("should be mocked") - } - } - var restore = func() { - processMqAccount = processMqAccountRestore - os.Unsetenv("DEVELOPMENT_MODE") - } - - t.Run("Process all mq accounts", func(t *testing.T) { - - reset() - defer restore() - - mqAccounts := []AccountInfo{ - {Name: "acc 1", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"abc","Password":"xyz"}`)}, - {Name: "acc 2", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"u1","Password":"p1"}`)}} - - var callCount = 0 - processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - - if callCount == 0 { - assert.Equal(t, "acc 1", mqAccount.Name) - assert.Equal(t, "BASIC", mqAccount.Credentials.AuthType) - assert.Equal(t, "abc", mqAccount.Credentials.Username) - assert.Equal(t, "xyz", mqAccount.Credentials.Password) - } - - if callCount == 1 { - assert.Equal(t, "acc 2", mqAccount.Name) - assert.Equal(t, "BASIC", mqAccount.Credentials.AuthType) - assert.Equal(t, "u1", mqAccount.Credentials.Username) - assert.Equal(t, "p1", mqAccount.Credentials.Password) - } - - callCount++ - return nil - } - - error := processMqConnectorAccounts(testLogger, testBaseDir, mqAccounts) - - assert.Equal(t, 2, callCount) - assert.Nil(t, error) - }) - - t.Run("Returns error if any processMqAccount returned error", func(t *testing.T) { - - reset() - defer restore() - - mqAccounts := []AccountInfo{ - {Name: "acc 1", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"abc","Password":"xyz"}`)}, - {Name: "acc 2", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"u1","Password":"p1"}`)}} - - var callCount = 0 - var err = errors.New("process mq account failed") - processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - if callCount == 1 { - return err - } - - callCount++ - return nil - } - - errReturned := processMqConnectorAccounts(testLogger, testBaseDir, mqAccounts) - - assert.Equal(t, err, errReturned) - }) - - t.Run("When running in authoring mode, invokes processAllAccounts with isDesignerAuthoringMode flag true", func(t *testing.T) { - reset() - defer restore() - - os.Setenv("DEVELOPMENT_MODE", "true") - - mqAccounts := []AccountInfo{ - {Name: "acc 1", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"abc","Password":"xyz"}`)}} - - processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - assert.True(t, isDesignerAuthoringMode) - return nil - } - - err := processMqConnectorAccounts(testLogger, testBaseDir, mqAccounts) - - assert.Nil(t, err) - }) - - t.Run("When not running in authoring mode, invokes processAllAccounts with isDesignerAuthoringMode flag false", func(t *testing.T) { - reset() - defer restore() - - os.Unsetenv("DEVELOPMENT_MODE") - - mqAccounts := []AccountInfo{ - {Name: "acc 1", Credentials: json.RawMessage(`{"authType":"BASIC","Username":"abc","Password":"xyz"}`)}} - - processMqAccount = func(log logger.LoggerInterface, baseDir string, mqAccount MQAccountInfo, isDesignerAuthoringMode bool) error { - assert.False(t, isDesignerAuthoringMode) - return nil - } - - err := processMqConnectorAccounts(testLogger, testBaseDir, mqAccounts) - - assert.Nil(t, err) - }) -} - -func TestProcessMqAccount(t *testing.T) { - - var createMqAccountDbParamsRestore = createMqAccountDbParams - var createMQPolicyRestore = createMQPolicy - var createMQFlowBarOverridesPropertiesRestore = createMQFlowBarOverridesProperties - var importMqAccountCertificatesRestore = importMqAccountCertificates - - var reset = func() { - createMqAccountDbParams = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - panic("should be mocked") - } - createMQPolicy = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - panic("should be mocked") - } - createMQFlowBarOverridesProperties = func(log logger.LoggerInterface, basedir string, mqAccount MQAccountInfo) error { - panic("should be mocked") - } - importMqAccountCertificates = func(log logger.LoggerInterface, mqAccount MQAccountInfo) error { - panic("should be mocked") - } - os.Setenv("ACE_CONTENT_SERVER_URL", "http://localhost/a.bar") - } - - var restore = func() { - createMqAccountDbParams = createMqAccountDbParamsRestore - createMQPolicy = createMQPolicyRestore - createMQFlowBarOverridesProperties = createMQFlowBarOverridesPropertiesRestore - importMqAccountCertificates = importMqAccountCertificatesRestore - - os.Unsetenv("ACE_CONTENT_SERVER_URL") - } - - mqAccount := getMqAccount("acc-1") - - reset() - defer restore() - - t.Run("when creates db params fails returns error", func(t *testing.T) { - - err := errors.New("create db params failed") - createMqAccountDbParams = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - return err - } - - errReturned := processMqAccount(testLogger, testBaseDir, mqAccount, false) - - assert.Equal(t, err, errReturned) - }) - - t.Run("when creates db params succeeds,import certificates", func(t *testing.T) { - - createMqAccountDbParams = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - return nil - } - - t.Run("Returns error when import certificates failed", func(t *testing.T) { - - importError := errors.New("import certificates failed") - importMqAccountCertificates = func(log logger.LoggerInterface, mqAccount MQAccountInfo) error { - return importError - } - - errReturned := processMqAccount(testLogger, testBaseDir, mqAccount, false) - assert.Equal(t, importError, errReturned) - }) - - t.Run("when import certificates succeeded, creates policies", func(t *testing.T) { - - importMqAccountCertificates = func(log logger.LoggerInterface, mqAccount MQAccountInfo) error { - return nil - } - - createMqAccountDbParams = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - assert.Equal(t, mqAccount, mqAccountP) - return nil - } - - t.Run("when running in designer authoring mode, doesn't deploy policy and doesn't create bar overrides file", func(t *testing.T) { - - isDesignerAuthoringMode := true - createMQPolicy = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - assert.Fail(t, "Should not create policies in authoring mode") - return nil - } - - createMQFlowBarOverridesProperties = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - assert.Fail(t, "Should not create policies in authoring mode") - return nil - } - - err := processMqAccount(testLogger, testBaseDir, mqAccount, isDesignerAuthoringMode) - - assert.Nil(t, err) - }) - - t.Run("when create policy fails, returns error", func(t *testing.T) { - - err := errors.New("create mq policy failed") - createMQPolicy = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - return err - } - - errReturned := processMqAccount(testLogger, testBaseDir, mqAccount, false) - - assert.Equal(t, err, errReturned) - }) - - t.Run("when create policy succeeds, creates bar overrides files", func(t *testing.T) { - createMQPolicy = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - assert.Equal(t, mqAccount, mqAccountP) - return nil - } - - t.Run("when create bar ovrrides failed, returns error", func(t *testing.T) { - err := errors.New("create bar overrides failed") - createMQFlowBarOverridesProperties = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - return err - } - - errReturned := processMqAccount(testLogger, testBaseDir, mqAccount, false) - - assert.Equal(t, err, errReturned) - }) - - t.Run("when create bar ovrrides succeeds, returns nil", func(t *testing.T) { - - createMQFlowBarOverridesProperties = func(log logger.LoggerInterface, basedir string, mqAccountP MQAccountInfo) error { - assert.Equal(t, mqAccount, mqAccountP) - return nil - } - - err := processMqAccount(testLogger, testBaseDir, mqAccount, false) - - assert.Nil(t, err) - }) - }) - - }) - }) -} - -func TestCreateMqAccountDbParams(t *testing.T) { - - var internalRunSetdbparmsCommandRestore = internalRunSetdbparmsCommand - var reset = func() { - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - panic("should be mocked") - } - } - - var restore = func() { - internalRunSetdbparmsCommand = internalRunSetdbparmsCommandRestore - } - - t.Run("invokes mqsisetdbparmas command with resource name which is sha of account, username and password arguments", func(t *testing.T) { - - reset() - defer restore() - - mqAccount := getMqAccount("acc1") - resourceName := "mq::gen_" + mqAccount1Sha - workdir := "'" + testBaseDir + string(os.PathSeparator) + workdirName + "'" - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Equal(t, "mqsisetdbparms", command) - assert.Equal(t, []string{"'-n'", resourceName, "'-u'", "'" + mqAccount.Credentials.Username + "'", "'-p'", "'" + mqAccount.Credentials.Password + "'", "'-w'", workdir}, params) - return nil - } - - createMqAccountDbParams(testLogger, testBaseDir, mqAccount) - }) - - t.Run("when mqsisetdbparmas command failed returns error", func(t *testing.T) { - - reset() - defer restore() - - mqAccount := getMqAccount("acc1") - err := errors.New("run setdb params failed") - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - return err - } - - errReturned := createMqAccountDbParams(testLogger, testBaseDir, mqAccount) - - assert.Equal(t, err, errReturned) - }) - - t.Run("when mqsisetdbparmas command succeeds returns nil", func(t *testing.T) { - - reset() - defer restore() - - mqAccount := getMqAccount("acc1") - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - return nil - } - - errReturned := createMqAccountDbParams(testLogger, testBaseDir, mqAccount) - - assert.Nil(t, errReturned) - }) - - t.Run("when username and password fields are empty doesn't execute setdbparams command", func(t *testing.T) { - - reset() - defer restore() - - internalRunSetdbparmsCommand = func(log logger.LoggerInterface, command string, params []string) error { - assert.Fail(t, "setdbparams should not be invoked when username and password fields are empty") - return nil - } - - mqAccount := getMqAccount("acc1") - mqAccount.Credentials.Username = "" - mqAccount.Credentials.Password = "" - - errReturned := createMqAccountDbParams(testLogger, testBaseDir, mqAccount) - - assert.Nil(t, errReturned) - }) -} - -func TestCreateMqPolicy(t *testing.T) { - - var osStatRestore = osStat - var osIsNotExistRestore = osIsNotExist - var osMkdirAllRestore = osMkdirAll - var transformXMLTemplateRestore = transformXMLTemplate - var ioutilWriteFileRestore = ioutilWriteFile - mqAccount := getMqAccount("acc-1") - - var reset = func() { - osStat = func(dirName string) (os.FileInfo, error) { - panic("should be mocked") - } - osIsNotExist = func(err error) bool { - panic("should be mocked") - } - - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - panic("should be mocked") - } - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - panic("should be mocked") - } - - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - panic("should be mocked") - } - } - - var restore = func() { - osStat = osStatRestore - osIsNotExist = osIsNotExistRestore - osMkdirAll = osMkdirAllRestore - transformXMLTemplate = transformXMLTemplateRestore - ioutilWriteFile = ioutilWriteFileRestore - } - - policyDirName := testBaseDir + string(os.PathSeparator) + workdirName + string(os.PathSeparator) + "overrides" + string(os.PathSeparator) + "gen.MQPolicies" - - t.Run("Returns error when failed to create 'gen.MQPolicies' directory if not exists", func(t *testing.T) { - - reset() - defer restore() - - osStatError := errors.New("osStat failed") - - osStat = func(dirName string) (os.FileInfo, error) { - assert.Equal(t, policyDirName, dirName, mqAccount) - return nil, osStatError - } - - osIsNotExist = func(err error) bool { - assert.Equal(t, osStatError, err) - return true - } - - osMakeDirError := errors.New("os make dir error failed") - osMkdirAll = func(dirPath string, perm os.FileMode) error { - assert.Equal(t, policyDirName, dirPath) - assert.Equal(t, os.ModePerm, perm) - return osMakeDirError - } - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccount) - - assert.Equal(t, osMakeDirError, errorReturned) - - t.Run("When creation of 'gen.MQPolicies' succeeds, transforms xml template", func(t *testing.T) { - - osMkdirAll = func(dirPath string, perm os.FileMode) error { - assert.Equal(t, policyDirName, dirPath) - assert.Equal(t, os.ModePerm, perm) - return nil - } - - t.Run("Returns error when failed to transform policy xml template", func(t *testing.T) { - - transformError := errors.New("transform xml template failed") - policyName := "account_1" - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - assert.Equal(t, map[string]interface{}{ - "policyName": policyName, - "queueManager": mqAccount.Credentials.QueueManager, - "hostName": mqAccount.Credentials.Hostname, - "port": mqAccount.Credentials.Port, - "channelName": mqAccount.Credentials.ChannelName, - "securityIdentity": "gen_" + mqAccount1Sha, - "useSSL": false, - "sslPeerName": "", - "sslCipherSpec": "", - "sslCertificateLabel": "", - }, context) - - return "", transformError - } - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccount) - assert.Equal(t, transformError, errorReturned) - }) - - t.Run("Sets security idenity empty with mq account username and password are empty", func(t *testing.T) { - - transformError := errors.New("transform xml template failed") - policyName := "account_1" - - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - assert.Equal(t, map[string]interface{}{ - "policyName": policyName, - "queueManager": mqAccount.Credentials.QueueManager, - "hostName": mqAccount.Credentials.Hostname, - "port": mqAccount.Credentials.Port, - "channelName": mqAccount.Credentials.ChannelName, - "securityIdentity": "", - "useSSL": false, - "sslPeerName": "", - "sslCipherSpec": "", - "sslCertificateLabel": "", - }, context) - - return "", transformError - } - - mqAccountWithEmptyCredentials := getMqAccountWithEmptyCredentials() - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccountWithEmptyCredentials) - assert.Equal(t, transformError, errorReturned) - }) - - t.Run("when transform xml template succeeds, writes transforrmed policy xml in 'gen.MQPolicies' dir with the file name of account name", func(t *testing.T) { - - trasformedXML := "abc" - transformXMLTemplate = func(xmlTemplate string, context interface{}) (string, error) { - return trasformedXML, nil - } - - t.Run("Returns error when failed to write to account name policy file", func(t *testing.T) { - - writeFileError := errors.New("write file failed") - policyFileNameForAccount1 := string(policyDirName + string(os.PathSeparator) + "account_1.policyxml") - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - assert.Equal(t, policyFileNameForAccount1, filename) - assert.Equal(t, trasformedXML, string(data)) - assert.Equal(t, os.ModePerm, perm) - return writeFileError - } - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccount) - assert.Equal(t, writeFileError, errorReturned) - }) - - t.Run("When write policyxml succeeds, writes policy descriptor", func(t *testing.T) { - - t.Run("Returns error when write policy descriptor failed", func(t *testing.T) { - - policyDescriptorWriteError := errors.New("policy descriptor write failed") - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - _, fileName := filepath.Split(filenameWithPath) - if fileName == "policy.descriptor" { - return policyDescriptorWriteError - } - - return nil - } - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccount) - assert.Equal(t, policyDescriptorWriteError, errorReturned) - }) - - t.Run("Returns nil when write policy descriptor succeeeded", func(t *testing.T) { - - ioutilWriteFile = func(filenameWithPath string, data []byte, perm os.FileMode) error { - return nil - } - - errorReturned := createMQPolicy(testLogger, testBaseDir, mqAccount) - assert.Nil(t, errorReturned) - }) - }) - - }) - }) - }) -} - -func TestCreateMQFlowBarOverridesPropertiest(t *testing.T) { - - var osStatRestore = osStat - var osIsNotExistRestore = osIsNotExist - var osMkdirAllRestore = osMkdirAll - var internalAppendFileRestore = internalAppendFile - mqAccount := getMqAccount("acc-1") - - var reset = func() { - osStat = func(dirName string) (os.FileInfo, error) { - panic("should be mocked") - } - osIsNotExist = func(err error) bool { - panic("should be mocked") - } - - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - panic("should be mocked") - } - - internalAppendFile = func(filename string, data []byte, perm os.FileMode) error { - panic("should be mocked") - } - } - - var restore = func() { - osStat = osStatRestore - osIsNotExist = osIsNotExistRestore - osMkdirAll = osMkdirAllRestore - internalAppendFile = internalAppendFileRestore - } - - reset() - defer restore() - - t.Run("Returns error when failed to create workdir_overrides dir if not exist", func(t *testing.T) { - - barOverridesDir := "/home/aceuser/initial-config/workdir_overrides" - osStatError := errors.New("osStat failed") - - osStat = func(dirName string) (os.FileInfo, error) { - assert.Equal(t, barOverridesDir, dirName) - return nil, osStatError - } - - osIsNotExist = func(err error) bool { - assert.Equal(t, osStatError, err) - return true - } - - osMakeDirError := errors.New("os make dir error failed") - - osMkdirAll = func(dirPath string, perm os.FileMode) error { - assert.Equal(t, barOverridesDir, dirPath) - assert.Equal(t, os.ModePerm, perm) - return osMakeDirError - } - - errorReturned := createMQFlowBarOverridesProperties(testLogger, testBaseDir, mqAccount) - - assert.Equal(t, osMakeDirError, errorReturned) - - t.Run("when create barfile overrides dir succeeded, creates barfile.properties with httpendpoint of mq runtime flow", func(t *testing.T) { - - osMkdirAll = func(dirPath string, perm os.FileMode) error { - return nil - } - - t.Run("Returns error when failed to write barfile.properties", func(t *testing.T) { - - barPropertiesFile := "/home/aceuser/initial-config/workdir_overrides/mqconnectorbarfile.properties" - appendFileError := errors.New("append file failed") - - udfProperty := "gen.mq_account_1#mqRuntimeAccountId=account_1~" + mqAccount1Sha + "\n" - internalAppendFile = func(fileName string, fileContent []byte, filePerm os.FileMode) error { - assert.Equal(t, barPropertiesFile, fileName) - assert.Equal(t, udfProperty, string(fileContent)) - return appendFileError - } - - errorReturned := createMQFlowBarOverridesProperties(testLogger, testBaseDir, mqAccount) - assert.Equal(t, appendFileError, errorReturned) - }) - - t.Run("Returns nil when write barfile.properties succeeded", func(t *testing.T) { - - internalAppendFile = func(fileName string, fileContent []byte, filePerm os.FileMode) error { - return nil - } - - errorReturned := createMQFlowBarOverridesProperties(testLogger, testBaseDir, mqAccount) - assert.Nil(t, errorReturned) - }) - }) - }) -} - -func TestImportMqAccountCertificatesTests(t *testing.T) { - - var convertMqAccountSingleLinePEMRestore = convertMqAccountSingleLinePEM - var kdbFilePath = "/home/aceuser/kdb/mq.kdb" - - var reset = func() { - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - panic("should be mocked") - } - runOpenSslCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - panic("should be mocked") - } - - runMqakmCommand = func(logger logger.LoggerInterface, cmdArgs []string) error { - panic("should be mocked") - } - - convertMqAccountSingleLinePEM = func(pem string) (string, error) { - panic("should be mocked") - } - } - - var restore = func() { - osMkdirAll = osMkdirAllRestore - runOpenSslCommand = runOpenSslCommandRestore - runMqakmCommand = runMqakmCommandRestore - convertMqAccountSingleLinePEM = convertMqAccountSingleLinePEMRestore - } - - reset() - defer restore() - - t.Run("Creates temp dir to import certificates", func(t *testing.T) { - - mqAccountWithSsl := getMqAccountWithSsl("acc1") - - t.Run("Returns error if failed to create temp dir", func(t *testing.T) { - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - assert.Equal(t, "/tmp/mqssl-work", dirName) - assert.Equal(t, os.ModePerm, filePerm) - return errors.New("Create temp dir failed") - } - - err := importMqAccountCertificates(testLogger, mqAccountWithSsl) - - assert.Error(t, err, "Failed to create mp dir to import certificates,Error: Create temp dir failed") - - }) - - t.Run("when create temp dir succeeded", func(t *testing.T) { - - osMkdirAll = func(dirName string, filePerm os.FileMode) error { - return nil - } - - t.Run("imports server cerificates if present", func(t *testing.T) { - - t.Run("Returns error if the server certificate is not valid a PEM ", func(t *testing.T) { - pemError := errors.New("Invalid pem error") - convertMqAccountSingleLinePEM = func(content string) (string, error) { - assert.Equal(t, mqAccountWithSsl.Credentials.ServerCertificate, content) - return "", pemError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithSsl) - - assert.Equal(t, pemError, err) - }) - - t.Run("when server certificate is a valid PEM, writes converted PEM to a temp file to import", func(t *testing.T) { - - convertedPem := "abc" - tempServerCertificatePemFile := "/tmp/mqssl-work/servercrt.pem" - convertMqAccountSingleLinePEM = func(content string) (string, error) { - return convertedPem, nil - } - - t.Run("Returns error if write to temp file failed", func(t *testing.T) { - - writeError := errors.New("Wrie temp file failed") - - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - assert.Equal(t, tempServerCertificatePemFile, filename) - assert.Equal(t, convertedPem, string(data)) - assert.Equal(t, os.ModePerm, perm) - - return writeError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithSsl) - - assert.Equal(t, writeError, err) - }) - - t.Run("when write to temp file succeeded, runs mqakam command to import certificate to kdb", func(t *testing.T) { - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - return nil - } - - t.Run("Return error if runmqakm command failed", func(t *testing.T) { - cmdError := errors.New("command error") - runMqakmCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - return cmdError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithSsl) - - assert.Equal(t, cmdError, err) - - }) - - t.Run("Returns nil When runMqakm command succeeded to import certificate", func(t *testing.T) { - - runMqakmCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - assert.Equal(t, "-cert", cmdArgs[0]) - assert.Equal(t, "-add", cmdArgs[1]) - assert.Equal(t, "-db", cmdArgs[2]) - assert.Equal(t, kdbFilePath, cmdArgs[3]) - assert.Equal(t, "-stashed", cmdArgs[4]) - assert.Equal(t, "-file", cmdArgs[5]) - assert.Equal(t, tempServerCertificatePemFile, cmdArgs[6]) - return nil - } - - err := importMqAccountCertificates(testLogger, mqAccountWithSsl) - - assert.Nil(t, err) - }) - }) - - }) - }) - - t.Run("imports client cerificate if present", func(t *testing.T) { - - mqAccountWithMutualSsl := getMqAccountWithMutualAuthSsl("acc1") - mqAccountWithMutualSsl.Credentials.ServerCertificate = "" - - t.Run("Returns error if the client certificate label is empty", func(t *testing.T) { - - mqAccountWithEmptyCertLabel := getMqAccountWithMutualAuthSsl("acc1") - mqAccountWithEmptyCertLabel.Credentials.ClientCertificateLabel = "" - err := importMqAccountCertificates(testLogger, mqAccountWithEmptyCertLabel) - - assert.Error(t, err, "Certificate label should not be empty for acc1") - }) - - t.Run("Returns error if the client certificate is not valid a PEM ", func(t *testing.T) { - pemError := errors.New("Invalid pem error") - convertMqAccountSingleLinePEM = func(content string) (string, error) { - assert.Equal(t, mqAccountWithMutualSsl.Credentials.ClientCertificate, content) - return "", pemError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - - assert.Equal(t, pemError, err) - }) - - t.Run("when client certificate is a valid PEM, writes converted PEM to a temp file to import", func(t *testing.T) { - - convertedPem := "abc" - tempClientCertificatePemFile := "/tmp/mqssl-work/clientcrt.pem" - convertMqAccountSingleLinePEM = func(content string) (string, error) { - return convertedPem, nil - } - - t.Run("Returns error when write to temp file failed", func(t *testing.T) { - - writeError := errors.New("Write client pem temp file failed") - - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - assert.Equal(t, tempClientCertificatePemFile, filename) - assert.Equal(t, convertedPem, string(data)) - assert.Equal(t, os.ModePerm, perm) - - return writeError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - - assert.Error(t, err, "Write client pem temp file failed") - }) - - t.Run("when write to temp file succeeded, creates pkcs12 file usingg openssl command to import to kdb", func(t *testing.T) { - ioutilWriteFile = func(filename string, data []byte, perm os.FileMode) error { - return nil - } - - tempP12File := "/tmp/mqssl-work/clientcrt.p12" - - t.Run("runs openssl command to create p12 with required arguments when no password present", func(t *testing.T) { - - runOpenSslCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - assert.Equal(t, "pkcs12", cmdArgs[0]) - assert.Equal(t, "-export", cmdArgs[1]) - assert.Equal(t, "-out", cmdArgs[2]) - assert.Equal(t, tempP12File, cmdArgs[3]) - assert.Equal(t, "-passout", cmdArgs[4]) - assert.NotEmpty(t, cmdArgs[5]) - assert.NotEmpty(t, "-in", cmdArgs[6]) - assert.Equal(t, tempClientCertificatePemFile, cmdArgs[7]) - - return errors.New("open ssl failed") - } - - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - - assert.NotNil(t, err) - }) - - t.Run("when password is parent runs openssl command password in flag", func(t *testing.T) { - - mqAccountWithPassword := getMqAccountWithMutualAuthSsl("acc1") - mqAccountWithPassword.Credentials.ClientCertificatePassword = "p123" - - runOpenSslCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - - assert.NotEmpty(t, "-passin", cmdArgs[8]) - assert.Equal(t, "pass:p123", cmdArgs[9]) - - return errors.New("open ssl failed") - } - - err := importMqAccountCertificates(testLogger, mqAccountWithPassword) - - assert.NotNil(t, err) - }) - - t.Run("Return error if openssl command failed to create p12 file failed", func(t *testing.T) { - cmdError := errors.New("command error") - runOpenSslCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - return cmdError - } - - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - - assert.Equal(t, cmdError, err) - - }) - - t.Run("When creation of p12 file from pem succeeded runs runmqakm command to import p12 file to kdb", func(t *testing.T) { - - runOpenSslCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - return nil - } - - t.Run("Returns error if runmqakm command failed to import p12 file", func(t *testing.T) { - - cmdErr := errors.New("runmqakm failed") - runMqakmCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - return cmdErr - } - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - assert.Equal(t, cmdErr, err) - }) - - t.Run("Returns nil when runmqakm command succeeded", func(t *testing.T) { - - runMqakmCommand = func(log logger.LoggerInterface, cmdArgs []string) error { - assert.Equal(t, "-cert", cmdArgs[0]) - assert.Equal(t, "-import", cmdArgs[1]) - assert.Equal(t, "-type", cmdArgs[2]) - assert.Equal(t, "p12", cmdArgs[3]) - assert.Equal(t, "-file", cmdArgs[4]) - assert.Equal(t, tempP12File, cmdArgs[5]) - assert.Equal(t, "-pw", cmdArgs[6]) - assert.NotEmpty(t, cmdArgs[7]) - assert.NotEmpty(t, "-target_type", cmdArgs[8]) - assert.NotEmpty(t, "cms", cmdArgs[9]) - assert.NotEmpty(t, "-target", cmdArgs[10]) - assert.Equal(t, kdbFilePath, cmdArgs[11]) - assert.NotEmpty(t, "-target_stashed", cmdArgs[12]) - - return nil - } - - err := importMqAccountCertificates(testLogger, mqAccountWithMutualSsl) - assert.Nil(t, err) - }) - }) - }) - }) - }) - }) - }) -} - -func TestConvertMQAccountSingleLinePEM(t *testing.T) { - - t.Run("Returns error if no PEM headers and footers present in the PEM line", func(t *testing.T) { - pemLine := "abc no pem headers and footers" - - _, err := convertMqAccountSingleLinePEM(pemLine) - - assert.NotNil(t, err) - }) - - t.Run("Returns error if not a valid PEM", func(t *testing.T) { - pemLineInvalidFooter := "-----BEGIN CERTIFICATE----- line1 line2 -----END CERTIFICATE" - - _, err := convertMqAccountSingleLinePEM(pemLineInvalidFooter) - - assert.NotNil(t, err) - }) - - t.Run("Returns error if not a valid PEM", func(t *testing.T) { - pemLineInvalidHeader := "-----BEGIN----- line1 line2 -----END CERTIFICATE-----" - - _, err := convertMqAccountSingleLinePEM(pemLineInvalidHeader) - - assert.NotNil(t, err) - }) - - t.Run("Returns multiline PEM", func(t *testing.T) { - expectedPem := "-----BEGIN CERTIFICATE-----\nline1\nline2\n-----END CERTIFICATE-----\n-----BEGIN ENCRYPTED PRIVATE KEY-----\nkeyline1\nkeyline2\n-----END ENCRYPTED PRIVATE KEY-----\n" - pemLineInvalidHeader := "-----BEGIN CERTIFICATE----- line1 line2 -----END CERTIFICATE----- -----BEGIN ENCRYPTED PRIVATE KEY----- keyline1 keyline2 -----END ENCRYPTED PRIVATE KEY-----" - - multiLinePem, err := convertMqAccountSingleLinePEM(pemLineInvalidHeader) - - assert.Nil(t, err) - assert.Equal(t, expectedPem, multiLinePem) - - }) -} - -func getMqAccount(accountName string) MQAccountInfo { - return MQAccountInfo{ - Name: "account-1", - Credentials: MQCredentials{ - AuthType: "BASIC", - QueueManager: "QM1", - Hostname: "host1", - Port: 123, - Username: "abc", - Password: "xyz", - ChannelName: "testchannel"}} -} - -func getMqAccountWithEmptyCredentials() MQAccountInfo { - return MQAccountInfo{ - Name: "account-1", - Credentials: MQCredentials{ - AuthType: "BASIC", - QueueManager: "QM1", - Hostname: "host1", - Port: 123, - Username: "", - Password: "", - ChannelName: "testchannel"}} -} - -func getMqAccountWithSsl(accountName string) MQAccountInfo { - return MQAccountInfo{ - Name: "account-1", - Credentials: MQCredentials{ - AuthType: "BASIC", - QueueManager: "QM1", - Hostname: "host1", - Port: 123, - Username: "abc", - Password: "xyz", - ChannelName: "testchannel", - ServerCertificate: "-----BEGIN CERTIFICATE----- Line1Content Line2Content -----END CERTIFICATE-----", - }} -} - -func getMqAccountWithMutualAuthSsl(accountName string) MQAccountInfo { - return MQAccountInfo{ - Name: "account-1", - Credentials: MQCredentials{ - AuthType: "BASIC", - QueueManager: "QM1", - Hostname: "host1", - Port: 123, - Username: "abc", - Password: "xyz", - ChannelName: "testchannel", - ServerCertificate: "-----BEGIN CERTIFICATE----- Line1Content Line2Content -----END CERTIFICATE-----", - ClientCertificate: "-----BEGIN CERTIFICATE----- Line1Content Line2Content -----END CERTIFICATE-----", - ClientCertificatePassword: "abcd", - ClientCertificateLabel: "somelabel", - }} -} diff --git a/internal/isCommandsApi/apiServer_test.go b/internal/isCommandsApi/apiServer_test.go deleted file mode 100644 index 59ca56e..0000000 --- a/internal/isCommandsApi/apiServer_test.go +++ /dev/null @@ -1,250 +0,0 @@ -package iscommandsapi - -import ( - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/stretchr/testify/assert" -) - -var startHTTPServerRestore = startHTTPServer -var restartIntegrationServerFuncRestore = restartIntegrationServerFunc -var runCommandRestore func(name string, args ...string) (string, int, error) = runCommand - -type testCommandHandler struct { - executeHandler func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) -} - -func (me *testCommandHandler) execute(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return me.executeHandler(log, body) -} - -func reset() { - startHTTPServer = func(log logger.LoggerInterface, portNo int) *http.Server { - panic("Start http server should be mocked") - } - - restartIntegrationServerFunc = func() error { - panic("Restart integration server should be mocked") - } - - runCommand = func(name string, args ...string) (string, int, error) { - panic("Run command should be implemented") - } -} - -func restore() { - runCommand = runCommandRestore - startHTTPServer = startHTTPServerRestore - restartIntegrationServerFunc = restartIntegrationServerFuncRestore -} - -func TestStartCommandsAPIServer(t *testing.T) { - - var testLogger, _ = logger.NewLogger(os.Stdout, true, true, "test") - restartIsFunc := func() error { return nil } - - t.Run("When restart func is nil, returns error", func(t *testing.T) { - reset() - defer restore() - - err := StartCommandsAPIServer(testLogger, 123, nil) - - assert.NotNil(t, err) - assert.Equal(t, "Restart handler should not be nil", err.Error()) - }) - - t.Run("registers setdbparms command handler and invokes startHTTPServer with specified portNo", func(t *testing.T) { - reset() - defer restore() - - var logP logger.LoggerInterface - var httpServerInstance = &http.Server{} - var portNoP int - startHTTPServer = func(log logger.LoggerInterface, portNo int) *http.Server { - logP = log - portNoP = portNo - - return httpServerInstance - } - - err := StartCommandsAPIServer(testLogger, 123, restartIsFunc) - - assert.NotNil(t, commandsHandler["setdbparms"]) - assert.Nil(t, err) - assert.Equal(t, logP, testLogger) - assert.Equal(t, portNoP, 123) - assert.Equal(t, httpServerInstance, httpServer) - - }) -} - -func TestCommandRequestHttpHandler(t *testing.T) { - - var request *http.Request - var response *httptest.ResponseRecorder - var handler http.HandlerFunc - var testCommandURL string = "/commands/test" - - setupTestCommand := func(requestURL string, executeCommandFunc func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError)) { - restartIntegrationServerFunc = func() error { - return nil - } - - handler = http.HandlerFunc(commandRequestHandler) - request, _ = http.NewRequest("POST", requestURL, nil) - response = httptest.NewRecorder() - - testCommandHadler := testCommandHandler{executeHandler: executeCommandFunc} - handleCRUDCommand("test", &testCommandHadler) - } - - t.Run("Returns not found when url doesn't have command ", func(t *testing.T) { - reset() - setupTestCommand("/commands", nil) - defer restore() - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusNotFound, response.Code) - assert.Equal(t, `{"success":false,"message":"Not found"}`+"\n", response.Body.String()) - }) - - t.Run("when no handler registered for the command, returns not found", func(t *testing.T) { - reset() - defer restore() - - setupTestCommand("/commands/test2", nil) - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusNotFound, response.Code) - assert.Equal(t, `{"success":false,"message":"Not found"}`+"\n", response.Body.String()) - }) - - t.Run("Invokes registered command handlers with request body", func(t *testing.T) { - reset() - defer restore() - - called := false - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - called = true - return &commandResponse{message: "ok"}, nil - } - - setupTestCommand(testCommandURL, executeCommandFunc) - - handler.ServeHTTP(response, request) - - assert.Equal(t, true, called) - }) - - t.Run("when command handler returns message, responds with status ok and message", func(t *testing.T) { - reset() - defer restore() - - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return &commandResponse{message: "command executed", restartIs: true}, nil - } - - setupTestCommand(testCommandURL, executeCommandFunc) - - handler.ServeHTTP(response, request) - - assert.Equal(t, http.StatusOK, response.Code) - assert.Equal(t, `{"success":true,"message":"command executed"}`+"\n", response.Body.String()) - }) - - t.Run("when command handler returns invalid input, responds with bad request", func(t *testing.T) { - reset() - defer restore() - - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return nil, &commandError{error: "Invalid input", errorCode: commandErrorInvalidInput} - } - - setupTestCommand(testCommandURL, executeCommandFunc) - - handler.ServeHTTP(response, request) - - assert.Equal(t, http.StatusBadRequest, response.Code) - assert.Equal(t, `{"success":false,"message":"Invalid input"}`+"\n", response.Body.String()) - }) - - t.Run("when command handler returns internal error, responds with internal server error", func(t *testing.T) { - reset() - defer restore() - - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return nil, &commandError{error: "Internal error while invkoing command", errorCode: commandErrorInternal} - } - - setupTestCommand(testCommandURL, executeCommandFunc) - - handler.ServeHTTP(response, request) - - assert.Equal(t, http.StatusInternalServerError, response.Code) - assert.Equal(t, `{"success":false,"message":"Internal error while invkoing command"}`+"\n", response.Body.String()) - }) - - t.Run("when command handler returns restartIs with true in response, invokes restart integration server func", func(t *testing.T) { - reset() - defer restore() - - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return &commandResponse{message: "command executed", restartIs: true}, nil - } - - setupTestCommand(testCommandURL, executeCommandFunc) - restartIsCalled := false - - restartIntegrationServerFunc = func() error { - restartIsCalled = true - return nil - } - - handler.ServeHTTP(response, request) - - assert.Equal(t, true, restartIsCalled) - }) - - t.Run("when restart inegration server failed, returns internal server error", func(t *testing.T) { - reset() - defer restore() - - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return &commandResponse{message: "command executed", restartIs: true}, nil - } - setupTestCommand(testCommandURL, executeCommandFunc) - - restartIsCalled := false - restartIntegrationServerFunc = func() error { - restartIsCalled = true - return errors.New("restart failed") - } - - handler.ServeHTTP(response, request) - - assert.Equal(t, true, restartIsCalled) - assert.Equal(t, http.StatusInternalServerError, response.Code) - assert.Equal(t, `{"success":false,"message":"Integration server restart failed"}`+"\n", response.Body.String()) - }) - - t.Run("when restart inegration server is nill, returns integration server has not restarted message", func(t *testing.T) { - reset() - defer restore() - executeCommandFunc := func(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - return &commandResponse{message: "command executed", restartIs: true}, nil - } - - setupTestCommand(testCommandURL, executeCommandFunc) - restartIntegrationServerFunc = nil - handler.ServeHTTP(response, request) - - assert.Equal(t, http.StatusInternalServerError, response.Code) - assert.Equal(t, `{"success":false,"message":"Integration server has not restarted"}`+"\n", response.Body.String()) - }) -} diff --git a/internal/isCommandsApi/apiserver.go b/internal/isCommandsApi/apiserver.go deleted file mode 100644 index 7b5b14d..0000000 --- a/internal/isCommandsApi/apiserver.go +++ /dev/null @@ -1,193 +0,0 @@ -package iscommandsapi - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "io" - "net/http" - "regexp" - "time" - - "github.com/ot4i/ace-docker/common/logger" -) - -var log logger.LoggerInterface - -type commandResponse struct { - message string - restartIs bool -} - -type commandError struct { - error string - errorCode int -} - -const commandErrorInternal = 1 -const commandErrorInvalidInput = 2 - -type commandHandlerInterface interface { - execute(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) -} - -type handlerInvocationDetails struct { - handler commandHandlerInterface -} - -type apiResponse struct { - Success bool `json:"success"` - Message string `json:"message"` -} - -var commandsHandler map[string]handlerInvocationDetails = make(map[string]handlerInvocationDetails) -var restartIntegrationServerFunc func() error -var httpServer *http.Server = nil - -func writeRequestesponse(writer http.ResponseWriter, statusCode int, message string) { - writer.Header().Set("Content-Type", "application/json") - writer.WriteHeader(statusCode) - - apiReturn := apiResponse{} - apiReturn.Success = statusCode == http.StatusOK - apiReturn.Message = message - - json.NewEncoder(writer).Encode(&apiReturn) -} - -func commandRequestHandler(writer http.ResponseWriter, request *http.Request) { - url := request.URL.Path - - log.Printf("#commandRequestHandler serving %f, method %s", url, request.Method) - apiRegEx := regexp.MustCompile("^/commands/(\\w*)/?(.*)?$") - - matches := apiRegEx.FindStringSubmatch(url) - - var err error = nil - if len(matches) != 3 { - log.Printf("#commandRequestHandler url doesn't have expected 3 tokens", url) - writeRequestesponse(writer, http.StatusNotFound, "Not found") - return - } - - command := matches[1] - commandHandler, found := commandsHandler[command] - if !found { - log.Printf("#commandRequestHandler No hanlders found for %s", command) - writeRequestesponse(writer, http.StatusNotFound, "Not found") - return - } - - restartIs := false - - apiResponse := "" - - switch request.Method { - case http.MethodPost: - commandResponse, commandError := commandHandler.handler.execute(log, request.Body) - - if commandError != nil { - log.Printf("#commandRequestHandler an error occurred while processing command %s, error %s", command, commandError.error) - - if commandError.errorCode == commandErrorInvalidInput { - writeRequestesponse(writer, http.StatusBadRequest, commandError.error) - } else { - writeRequestesponse(writer, http.StatusInternalServerError, commandError.error) - } - - return - } - - apiResponse = commandResponse.message - restartIs = commandResponse.restartIs - break - - default: - writeRequestesponse(writer, http.StatusNotImplemented, "Not implemented") - return - } - - if restartIs { - log.Printf("#commandRequestHandler command %s requested integration server restart, invoking restart callback", command) - if restartIntegrationServerFunc != nil { - err = restartIntegrationServerFunc() - - if err != nil { - log.Errorf("#commandRequestHandler an error occurred while restarting integration server %v", err) - apiResponse = "Integration server restart failed" - } - } else { - log.Error("Intergration server function is nil") - err = errors.New("Integration server has not restarted") - apiResponse = "Integration server has not restarted" - } - } - - if err == nil { - writeRequestesponse(writer, http.StatusOK, apiResponse) - } else { - writeRequestesponse(writer, http.StatusInternalServerError, apiResponse) - } -} - -func handleCRUDCommand(command string, crudCommandHandler commandHandlerInterface) { - - crudHandler := handlerInvocationDetails{ - handler: crudCommandHandler} - - commandsHandler[command] = crudHandler -} - -var startHTTPServer = func(logger logger.LoggerInterface, portNo int) *http.Server { - log = logger - - address := fmt.Sprintf(":%v", portNo) - server := &http.Server{Addr: address} - - go func() { - err := server.ListenAndServe() - if err != nil && err != http.ErrServerClosed { - log.Errorf("Error in serving " + err.Error()) - } - log.Println("Commands API server stopped ") - }() - - return server -} - -// StartCommandsAPIServer Starts the api server -func StartCommandsAPIServer(logger logger.LoggerInterface, portNumber int, restartIsFunc func() error) error { - - if restartIsFunc == nil { - return errors.New("Restart handler should not be nil") - } - - log = logger - restartIntegrationServerFunc = restartIsFunc - - dbParamsHandler := DbParamsHandler{} - - handleCRUDCommand("setdbparms", dbParamsHandler) - http.HandleFunc("/commands/", commandRequestHandler) - httpServer = startHTTPServer(log, portNumber) - - return nil -} - -// StopCommandsAPIServer Stops commands api server -func StopCommandsAPIServer() { - if httpServer != nil { - ctxShutDown, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer func() { - cancel() - }() - - if err := httpServer.Shutdown(ctxShutDown); err != nil { - log.Fatalf("Server Shutdown Failed:%+s", err) - } else { - log.Println("Integration commands API stopped") - } - } - -} diff --git a/internal/isCommandsApi/dbparamsHandler.go b/internal/isCommandsApi/dbparamsHandler.go deleted file mode 100644 index 94df81f..0000000 --- a/internal/isCommandsApi/dbparamsHandler.go +++ /dev/null @@ -1,83 +0,0 @@ -package iscommandsapi - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "regexp" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/ot4i/ace-docker/internal/command" -) - -// DbParamsCommand for mqsisetdbparams command -type DbParamsCommand struct { - ResourceType string `json:"resourceType"` - ResourceName string `json:"resourceName"` - UserName string `json:"userName"` - Password string `json:"password"` -} - -// DbParamsHandler handler -type DbParamsHandler struct { -} - -var runCommand func(name string, args ...string) (string, int, error) = command.Run - -func (handler DbParamsHandler) execute(log logger.LoggerInterface, body io.Reader) (*commandResponse, *commandError) { - - dbParamsCommand := DbParamsCommand{} - err := json.NewDecoder(body).Decode(&dbParamsCommand) - - if err != nil { - log.Println("#setdbparamsHandler Error in decoding json") - return nil, &commandError{errorCode: commandErrorInvalidInput, error: "Invalid request"} - } - - if len(dbParamsCommand.UserName) == 0 || len(dbParamsCommand.ResourceType) == 0 || len(dbParamsCommand.ResourceName) == 0 { - log.Println("#setdbparamsHandler one of required parameters not found") - return nil, &commandError{errorCode: commandErrorInvalidInput, error: "Invalid request"} - } - - resource := fmt.Sprintf("%s::%s", dbParamsCommand.ResourceType, dbParamsCommand.ResourceName) - - isCredentialsExists, err := isResourceCredentialsExists(resource, dbParamsCommand.UserName, dbParamsCommand.Password) - - if err != nil { - log.Printf("#setdbparamsHandler, an error occurred while checking the resource already exists, error %s", err.Error()) - return nil, &commandError{errorCode: commandErrorInternal, error: "Internal error"} - } - - if isCredentialsExists { - log.Printf("#setdbparamsHandler credentials with the same user name and password already exists for the resource %s", resource) - return &commandResponse{message: "success", restartIs: false}, nil - } - - log.Printf("#setdbparamsHandler adding %s of type %s", dbParamsCommand.ResourceName, dbParamsCommand.ResourceType) - - runCommand("ace_mqsicommand.sh", "setdbparms", "-w", "/home/aceuser/ace-server/", "-n", resource, - "-u", dbParamsCommand.UserName, "-p", dbParamsCommand.Password) - - return &commandResponse{message: "success", restartIs: true}, nil -} - -func isResourceCredentialsExists(resourceName string, username string, password string) (bool, error) { - - cmdOutput, exitCode, err := runCommand("ace_mqsicommand.sh", "reportdbparms", "-w", "/home/aceuser/ace-server/", "-n", resourceName, - "-u", username, "-p", password) - - if err != nil { - return false, err - } - - if exitCode != 0 { - errorMsg := fmt.Sprintf("mqsireportdbparams command exited with non zero, exit code %v", exitCode) - return false, errors.New(errorMsg) - } - - credentialsMatchRegx := regexp.MustCompile("(?m)^(\\s)*\\b(BIP8201I).*\\b(correct).*$") - - return credentialsMatchRegx.MatchString(cmdOutput), nil - -} diff --git a/internal/isCommandsApi/dbparamsHandler_test.go b/internal/isCommandsApi/dbparamsHandler_test.go deleted file mode 100644 index 4212169..0000000 --- a/internal/isCommandsApi/dbparamsHandler_test.go +++ /dev/null @@ -1,198 +0,0 @@ -package iscommandsapi - -import ( - "errors" - "os" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/ot4i/ace-docker/common/logger" -) - -func TestDbParamsHandlerExecute(t *testing.T) { - - testLogger, _ := logger.NewLogger(os.Stdout, true, true, "test") - t.Run("When invalid json input is given, returns invalid input", func(t *testing.T) { - - reset() - defer restore() - - invalidJSON := `{"ResourceName":"abc}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(invalidJSON)) - - assert.NotNil(t, cmdError) - assert.Equal(t, commandErrorInvalidInput, cmdError.errorCode) - assert.Equal(t, "Invalid request", cmdError.error) - assert.Nil(t, cmdResponse) - }) - - t.Run("When resource name is missing, returns invalid input", func(t *testing.T) { - - reset() - defer restore() - - invalidJSON := `{"ResourceType":"mq","UserName":"abc","Password":"xyz"}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(invalidJSON)) - - assert.NotNil(t, cmdError) - assert.Equal(t, commandErrorInvalidInput, cmdError.errorCode) - assert.Equal(t, "Invalid request", cmdError.error) - assert.Nil(t, cmdResponse) - }) - - t.Run("When resource type is empty, returns invalid input", func(t *testing.T) { - - reset() - defer restore() - - invalidJSON := `{"resourceType":"","resourceName":"123","UserName":"abc","Password":"xyz"}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(invalidJSON)) - - assert.NotNil(t, cmdError) - assert.Equal(t, commandErrorInvalidInput, cmdError.errorCode) - assert.Equal(t, "Invalid request", cmdError.error) - assert.Nil(t, cmdResponse) - }) - - t.Run("When username is empty, returns invalid input", func(t *testing.T) { - - reset() - defer restore() - - invalidJSON := `{"resourceType":"mq","resourceName":"123","UserName":"","Password":"xyz"}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(invalidJSON)) - - assert.NotNil(t, cmdError) - assert.Equal(t, commandErrorInvalidInput, cmdError.errorCode) - assert.Equal(t, "Invalid request", cmdError.error) - assert.Nil(t, cmdResponse) - }) - - t.Run("when request is valid invokes reportdbparms command to check supplied resource credentials", func(t *testing.T) { - - reset() - defer restore() - - var invokedCommandName string = "" - var invokedCommandArgs []string = nil - - runCommand = func(cmdName string, cmdArguments ...string) (string, int, error) { - - invokedCommandName = cmdName - invokedCommandArgs = cmdArguments - return "", 1, nil - } - - validJSON := `{"resourceType":"mq","resourceName":"123","UserName":"abc","Password":"xyz"}` - expectedCommandArgs := []string{"reportdbparms", "-w", "/home/aceuser/ace-server/", "-n", "mq::123", "-u", "abc", "-p", "xyz"} - - _, err := DbParamsHandler{}.execute(testLogger, strings.NewReader(validJSON)) - - assert.NotNil(t, err) - assert.Equal(t, "ace_mqsicommand.sh", invokedCommandName) - assert.Equal(t, expectedCommandArgs, invokedCommandArgs) - }) - - t.Run("when reportdbparms cmd output contains credentials correct line, returns success with restart integration server flag false", func(t *testing.T) { - - reset() - defer restore() - - var credentialsExistsOutput = `BIP8180I: The resource name 'mq::123' has userID 'abc'. - BIP8201I: The password you entered, 'xyz' for resource 'mq::123' and userId 'abc' is correct.` - - runCommand = func(cmdName string, cmdArguments ...string) (string, int, error) { - return credentialsExistsOutput, 0, nil - } - - validJSON := `{"resourceType":"mq","resourceName":"123","UserName":"abc","Password":"xyz"}` - - cmdResponse, _ := DbParamsHandler{}.execute(testLogger, strings.NewReader(validJSON)) - - assert.NotNil(t, cmdResponse) - assert.Equal(t, "success", cmdResponse.message) - assert.Equal(t, false, cmdResponse.restartIs) - }) - - t.Run("When reportdbparams command output doesn't contain credentials correct line, invokes setdbparams and returns success", func(t *testing.T) { - - reset() - defer restore() - - var invokedCommandName string = "" - var invokedCommandArgs []string = nil - - reportDbPramsOutput := `BIP8180I: The resource name 'mq::123' has userID 'abc'. - BIP8204W: The password you entered, 'xyz' for resource 'mq::123' and userId 'test1' is incorrect` - - runCommand = func(cmdName string, cmdArguments ...string) (string, int, error) { - - if cmdArguments[0] == "reportdbparms" { - return reportDbPramsOutput, 0, nil - } - - invokedCommandName = cmdName - invokedCommandArgs = cmdArguments - return "", 0, nil - } - - validJSON := `{"resourceType":"mq","resourceName":"123","UserName":"abc","Password":"xyz"}` - - expectedCommandArgs := []string{"setdbparms", "-w", "/home/aceuser/ace-server/", "-n", "mq::123", "-u", "abc", "-p", "xyz"} - - cmdResponse, _ := DbParamsHandler{}.execute(testLogger, strings.NewReader(validJSON)) - - assert.NotNil(t, cmdResponse) - assert.Equal(t, "success", cmdResponse.message) - assert.Equal(t, "ace_mqsicommand.sh", invokedCommandName) - assert.Equal(t, expectedCommandArgs, invokedCommandArgs) - }) - - t.Run("When reportdbparams command returns error, returns internal error", func(t *testing.T) { - reset() - defer restore() - - runCommand = func(cmdName string, cmdArguments ...string) (string, int, error) { - if cmdArguments[0] == "reportdbparms" { - return "", 0, errors.New("some error") - } - - panic("should not come here") - } - - validJSON := `{"resourceType":"mq","resourceName":"123","UserName":"abc","Password":"xyz"}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(validJSON)) - - assert.Nil(t, cmdResponse) - assert.NotNil(t, commandErrorInternal, cmdError.errorCode) - assert.Equal(t, "Internal error", cmdError.error) - }) - - t.Run("When reportdbparams command exits with non zero, returns internal error", func(t *testing.T) { - reset() - defer restore() - - runCommand = func(cmdName string, cmdArguments ...string) (string, int, error) { - if cmdArguments[0] == "reportdbparms" { - return "", 1, nil - } - - return "", 0, nil - } - - validJSON := `{"resourceType":"mq","resourceName":"123","UserName":"abc","Password":"xyz"}` - - cmdResponse, cmdError := DbParamsHandler{}.execute(testLogger, strings.NewReader(validJSON)) - - assert.Nil(t, cmdResponse) - assert.Equal(t, commandErrorInternal, cmdError.errorCode) - assert.Equal(t, "Internal error", cmdError.error) - }) -} diff --git a/internal/metrics/exporter.go b/internal/metrics/exporter.go deleted file mode 100644 index 72bb682..0000000 --- a/internal/metrics/exporter.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package metrics contains code to provide metrics for the queue manager -package metrics - -import ( - "github.com/ot4i/ace-docker/common/logger" - - "github.com/prometheus/client_golang/prometheus" -) - -const ( - namespace = "ibmace" - msgflowPrefix = "msgflow" - msgflownodePrefix = "msgflownode" - serverLabel = "server" - applicationLabel = "application" - msgflowLabel = "msgflow" - msgflownodeLabel = "msgflownode" - msgflownodeTypeLabel = "msgflownodetype" - originLabel = "accountingorigin" -) - -type exporter struct { - serverName string - counterMap map[string]*prometheus.CounterVec - gaugeMap map[string]*prometheus.GaugeVec - firstCollect bool - log logger.LoggerInterface -} - -func newExporter(serverName string, log logger.LoggerInterface) *exporter { - return &exporter{ - serverName: serverName, - counterMap: make(map[string]*prometheus.CounterVec), - gaugeMap: make(map[string]*prometheus.GaugeVec), - log: log, - } -} - -// Describe provides details of all available metrics -func (e *exporter) Describe(ch chan<- *prometheus.Desc) { - - requestChannel <- false - response := <-responseChannel - - response.Lock() - defer response.Unlock() - - for key, metric := range response.internal { - - if metric.metricType == Total { - // For delta type metrics - allocate a Prometheus Counter - counterVec := createCounterVec(metric.name, metric.description, metric.metricLevel) - e.counterMap[key] = counterVec - - // Describe metric - counterVec.Describe(ch) - } else { - // For non-delta type metrics - allocate a Prometheus Gauge - gaugeVec := createGaugeVec(metric.name, metric.description, metric.metricLevel) - e.gaugeMap[key] = gaugeVec - - // Describe metric - gaugeVec.Describe(ch) - } - - } -} - -// Collect is called at regular intervals to provide the current metric data -func (e *exporter) Collect(ch chan<- prometheus.Metric) { - - requestChannel <- true - response := <-responseChannel - - response.Lock() - defer response.Unlock() - - for key, metric := range response.internal { - if metric.metricType == Total { - // For delta type metrics - update their Prometheus Counter - counterVec := e.counterMap[key] - - // Populate Prometheus Counter with metric values - for _, value := range metric.values { - var err error - var counter prometheus.Counter - - counter, err = counterVec.GetMetricWith(value.labels) - - if err == nil { - counter.Add(value.value) - } else { - e.log.Errorf("Metrics Error: %s", err.Error()) - } - } - - // Collect metric and reset cached values - counterVec.Collect(ch) - response.internal[key].values = make(map[string]*Metric) - } else { - // For non-delta type metrics - reset their Prometheus Gauge - gaugeVec := e.gaugeMap[key] - gaugeVec.Reset() - - for _, value := range metric.values { - var err error - var gauge prometheus.Gauge - - gauge, err = gaugeVec.GetMetricWith(value.labels) - - if err == nil { - gauge.Set(value.value) - } else { - e.log.Errorf("Metrics Error: %s", err.Error()) - } - } - - // Collect metric - gaugeVec.Collect(ch) - } - } -} - -// createCounterVec returns a Prometheus CounterVec populated with metric details -func createCounterVec(name, description string, metricLevel MetricLevel) *prometheus.CounterVec { - - labels := getVecDetails(metricLevel) - - counterVec := prometheus.NewCounterVec( - prometheus.CounterOpts{ - Namespace: namespace, - Name: name, - Help: description, - }, - labels, - ) - return counterVec -} - -// createGaugeVec returns a Prometheus GaugeVec populated with metric details -func createGaugeVec(name, description string, metricLevel MetricLevel) *prometheus.GaugeVec { - - labels := getVecDetails(metricLevel) - - gaugeVec := prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Namespace: namespace, - Name: name, - Help: description, - }, - labels, - ) - return gaugeVec -} - -// getVecDetails returns the required prefix and labels for a metric -func getVecDetails(metricLevel MetricLevel) (labels []string) { - - //TODO: What if messageflow is in a library? - if metricLevel == MsgFlowLevel { - labels = []string{msgflowLabel, applicationLabel, serverLabel, originLabel} - } else if metricLevel == MsgFlowNodeLevel { - labels = []string{msgflownodeLabel, msgflownodeTypeLabel, msgflowLabel, applicationLabel, serverLabel, originLabel} - } else if metricLevel == Resource { - labels = []string{serverLabel} - } - - return labels -} diff --git a/internal/metrics/exporter_test.go b/internal/metrics/exporter_test.go deleted file mode 100644 index 9747ee2..0000000 --- a/internal/metrics/exporter_test.go +++ /dev/null @@ -1,314 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package metrics - -import ( - "os" - "testing" - - "github.com/prometheus/client_golang/prometheus" - dto "github.com/prometheus/client_model/go" - "github.com/ot4i/ace-docker/common/logger" -) - -func getTestLogger() logger.LoggerInterface { - log, _ := logger.NewLogger(os.Stdout, false, false, "test") - return log -} - -func TestDescribe(t *testing.T) { - log := getTestLogger() - - ch := make(chan *prometheus.Desc) - go func() { - exporter := newExporter("serverName", log) - exporter.Describe(ch) - }() - - collect := <-requestChannel - if collect { - t.Errorf("Received unexpected collect request") - } - - metrics := NewMetricsMap() - - countMetric := metricData{ - name: "test_count_metric", - description: "This is a test counter metric", - metricType: Total, - metricUnits: Count, - metricLevel: MsgFlowLevel, - } - countMetric.values = make(map[string]*Metric) - - gaugeMetric := metricData{ - name: "test_gauge_metric", - description: "This is a test gauge metric", - metricType: Current, - metricUnits: Count, - metricLevel: Resource, - } - gaugeMetric.values = make(map[string]*Metric) - - metrics.internal["count_metrics"] = &countMetric - metrics.internal["gauge_metrics"] = &gaugeMetric - - responseChannel <- metrics - - expectedDesc1 := "Desc{fqName: \"ibmace_test_count_metric\", help: \"This is a test counter metric\", constLabels: {}, variableLabels: [msgflow application server accountingorigin]}" - expectedDesc2 := "Desc{fqName: \"ibmace_test_gauge_metric\", help: \"This is a test gauge metric\", constLabels: {}, variableLabels: [server]}" - - var found1, found2 bool = false, false - - for i := 0; i < len(metrics.internal); i++ { - prometheusDesc := <-ch - actualDesc := prometheusDesc.String() - - if actualDesc != expectedDesc1 && actualDesc != expectedDesc2 { - t.Errorf("Expected a value of either\n- %s OR\n- %s\n\nActual value was - %s", expectedDesc1, expectedDesc2, actualDesc) - return - } - - if actualDesc == expectedDesc1 { - if found1 { - t.Errorf("Duplicate metrics sent over channel, was only expected once\n- %s\n", expectedDesc1) - } else { - found1 = true - } - } - - if actualDesc == expectedDesc2 { - if found2 { - t.Errorf("Duplicate metrics sent over channel, was only expected once\n- %s\n", expectedDesc2) - } else { - found2 = true - } - } - } - - if !found1 { - t.Errorf("Expected to find value\n- %s", expectedDesc1) - } - - if !found2 { - t.Errorf("Expected to find value\n- %s", expectedDesc2) - } -} - -func TestCollect_Counters(t *testing.T) { - log := getTestLogger() - - exporter := newExporter("serverName", log) - - exporter.counterMap["count_metrics"] = createCounterVec("test_count_metric", "This is a test counter metric", Resource) - - metrics := NewMetricsMap() - - countMetric := metricData{ - name: "test_count_metric", - description: "This is a test counter metric", - metricType: Total, - metricUnits: Count, - metricLevel: Resource, - } - countMetric.values = make(map[string]*Metric) - metrics.internal["count_metrics"] = &countMetric - - countValues := []float64{0.0, 4.0, 5.0, 0.0, 3.0} - expected := 0.0 - - // Call collect several times and ensure the values are reset and counter is incremented as expected - for _, countValue := range countValues { - expected += countValue - - ch := make(chan prometheus.Metric) - go func() { - exporter.Collect(ch) - close(ch) - }() - - collect := <-requestChannel - if !collect { - t.Errorf("Received unexpected describe request") - } - - countMetric.values["Test1"] = &Metric{labels: prometheus.Labels{serverLabel: "test server1"}, value: countValue} - - responseChannel <- metrics - <-ch - prometheusMetric := dto.Metric{} - exporter.counterMap["count_metrics"].WithLabelValues("test server1").Write(&prometheusMetric) - actual := prometheusMetric.GetCounter().GetValue() - - if actual != expected { - t.Errorf("Expected value=%f; actual=%f", expected, actual) - } - - if len(countMetric.values) != 0 { - t.Errorf("Counter values should be reset after collect: %+v", countMetric.values) - } - } -} - -func TestCollect_Gauges(t *testing.T) { - log := getTestLogger() - - exporter := newExporter("TestServer", log) - - exporter.gaugeMap["gauge_metrics"] = createGaugeVec("test_gauge_metric", "This is a test gauge metric", Resource) - - metrics := NewMetricsMap() - - gaugeMetric := metricData{ - name: "test_gauge_metric", - description: "This is a test gauge metric", - metricType: Current, - metricUnits: Count, - metricLevel: Resource, - } - gaugeMetric.values = make(map[string]*Metric) - metrics.internal["gauge_metrics"] = &gaugeMetric - - gaugeValues := []float64{0.0, 4.0, 5.0, 0.0, 3.0} - - // Call collect several times and ensure the values are reset and counter is incremented as expected - for _, gaugeValue := range gaugeValues { - expected := gaugeValue - - ch := make(chan prometheus.Metric) - go func() { - exporter.Collect(ch) - close(ch) - }() - - collect := <-requestChannel - if !collect { - t.Errorf("Received unexpected describe request") - } - - gaugeMetric.values["Test"] = &Metric{labels: prometheus.Labels{serverLabel: "TestServer"}, value: gaugeValue} - - responseChannel <- metrics - <-ch - prometheusMetric := dto.Metric{} - exporter.gaugeMap["gauge_metrics"].WithLabelValues("TestServer").Write(&prometheusMetric) - actual := prometheusMetric.GetGauge().GetValue() - - if actual != expected { - t.Errorf("Expected value=%f; actual=%f", expected, actual) - } - - if len(gaugeMetric.values) != 1 { - t.Errorf("Gauge values should not be reset after collect: %+v", gaugeMetric.values) - } - } -} - -func TestCreateCounterVec_msgFlow(t *testing.T) { - - ch := make(chan *prometheus.Desc) - counterVec := createCounterVec("MetricName", "MetricDescription", MsgFlowLevel) - go func() { - counterVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [msgflow application server accountingorigin]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} - -func TestCreateCounterVec_MsgFlowNode(t *testing.T) { - - ch := make(chan *prometheus.Desc) - counterVec := createCounterVec("MetricName", "MetricDescription", MsgFlowNodeLevel) - go func() { - counterVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [msgflownode msgflownodetype msgflow application server accountingorigin]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} - -func TestCreateCounterVec_Resource(t *testing.T) { - - ch := make(chan *prometheus.Desc) - counterVec := createCounterVec("MetricName", "MetricDescription", Resource) - go func() { - counterVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [server]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} - -func TestCreateGaugeVec_MsgFlow(t *testing.T) { - - ch := make(chan *prometheus.Desc) - gaugeVec := createGaugeVec("MetricName", "MetricDescription", MsgFlowLevel) - go func() { - gaugeVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [msgflow application server accountingorigin]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} - -func TestCreateGaugeVec_MsgFlowNode(t *testing.T) { - - ch := make(chan *prometheus.Desc) - gaugeVec := createGaugeVec("MetricName", "MetricDescription", MsgFlowNodeLevel) - go func() { - gaugeVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [msgflownode msgflownodetype msgflow application server accountingorigin]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} - -func TestCreateGaugeVec_Resource(t *testing.T) { - - ch := make(chan *prometheus.Desc) - gaugeVec := createGaugeVec("MetricName", "MetricDescription", Resource) - go func() { - gaugeVec.Describe(ch) - }() - description := <-ch - - expected := "Desc{fqName: \"ibmace_MetricName\", help: \"MetricDescription\", constLabels: {}, variableLabels: [server]}" - actual := description.String() - if actual != expected { - t.Errorf("Expected value=%s; actual %s", expected, actual) - } -} diff --git a/internal/metrics/mapping.go b/internal/metrics/mapping.go deleted file mode 100644 index 04e4be2..0000000 --- a/internal/metrics/mapping.go +++ /dev/null @@ -1,280 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package metrics contains code to provide metrics for the queue manager -package metrics - -const ( - ResourceStatisticsData = 0 - AccountingAndStatisticsData = 2 -) - -type MetricType int - -const ( - Total MetricType = 0 - Minimum MetricType = 1 - Maximum MetricType = 2 - Current MetricType = 3 -) - -type MetricUnits int - -const ( - Microseconds MetricUnits = 0 - Seconds MetricUnits = 1 - Bytes MetricUnits = 2 - MegaBytes MetricUnits = 3 - Count MetricUnits = 4 -) - -type MetricLevel int - -const ( - MsgFlowLevel MetricLevel = 0 - MsgFlowNodeLevel MetricLevel = 1 - Resource MetricLevel = 2 -) - -type metricLookup struct { - name string - description string - enabled bool - metricType MetricType - metricUnits MetricUnits - metricLevel MetricLevel -} - -type ThreadStatisticsStruct struct { -} - -type TerminalStatisticsStruct struct { -} - -type NodesStatisticsStruct struct { - Label string `json:"Label"` - Type string `json:"Type"` - TotalElapsedTime int `json:"TotalElapsedTime"` - MaximumElapsedTime int `json:"MaximumElapsedTime"` - MinimumElapsedTime int `json:"MinimumElapsedTime"` - TotalCPUTime int `json:"TotalCPUTime"` - MaximumCPUTime int `json:"MaximumCPUTime"` - MinimumCPUTime int `json:"MinimumCPUTime"` - CountOfInvocations int `json:"CountOfInvocations"` - NumberOfInputTerminals int `json:"NumberOfInputTerminals"` - NumberOfOutputTerminals int `json:"NumberOfOutputTerminals"` - TerminalStatistics []TerminalStatisticsStruct -} - -type MessageFlowStruct struct { - BrokerLabel string `json:"BrokerLabel"` - BrokerUUID string `json:"BrokerUUID"` - ExecutionGroupName string `json:"ExecutionGroupName"` - ExecutionGroupUUID string `json:"ExecutionGroupUUID"` - MessageFlowName string `json:"MessageFlowName"` - ApplicationName string `json:"ApplicationName"` - StartDate string `json:"StartDate"` - StartTime string `json:"StartTime"` - GMTStartTime string `json:"GMTStartTime"` - EndDate string `json:"EndDate"` - EndTime string `json:"EndTime"` - GMTEndTime string `json:"GMTEndTime"` - TotalElapsedTime int `json:"TotalElapsedTime"` - MaximumElapsedTime int `json:"MaximumElapsedTime"` - MinimumElapsedTime int `json:"MinimumElapsedTime"` - TotalCPUTime int `json:"TotalCPUTime"` - MaximumCPUTime int `json:"MaximumCPUTime"` - MinimumCPUTime int `json:"MinimumCPUTime"` - CPUTimeWaitingForInputMessage int `json:"CPUTimeWaitingForInputMessage"` - ElapsedTimeWaitingForInputMessage int `json:"ElapsedTimeWaitingForInputMessage"` - TotalInputMessages int `json:"TotalInputMessages"` - TotalSizeOfInputMessages int `json:"TotalSizeOfInputMessages"` - MaximumSizeOfInputMessages int `json:"MaximumSizeOfInputMessages"` - MinimumSizeOfInputMessages int `json:"MinimumSizeOfInputMessages"` - NumberOfThreadsInPool int `json:"NumberOfThreadsInPool"` - TimesMaximumNumberOfThreadsReached int `json:"TimesMaximumNumberOfThreadsReached"` - TotalNumberOfMQErrors int `json:"TotalNumberOfMQErrors"` - TotalNumberOfMessagesWithErrors int `json:"TotalNumberOfMessagesWithErrors"` - TotalNumberOfErrorsProcessingMessages int `json:"TotalNumberOfErrorsProcessingMessages"` - TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages int `json:"TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages"` - TotalNumberOfCommits int `json:"TotalNumberOfCommits"` - TotalNumberOfBackouts int `json:"TotalNumberOfBackouts"` - AccountingOrigin string `json:"AccountingOrigin"` -} - -type DataStruct struct { - WMQIStatisticsAccounting *WMQIStatisticsAccountingStruct `json:"WMQIStatisticsAccounting,omitempty"` - ResourceStatistics *ResourceStatisticsStruct `json:"ResourceStatistics,omitempty"` -} - -type WMQIStatisticsAccountingStruct struct { - RecordType string `json:"RecordType"` - RecordCode string `json:"RecordCode"` - MessageFlow MessageFlowStruct `json:"MessageFlow"` - NumberOfThreads int `json:"NumberOfThreads"` - ThreadStatistics []ThreadStatisticsStruct `json:"ThreadStatistics"` - NumberOfNodes int `json:"NumberOfNodes"` - Nodes []NodesStatisticsStruct `json:"Nodes"` -} - -type StatisticsDataStruct struct { - Data DataStruct `json:"data"` - Event int `json:"event"` -} - -type ResourceStatisticsStruct struct { - BrokerLabel string `json:"brokerLabel"` - BrokerUUID string `json:"brokerUUID"` - ExecutionGroupName string `json:"executionGroupName"` - ExecutiongGroupUUID string `json:"executionGroupUUID"` - CollectionStartDate string `json:"collectionStartDate"` - CollectionStartTime string `json:"collectionStartTime"` - StartDate string `json:"startDate"` - StartTime string `json:"startTime"` - EndDate string `json:"endDate"` - EndTime string `json:"endTime"` - Timezone string `json:"timezone"` - ResourceType []ResourceTypeStruct `json:"ResourceType"` -} - -type ResourceTypeStruct struct { - Name string `json:"name"` - ResourceIdentifier []map[string]interface{} `json:"resourceIdentifier"` -} - -type JvmDataStruct struct { - SummaryInitial int - SummaryUsed int - SummaryCommitted int - SummaryMax int - SummaryGCTime int - SummaryGCCount int - HeapInitial int - HeapUsed int - HeapCommitted int - HeapMax int - NativeInitial int - NativeUsed int - NativeCommitted int - NativeMax int - ScavengerGCTime int - ScavengerGCCount int - GlobalGCTime int - GlobalGCCount int -} - -func NewJVMData(ma []map[string]interface{}) *JvmDataStruct { - - jvmData := JvmDataStruct{} - - for _, m := range ma { - switch m["name"] { - case "summary": - jvmData.SummaryInitial = int(m["InitialMemoryInMB"].(float64)) - jvmData.SummaryUsed = int(m["UsedMemoryInMB"].(float64)) - jvmData.SummaryCommitted = int(m["CommittedMemoryInMB"].(float64)) - jvmData.SummaryMax = int(m["MaxMemoryInMB"].(float64)) - jvmData.SummaryGCTime = int(m["CumulativeGCTimeInSeconds"].(float64)) - jvmData.SummaryGCCount = int(m["CumulativeNumberOfGCCollections"].(float64)) - case "Heap Memory": - jvmData.HeapInitial = int(m["InitialMemoryInMB"].(float64)) - jvmData.HeapUsed = int(m["UsedMemoryInMB"].(float64)) - jvmData.HeapCommitted = int(m["CommittedMemoryInMB"].(float64)) - jvmData.HeapMax = int(m["MaxMemoryInMB"].(float64)) - case "Non-Heap Memory": - jvmData.NativeInitial = int(m["InitialMemoryInMB"].(float64)) - jvmData.NativeUsed = int(m["UsedMemoryInMB"].(float64)) - jvmData.NativeCommitted = int(m["CommittedMemoryInMB"].(float64)) - jvmData.NativeMax = int(m["MaxMemoryInMB"].(float64)) - case "Garbage Collection - scavenge": - jvmData.ScavengerGCTime = int(m["CumulativeGCTimeInSeconds"].(float64)) - jvmData.ScavengerGCCount = int(m["CumulativeNumberOfGCCollections"].(float64)) - case "Garbage Collection - global": - jvmData.GlobalGCTime = int(m["CumulativeGCTimeInSeconds"].(float64)) - jvmData.GlobalGCCount = int(m["CumulativeNumberOfGCCollections"].(float64)) - } - } - - return &jvmData -} - -// generates metric names mapped from their description -func generateMetricNamesMap() (msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap map[string]metricLookup) { - - msgFlowMetricNamesMap = map[string]metricLookup{ - "MsgFlow/TotalElapsedTime": metricLookup{"msgflow_elapsed_time_seconds_total", "Total elapsed time spent processing messages by the message flow", true, Total, Microseconds, MsgFlowLevel}, - "MsgFlow/MaximumElapsedTime": metricLookup{"msgflow_elapsed_time_seconds_max", "Maximum elapsed time spent processing a message by the message flow", true, Maximum, Microseconds, MsgFlowLevel}, - "MsgFlow/MinimumElapsedTime": metricLookup{"msgflow_elapsed_time_seconds_min", "Minimum elapsed time spent processing a message by the message flow", true, Minimum, Microseconds, MsgFlowLevel}, - "MsgFlow/TotalCpuTime": metricLookup{"msgflow_cpu_time_seconds_total", "Total CPU time spent processing messages by the message flow", true, Total, Microseconds, MsgFlowLevel}, - "MsgFlow/MaximumCpuTime": metricLookup{"msgflow_cpu_time_seconds_max", "Maximum CPU time spent processing a message by the message flow", true, Maximum, Microseconds, MsgFlowLevel}, - "MsgFlow/MinimumCpuTime": metricLookup{"msgflow_cpu_time_seconds_min", "Minimum CPU time spent processing a message by the message flow", true, Minimum, Microseconds, MsgFlowLevel}, - "MsgFlow/TotalSizeOfInputMessages": metricLookup{"msgflow_messages_bytes_total", "Total size of messages processed by the message flow", true, Total, Bytes, MsgFlowLevel}, - "MsgFlow/MaximumSizeOfInputMessages": metricLookup{"msgflow_messages_bytes_max", "Maximum size of message processed by the message flow", true, Maximum, Bytes, MsgFlowLevel}, - "MsgFlow/MinimumSizeOfInputMessages": metricLookup{"msgflow_messages_bytes_min", "Minimum size of message processed by the message flow", true, Minimum, Bytes, MsgFlowLevel}, - "MsgFlow/TotalInputMessages": metricLookup{"msgflow_messages_total", "Total number of messages processed by the message flow", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalCPUTimeWaiting": metricLookup{"msgflow_cpu_time_waiting_seconds_total", "Total CPU time spent waiting for input messages by the message flow", true, Total, Microseconds, MsgFlowLevel}, - "MsgFlow/TotalElapsedTimeWaiting": metricLookup{"msgflow_elapsed_time_waiting_seconds_total", "Total elapsed time spent waiting for input messages by the message flow", true, Total, Microseconds, MsgFlowLevel}, - "MsgFlow/NumberOfThreadsInPool": metricLookup{"msgflow_threads_total", "Number of threads in the pool for the message flow", true, Current, Count, MsgFlowLevel}, - "MsgFlow/TimesMaximumNumberOfThreadsReached": metricLookup{"msgflow_threads_reached_maximum_total", "Number of times that maximum number of threads in the pool for the message flow was reached", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfMQErrors": metricLookup{"msgflow_mq_errors_total", "Total number of MQ errors in the message flow", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfMessagesWithErrors": metricLookup{"msgflow_messages_with_error_total", "Total number of messages processed by the message flow that had errors", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfErrorsProcessingMessages": metricLookup{"msgflow_errors_total", "Total number of errors processing messages by the message flow", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages": metricLookup{"msgflow_aggregation_timeouts_total", "Total number of timeouts waiting for replies to Aggregate messages", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfCommits": metricLookup{"msgflow_commits_total", "Total number of commits by the message flow", true, Total, Count, MsgFlowLevel}, - "MsgFlow/TotalNumberOfBackouts": metricLookup{"msgflow_backouts_total", "Total number of backouts by the message flow", true, Total, Count, MsgFlowLevel}, - } - - msgFlowNodeMetricNamesMap = map[string]metricLookup{ - "MsgFlowNode/TotalElapsedTime": metricLookup{"msgflownode_elapsed_time_seconds_total", "Total elapsed time spent processing messages by the message flow node", true, Total, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/MaximumElapsedTime": metricLookup{"msgflownode_elapsed_time_seconds_max", "Maximum elapsed time spent processing a message by the message flow node", true, Maximum, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/MinimumElapsedTime": metricLookup{"msgflownode_elapsed_time_seconds_min", "Minimum elapsed time spent processing a message by the message flow node", true, Minimum, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/TotalCpuTime": metricLookup{"msgflownode_cpu_time_seconds_total", "Total CPU time spent processing messages by the message flow node", true, Total, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/MaximumCpuTime": metricLookup{"msgflownode_cpu_time_seconds_max", "Maximum CPU time spent processing a message by the message flow node", true, Maximum, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/MinimumCpuTime": metricLookup{"msgflownode_cpu_time_seconds_min", "Minimum CPU time spent processing a message by the message flow node", true, Minimum, Microseconds, MsgFlowNodeLevel}, - "MsgFlowNode/TotalInvocations": metricLookup{"msgflownode_messages_total", "Total number of messages processed by the message flow node", true, Total, Count, MsgFlowNodeLevel}, - "MsgFlowNode/InputTerminals": metricLookup{"msgflownode_input_terminals_total", "Total number of input terminals on the message flow node", true, Current, Count, MsgFlowNodeLevel}, - "MsgFlowNode/OutputTerminals": metricLookup{"msgflownode_output_terminals_total", "Total number of output terminals on the message flow node", true, Current, Count, MsgFlowNodeLevel}, - } - - return -} - -// generates metric names mapped from their description -func generateResourceMetricNamesMap() (jvmMetricNamesMap map[string]metricLookup) { - - jvmMetricNamesMap = map[string]metricLookup{ - "JVM/Summary/InitialMemoryInMB": metricLookup{"jvm_summary_initial_memory_bytes", "Initial memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Summary/UsedMemoryInMB": metricLookup{"jvm_summary_used_memory_bytes", "Used memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Summary/CommittedMemoryInMB": metricLookup{"jvm_summary_committed_memory_bytes", "Committed memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Summary/MaxMemoryInMB": metricLookup{"jvm_summary_max_memory_bytes", "Committed memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Summary/CumulativeGCTimeInSeconds": metricLookup{"jvm_summary_gcs_elapsed_time_seconds_total", "Total time spent in GCs for the JVM", true, Current, Seconds, Resource}, - "JVM/Summary/CumulativeNumberOfGCCollections": metricLookup{"jvm_summary_gcs_total", "Total number of GCs for the JVM", true, Current, Count, Resource}, - "JVM/Heap/InitialMemoryInMB": metricLookup{"jvm_heap_initial_memory_bytes", "Initial heap memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Heap/UsedMemoryInMB": metricLookup{"jvm_heap_used_memory_bytes", "Used heap memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Heap/CommittedMemoryInMB": metricLookup{"jvm_heap_committed_memory_bytes", "Committed heap memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Heap/MaxMemoryInMB": metricLookup{"jvm_heap_max_memory_bytes", "Committed heap memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Native/InitialMemoryInMB": metricLookup{"jvm_native_initial_memory_bytes", "Initial native memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Native/UsedMemoryInMB": metricLookup{"jvm_native_used_memory_bytes", "Used native memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Native/CommittedMemoryInMB": metricLookup{"jvm_native_committed_memory_bytes", "Committed native memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/Native/MaxMemoryInMB": metricLookup{"jvm_native_max_memory_bytes", "Committed native memory for the JVM", true, Current, MegaBytes, Resource}, - "JVM/ScavengerGC/CumulativeGCTimeInSeconds": metricLookup{"jvm_scavenger_gcs_elapsed_time_seconds_total", "Total time spent in scavenger GCs for the JVM", true, Current, Seconds, Resource}, - "JVM/ScavengerGC/CumulativeNumberOfGCCollections": metricLookup{"jvm_scavenger_gcs_total", "Total number of scavenger GCs for the JVM", true, Current, Count, Resource}, - "JVM/GlobalGC/CumulativeGCTimeInSeconds": metricLookup{"jvm_global_gcs_elapsed_time_seconds_total", "Total time spent in global GCs for the JVM", true, Current, Seconds, Resource}, - "JVM/GlobalGC/CumulativeNumberOfGCCollections": metricLookup{"jvm_global_gcs_total", "Total number of global GCs for the JVM", true, Current, Count, Resource}, - } - - return -} diff --git a/internal/metrics/mapping_test.go b/internal/metrics/mapping_test.go deleted file mode 100644 index ea1bbf5..0000000 --- a/internal/metrics/mapping_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package metrics - -import ( - "encoding/json" - "testing" -) - -func TestGenerateMetricNamesMap(t *testing.T) { - - msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap := generateMetricNamesMap() - - if len(msgFlowMetricNamesMap) != 20 { - t.Errorf("Expected mapping-size=%d; actual %d", 20, len(msgFlowMetricNamesMap)) - } - - if len(msgFlowNodeMetricNamesMap) != 9 { - t.Errorf("Expected mapping-size=%d; actual %d", 9, len(msgFlowNodeMetricNamesMap)) - } - - for _, v := range msgFlowMetricNamesMap { - if v.name == "" { - t.Errorf("Name for metricLookup is empty string: %+v", v) - } - if v.description == "" { - t.Errorf("Description for metricLookup is empty string: %+v", v) - } - } - - for _, v := range msgFlowNodeMetricNamesMap { - if v.name == "" { - t.Errorf("Name for metricLookup is empty string: %+v", v) - } - if v.description == "" { - t.Errorf("Description for metricLookup is empty string: %+v", v) - } - } -} - -func TestGenerateResourceMetricNamesMap(t *testing.T) { - - jvmMetricNamesMap := generateResourceMetricNamesMap() - - if len(jvmMetricNamesMap) != 18 { - t.Errorf("Expected mapping-size=%d; actual %d", 18, len(jvmMetricNamesMap)) - } - - for _, v := range jvmMetricNamesMap { - if v.name == "" { - t.Errorf("Name for metricLookup is empty string: %+v", v) - } - if v.description == "" { - t.Errorf("Description for metricLookup is empty string: %+v", v) - } - } -} - -func TestNewJVMData(t *testing.T) { - resourceStatisticsString := "{\"data\":{\"ResourceStatistics\":{\"brokerLabel\":\"integration_server\",\"brokerUUID\":\"\",\"executionGroupName\":\"websockettest\",\"executionGroupUUID\":\"00000000-0000-0000-0000-000000000000\",\"collectionStartDate\":\"2018-08-28\",\"collectionStartTime\":\"21:13:33\",\"startDate\":\"2018-08-30\",\"startTime\":\"13:50:54\",\"endDate\":\"2018-08-30\",\"endTime\":\"13:51:15\",\"timezone\":\"Europe/London\",\"ResourceType\":[{\"name\":\"JVM\",\"resourceIdentifier\":[{\"name\":\"summary\",\"InitialMemoryInMB\":305,\"UsedMemoryInMB\":40,\"CommittedMemoryInMB\":314,\"MaxMemoryInMB\":-1,\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":132},{\"name\":\"Heap Memory\",\"InitialMemoryInMB\":32,\"UsedMemoryInMB\":18,\"CommittedMemoryInMB\":34,\"MaxMemoryInMB\":256},{\"name\":\"Non-Heap Memory\",\"InitialMemoryInMB\":273,\"UsedMemoryInMB\":22,\"CommittedMemoryInMB\":280,\"MaxMemoryInMB\":-1},{\"name\":\"Garbage Collection - scavenge\",\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":131},{\"name\":\"Garbage Collection - global\",\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":1}]}]}},\"event\":0}" - - var sds StatisticsDataStruct - - unmarshallError := json.Unmarshal([]byte(resourceStatisticsString), &sds) - - if unmarshallError != nil { - t.Errorf("Error parsing json: %e", unmarshallError) - } - - // s, _ := json.Marshal(sds) - // t.Errorf("resource json=%s", string(s)) - - for _, v := range sds.Data.ResourceStatistics.ResourceType { - if v.Name == "JVM" { - jvmData := NewJVMData(v.ResourceIdentifier) - if jvmData.SummaryInitial != 305 { - t.Errorf("Expected value=%d; actual=%d", 305, jvmData.SummaryInitial) - } - if jvmData.SummaryUsed != 40 { - t.Errorf("Expected value=%d; actual=%d", 40, jvmData.SummaryUsed) - } - if jvmData.SummaryCommitted != 314 { - t.Errorf("Expected value=%d; actual=%d", 314, jvmData.SummaryCommitted) - } - if jvmData.SummaryMax != -1 { - t.Errorf("Expected value=%d; actual=%d", -1, jvmData.SummaryMax) - } - if jvmData.SummaryGCTime != 0 { - t.Errorf("Expected value=%d; actual=%d", 0, jvmData.SummaryGCTime) - } - if jvmData.SummaryGCCount != 132 { - t.Errorf("Expected value=%d; actual=%d", 132, jvmData.SummaryGCCount) - } - if jvmData.HeapInitial != 32 { - t.Errorf("Expected value=%d; actual=%d", 32, jvmData.HeapInitial) - } - if jvmData.HeapUsed != 18 { - t.Errorf("Expected value=%d; actual=%d", 18, jvmData.HeapUsed) - } - if jvmData.HeapCommitted != 34 { - t.Errorf("Expected value=%d; actual=%d", 34, jvmData.HeapCommitted) - } - if jvmData.HeapMax != 256 { - t.Errorf("Expected value=%d; actual=%d", 256, jvmData.HeapMax) - } - if jvmData.NativeInitial != 273 { - t.Errorf("Expected value=%d; actual=%d", 273, jvmData.NativeInitial) - } - if jvmData.NativeUsed != 22 { - t.Errorf("Expected value=%d; actual=%d", 22, jvmData.NativeUsed) - } - if jvmData.NativeCommitted != 280 { - t.Errorf("Expected value=%d; actual=%d", 280, jvmData.NativeCommitted) - } - if jvmData.NativeMax != -1 { - t.Errorf("Expected value=%d; actual=%d", -1, jvmData.NativeMax) - } - if jvmData.ScavengerGCTime != 0 { - t.Errorf("Expected value=%d; actual=%d", 0, jvmData.ScavengerGCTime) - } - if jvmData.ScavengerGCCount != 131 { - t.Errorf("Expected value=%d; actual=%d", 131, jvmData.ScavengerGCCount) - } - if jvmData.GlobalGCTime != 0 { - t.Errorf("Expected value=%d; actual=%d", 0, jvmData.GlobalGCTime) - } - if jvmData.GlobalGCCount != 1 { - t.Errorf("Expected value=%d; actual=%d", 1, jvmData.GlobalGCCount) - } - } - } - - //TODO: Doesn't seem to give code coverage of scavenger of global gc data - are these values being picked up? -} diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go deleted file mode 100644 index e19d24e..0000000 --- a/internal/metrics/metrics.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package metrics contains code to provide metrics for the queue manager -package metrics - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/ot4i/ace-docker/common/logger" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" -) - -const ( - defaultPort = "9483" -) - -var ( - metricsEnabled = false - metricsServer = &http.Server{Addr: ":" + defaultPort} -) - -// GatherMetrics gathers metrics for the integration server -func GatherMetrics(serverName string, log logger.LoggerInterface) { - log.Println("Metrics: Gathering Metrics...") - metricsEnabled = true - - err := startMetricsGathering(serverName, log) - if err != nil { - log.Errorf("Metrics Error: %s", err.Error()) - StopMetricsGathering() - } -} - -// startMetricsGathering starts gathering metrics for the integration server -func startMetricsGathering(serverName string, log logger.LoggerInterface) error { - - defer func() { - if r := recover(); r != nil { - log.Errorf("Metrics Error: %v", r) - } - }() - - log.Println("Metrics: Starting metrics gathering") - - // Start processing metrics - go processMetrics(log, serverName) - - // Wait for metrics to be ready before starting the Prometheus handler - <-startChannel - - // Register metrics - metricsExporter := newExporter(serverName, log) - err := prometheus.Register(metricsExporter) - if err != nil { - return fmt.Errorf("Metrics: Failed to register metrics: %v", err) - } - - // Setup HTTP server to handle requests from Prometheus - http.Handle("/metrics", promhttp.Handler()) - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("Status: METRICS ACTIVE")) - }) - - go func() { - err = metricsServer.ListenAndServe() - if err != nil && err != http.ErrServerClosed { - log.Errorf("Metrics: Error: Failed to handle metrics request: %v", err) - - StopMetricsGathering() - } - }() - - return nil -} - -// StopMetricsGathering stops gathering metrics for the integration server -func StopMetricsGathering() { - - if metricsEnabled { - - // Stop processing metrics - stopChannel <- true - - // Shutdown HTTP server - timeout, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - metricsServer.Shutdown(timeout) - } -} diff --git a/internal/metrics/update.go b/internal/metrics/update.go deleted file mode 100644 index fec898b..0000000 --- a/internal/metrics/update.go +++ /dev/null @@ -1,593 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package metrics contains code to provide metrics for the queue manager -package metrics - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "flag" - "fmt" - "io/ioutil" - "math" - "net" - "net/http" - "net/http/cookiejar" - "net/url" - "os" - "path/filepath" - "strings" - "sync" - "time" - - "github.com/ot4i/ace-docker/common/logger" - - "github.com/gorilla/websocket" - "github.com/prometheus/client_golang/prometheus" -) - -var ( - addr = flag.String("addr", "localhost:7600", "http service address") - startChannel = make(chan bool) - stopChannel = make(chan bool, 2) - stopping = false - requestChannel = make(chan bool) - responseChannel = make(chan *MetricsMap) - statisticsChannel = make(chan StatisticsDataStruct, 10) // Block on writing to channel if we already have 10 queued so we don't retrieve any more -) - -type MetricsMap struct { - sync.Mutex - internal map[string]*metricData -} - -func NewMetricsMap() *MetricsMap { - return &MetricsMap{ - internal: make(map[string]*metricData), - } -} - -type Metric struct { - labels prometheus.Labels - value float64 -} - -type metricData struct { - name string - description string - values map[string]*Metric - metricType MetricType - metricUnits MetricUnits - metricLevel MetricLevel -} - -/* -Normalise returns a float64 representation of the metric value normalised to a base metric type (seconds, bytes, etc.) -*/ -func (md *metricData) Normalise(value int) float64 { - f := float64(value) - - if f < 0 { - f = 0 - } - - // Convert microseconds to seconds - if md.metricUnits == Microseconds { - f = f / 1000000 - } - - // Convert megabytes to bytes - if md.metricUnits == MegaBytes { - f = f * 1024 * 1024 - } - - return f -} - -func ReadStatistics(log logger.LoggerInterface) { - // Check if the admin server is secure so we know whether to connect with wss or ws - aceAdminServerSecurity := os.Getenv("ACE_ADMIN_SERVER_SECURITY") - if aceAdminServerSecurity == "" { - log.Printf("Metrics: Can't tell if ace admin server security is enabled defaulting to false") - aceAdminServerSecurity = "false" - } else { - log.Printf("Metrics: ACE_ADMIN_SERVER_SECURITY is %s", aceAdminServerSecurity) - } - - var firstConnect = true - - for { - if stopping { - // Stopping will trigger a read error on the c.ReadJSON call and re-entry into this loop, - // but we want to exit this function when that happens - return - } - - var c *websocket.Conn - var dialError error - - // Use wss with TLS if using the admin server is secured - if aceAdminServerSecurity == "true" { - adminServerCACert := os.Getenv("ACE_ADMIN_SERVER_CA") - - caCertPool := x509.NewCertPool() - if stat, err := os.Stat(adminServerCACert); err == nil && stat.IsDir() { - // path is a directory load all certs - log.Printf("Metrics: Using CA Certificate folder %s", adminServerCACert) - filepath.Walk(adminServerCACert, func(cert string, info os.FileInfo, err error) error { - if strings.HasSuffix(cert, "crt.pem") { - log.Printf("Metrics: Adding Certificate %s to CA pool", cert) - binaryCert, err := ioutil.ReadFile(cert) - if err != nil { - log.Errorf("Metrics: Error reading CA Certificate %s", err) - } - ok := caCertPool.AppendCertsFromPEM(binaryCert) - if !ok { - log.Errorf("Metrics: Failed to parse Certificate %s", cert) - } - } - return nil - }) - } else { - log.Printf("Metrics: Using CA Certificate file %s", adminServerCACert) - caCert, err := ioutil.ReadFile(adminServerCACert) - if err != nil { - log.Errorf("Metrics: Error reading CA Certificate %s", err) - return - } - ok := caCertPool.AppendCertsFromPEM(caCert) - if !ok { - log.Errorf("Metrics: failed to parse root CA Certificate") - } - } - - // Read the key/ cert pair to create tls certificate - adminServerCert := os.Getenv("ACE_ADMIN_SERVER_CERT") - adminServerKey := os.Getenv("ACE_ADMIN_SERVER_KEY") - adminServerCerts, err := tls.LoadX509KeyPair(adminServerCert, adminServerKey) - if err != nil { - if adminServerCert != "" && adminServerKey != "" { - log.Errorf("Metrics: Error reading TLS Certificates: %s", err) - return - } - } else { - log.Printf("Metrics: Using provided cert and key for mutual auth") - } - - aceAdminServerName := os.Getenv("ACE_ADMIN_SERVER_NAME") - if aceAdminServerName == "" { - log.Printf("Metrics: No ace admin server name available") - return - } else { - log.Printf("Metrics: ACE_ADMIN_SERVER_NAME is %s", aceAdminServerName) - } - - u := url.URL{Scheme: "wss", Host: *addr, Path: "/"} - log.Printf("Metrics: Connecting to %s for statistics gathering", u.String()) - d := websocket.Dialer{ - TLSClientConfig: &tls.Config{ - RootCAs: caCertPool, - Certificates: []tls.Certificate{adminServerCerts}, - ServerName: aceAdminServerName, - }, - } - - // Retrieve session if the webusers exist - contentBytes, err := ioutil.ReadFile("/home/aceuser/initial-config/webusers/admin-users.txt") - if err != nil { - log.Printf("Metrics: Cannot find webusers/admin-users.txt file, connecting without user authentication") - } else { - log.Printf("Metrics: Using provided webusers/admin-users.txt, connecting with user authentication") - userPassword := strings.Fields(string(contentBytes)) - username := userPassword[0] - password := userPassword[1] - - var conn *tls.Conn - httpUrl := url.URL{Scheme: "https", Host: *addr, Path: "/"} - tlsConfig := &tls.Config{ - RootCAs: caCertPool, - Certificates: []tls.Certificate{adminServerCerts}, - ServerName: aceAdminServerName, - } - client := &http.Client{ - Transport: &http.Transport{ - DialTLS: func(network, addr string) (net.Conn, error) { - conn, err = tls.Dial(network, addr, tlsConfig) - return conn, err - }, - }, - } - req, _ := http.NewRequest("GET", httpUrl.String(), nil) - req.SetBasicAuth(username, password) - resp, err := client.Do(req) - if err != nil { - log.Errorf("Metrics: Error retrieving session: %s", err) - } - - jar, _ := cookiejar.New(nil) - if resp != nil { - cookies := resp.Cookies() - jar.SetCookies(&httpUrl, cookies) - } - - if jar.Cookies(&httpUrl) != nil { - log.Printf("Metrics: Connecting to %s using session cookie and SSL", u.String()) - d.Jar = jar - } else { - log.Printf("Metrics: Connecting to %s with SSL", u.String()) - } - } - - // Create the websocket connection - c, _, dialError = d.Dial(u.String(), http.Header{"Origin": {u.String()}}) - } else { - wsUrl := url.URL{Scheme: "ws", Host: *addr, Path: "/"} - log.Printf("Metrics: Connecting to %s for statistics", wsUrl.String()) - - d := websocket.DefaultDialer - - // Retrieve session if the webusers exist - contentBytes, err := ioutil.ReadFile("/home/aceuser/initial-config/webusers/admin-users.txt") - if err != nil { - log.Printf("Metrics: Cannot find admin-users.txt file, not retrieving session") - } else { - log.Printf("Metrics: Using provided webusers/admin-users.txt for basic auth session cookie") - userPassword := strings.Fields(string(contentBytes)) - username := userPassword[0] - password := userPassword[1] - - httpUrl := url.URL{Scheme: "http", Host: *addr, Path: "/"} - client := &http.Client{} - req, _ := http.NewRequest("GET", httpUrl.String(), nil) - req.SetBasicAuth(username, password) - resp, err := client.Do(req) - if err != nil { - log.Errorf("Metrics: Error retrieving session: %s", err) - } - - jar, _ := cookiejar.New(nil) - if resp != nil { - cookies := resp.Cookies() - jar.SetCookies(&httpUrl, cookies) - } - - if jar.Cookies(&httpUrl) != nil { - log.Printf("Metrics: Connecting to %s using session cookie", wsUrl.String()) - d.Jar = jar - } else { - log.Printf("Metrics: Connecting to %s without using session cookie", wsUrl.String()) - } - } - // Create the websocket connection - c, _, dialError = d.Dial(wsUrl.String(), http.Header{"Origin": {wsUrl.String()}}) - } - - if dialError == nil { - log.Printf("Metrics: Connected") - if firstConnect { - firstConnect = false - startChannel <- true - } - - defer c.Close() - - // Loop reading from websocket and put messages on the statistics statisticsChannel - // End the loop and reconnect if there is an error reading from the websocket - var readError error - for readError == nil { - var m StatisticsDataStruct - - readError = c.ReadJSON(&m) - if readError == nil { - statisticsChannel <- m - } - } - } else { - log.Errorf("Metrics: Error calling ace admin server webservice endpoint %s", dialError) - log.Println("Metrics: If this repeats then check you have assigned enough memory to your Pod and you aren't running out of memory") - log.Println("Metrics: Sleeping for 5 seconds before retrying to connect to metrics...") - time.Sleep(5 * time.Second) - } - } -} - -// processMetrics processes publications of metric data and handles describe/collect/stop requests -func processMetrics(log logger.LoggerInterface, serverName string) { - log.Println("Metrics: Processing metrics...") - - metrics := initialiseMetrics(log) - - go ReadStatistics(log) - - // Handle update/describe/collect/stop requests - for { - select { - case m := <-statisticsChannel: - newMetrics, parseError := parseMetrics(log, &m) - - if parseError != nil { - log.Println("Metrics: Parse Error:", parseError) - } else { - updateMetrics(log, metrics, newMetrics) - } - case <-requestChannel: - responseChannel <- metrics - case <-stopChannel: - log.Println("Stopping metrics gathering") - stopping = true - return - } - } -} - -// initialiseMetrics sets initial details for all available metrics -func initialiseMetrics(log logger.LoggerInterface) *MetricsMap { - - metrics := NewMetricsMap() - msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap := generateMetricNamesMap() - - for k, v := range msgFlowMetricNamesMap { - if v.enabled { - // Set metric details - metric := metricData{ - name: v.name, - description: v.description, - metricType: v.metricType, - metricUnits: v.metricUnits, - metricLevel: v.metricLevel, - } - metric.values = make(map[string]*Metric) - - // Add metric - metrics.internal[k] = &metric - } - } - - for k, v := range msgFlowNodeMetricNamesMap { - if v.enabled { - // Set metric details - metric := metricData{ - name: v.name, - description: v.description, - metricType: v.metricType, - metricUnits: v.metricUnits, - metricLevel: v.metricLevel, - } - metric.values = make(map[string]*Metric) - - // Add metric - metrics.internal[k] = &metric - } - } - - jvmResourceMetricNamesMap := generateResourceMetricNamesMap() - - for k, v := range jvmResourceMetricNamesMap { - if v.enabled { - // Set metric details - metric := metricData{ - name: v.name, - description: v.description, - metricType: v.metricType, - metricUnits: v.metricUnits, - metricLevel: v.metricLevel, - } - metric.values = make(map[string]*Metric) - - // Add metric - metrics.internal[k] = &metric - } - } - - return metrics -} - -func parseMetrics(log logger.LoggerInterface, m *StatisticsDataStruct) (*MetricsMap, error) { - if m.Event == ResourceStatisticsData { - return parseResourceMetrics(log, m) - } else if m.Event == AccountingAndStatisticsData { - return parseAccountingMetrics(log, m) - } else { - return nil, fmt.Errorf("Metrics: Unable to parse data with event: %d", m.Event) - } -} - -func parseAccountingMetrics(log logger.LoggerInterface, m *StatisticsDataStruct) (*MetricsMap, error) { - parsedMetrics := NewMetricsMap() - - msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap := generateMetricNamesMap() - - accountingOrigin := m.Data.WMQIStatisticsAccounting.MessageFlow.AccountingOrigin - serverName := m.Data.WMQIStatisticsAccounting.MessageFlow.ExecutionGroupName - applicationName := m.Data.WMQIStatisticsAccounting.MessageFlow.ApplicationName - msgflowName := m.Data.WMQIStatisticsAccounting.MessageFlow.MessageFlowName - - if msgflowName == "" { - err := errors.New("Metrics: parse error - no message flow name in statistics") - return parsedMetrics, err - } - - flowValuesMap := map[string]int{ - "MsgFlow/TotalElapsedTime": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalElapsedTime, - "MsgFlow/MaximumElapsedTime": m.Data.WMQIStatisticsAccounting.MessageFlow.MaximumElapsedTime, - "MsgFlow/MinimumElapsedTime": m.Data.WMQIStatisticsAccounting.MessageFlow.MinimumElapsedTime, - "MsgFlow/TotalCpuTime": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalCPUTime, - "MsgFlow/MaximumCpuTime": m.Data.WMQIStatisticsAccounting.MessageFlow.MaximumCPUTime, - "MsgFlow/MinimumCpuTime": m.Data.WMQIStatisticsAccounting.MessageFlow.MinimumCPUTime, - "MsgFlow/TotalSizeOfInputMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalSizeOfInputMessages, - "MsgFlow/MaximumSizeOfInputMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.MaximumSizeOfInputMessages, - "MsgFlow/MinimumSizeOfInputMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.MinimumSizeOfInputMessages, - "MsgFlow/TotalInputMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalInputMessages, - "MsgFlow/TotalCPUTimeWaiting": m.Data.WMQIStatisticsAccounting.MessageFlow.CPUTimeWaitingForInputMessage, - "MsgFlow/TotalElapsedTimeWaiting": m.Data.WMQIStatisticsAccounting.MessageFlow.ElapsedTimeWaitingForInputMessage, - "MsgFlow/NumberOfThreadsInPool": m.Data.WMQIStatisticsAccounting.MessageFlow.NumberOfThreadsInPool, - "MsgFlow/TimesMaximumNumberOfThreadsReached": m.Data.WMQIStatisticsAccounting.MessageFlow.TimesMaximumNumberOfThreadsReached, - "MsgFlow/TotalNumberOfMQErrors": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfMQErrors, - "MsgFlow/TotalNumberOfMessagesWithErrors": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfMessagesWithErrors, - "MsgFlow/TotalNumberOfErrorsProcessingMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfErrorsProcessingMessages, - "MsgFlow/TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages, - "MsgFlow/TotalNumberOfCommits": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfCommits, - "MsgFlow/TotalNumberOfBackouts": m.Data.WMQIStatisticsAccounting.MessageFlow.TotalNumberOfBackouts, - } - - /* - Process flow level accounting and statistics data - */ - for k, v := range flowValuesMap { - metricDesc := msgFlowMetricNamesMap[k] - if metricDesc.enabled { - metric := metricData{ - name: metricDesc.name, - description: metricDesc.description, - metricType: metricDesc.metricType, - metricUnits: metricDesc.metricUnits, - metricLevel: metricDesc.metricLevel, - } - metric.values = make(map[string]*Metric) - metric.values[accountingOrigin+"_"+applicationName+"_"+msgflowName] = &Metric{labels: prometheus.Labels{msgflowPrefix: msgflowName, serverLabel: serverName, applicationLabel: applicationName, originLabel: accountingOrigin}, value: metric.Normalise(v)} - parsedMetrics.internal[k] = &metric - } - } - - /* - Process node level accounting and statistics data - */ - for k, v := range msgFlowNodeMetricNamesMap { - - if v.enabled { - metric := metricData{ - name: v.name, - description: v.description, - metricType: v.metricType, - metricUnits: v.metricUnits, - metricLevel: v.metricLevel, - } - metric.values = make(map[string]*Metric) - - for _, node := range m.Data.WMQIStatisticsAccounting.Nodes { - nodeValuesMap := map[string]int{ - "MsgFlowNode/TotalElapsedTime": node.TotalElapsedTime, - "MsgFlowNode/MaximumElapsedTime": node.MaximumElapsedTime, - "MsgFlowNode/MinimumElapsedTime": node.MinimumElapsedTime, - "MsgFlowNode/TotalCpuTime": node.TotalCPUTime, - "MsgFlowNode/MaximumCpuTime": node.MaximumCPUTime, - "MsgFlowNode/MinimumCpuTime": node.MinimumCPUTime, - "MsgFlowNode/TotalInvocations": node.CountOfInvocations, - "MsgFlowNode/InputTerminals": node.NumberOfInputTerminals, - "MsgFlowNode/OutputTerminals": node.NumberOfOutputTerminals, - } - msgflownodeName := node.Label - msgflownodeType := node.Type - - metric.values[accountingOrigin+"_"+applicationName+"_"+msgflowName+"_"+msgflownodeName] = &Metric{labels: prometheus.Labels{msgflownodeLabel: msgflownodeName, msgflownodeTypeLabel: msgflownodeType, msgflowLabel: msgflowName, serverLabel: serverName, applicationLabel: applicationName, originLabel: accountingOrigin}, value: metric.Normalise(nodeValuesMap[k])} - } - parsedMetrics.internal[k] = &metric - } - } - - return parsedMetrics, nil -} - -func parseResourceMetrics(log logger.LoggerInterface, m *StatisticsDataStruct) (*MetricsMap, error) { - parsedResourceMetrics := NewMetricsMap() - - serverName := m.Data.ResourceStatistics.ExecutionGroupName - - for _, v := range m.Data.ResourceStatistics.ResourceType { - switch v.Name { - case "JVM": - jvmData := NewJVMData(v.ResourceIdentifier) - - jvmResourceMetricNamesMap := generateResourceMetricNamesMap() - - jvmValuesMap := map[string]int{ - "JVM/Summary/InitialMemoryInMB": jvmData.SummaryInitial, - "JVM/Summary/UsedMemoryInMB": jvmData.SummaryUsed, - "JVM/Summary/CommittedMemoryInMB": jvmData.SummaryCommitted, - "JVM/Summary/MaxMemoryInMB": jvmData.SummaryMax, - "JVM/Summary/CumulativeGCTimeInSeconds": jvmData.SummaryGCTime, - "JVM/Summary/CumulativeNumberOfGCCollections": jvmData.SummaryGCCount, - "JVM/Heap/InitialMemoryInMB": jvmData.HeapInitial, - "JVM/Heap/UsedMemoryInMB": jvmData.HeapUsed, - "JVM/Heap/CommittedMemoryInMB": jvmData.HeapCommitted, - "JVM/Heap/MaxMemoryInMB": jvmData.HeapMax, - "JVM/Native/InitialMemoryInMB": jvmData.NativeInitial, - "JVM/Native/UsedMemoryInMB": jvmData.NativeUsed, - "JVM/Native/CommittedMemoryInMB": jvmData.NativeCommitted, - "JVM/Native/MaxMemoryInMB": jvmData.NativeMax, - "JVM/ScavengerGC/CumulativeGCTimeInSeconds": jvmData.ScavengerGCTime, - "JVM/ScavengerGC/CumulativeNumberOfGCCollections": jvmData.ScavengerGCCount, - "JVM/GlobalGC/CumulativeGCTimeInSeconds": jvmData.GlobalGCTime, - "JVM/GlobalGC/CumulativeNumberOfGCCollections": jvmData.GlobalGCCount, - } - - for metricKey, metricDesc := range jvmResourceMetricNamesMap { - if metricDesc.enabled { - metric := metricData{ - name: metricDesc.name, - description: metricDesc.description, - metricType: metricDesc.metricType, - metricUnits: metricDesc.metricUnits, - metricLevel: metricDesc.metricLevel, - } - metric.values = make(map[string]*Metric) - metric.values[metricKey] = &Metric{labels: prometheus.Labels{serverLabel: serverName}, value: metric.Normalise(jvmValuesMap[metricKey])} - parsedResourceMetrics.internal[metricKey] = &metric - } - } - default: - //TODO: Support other resource statistic types - } - } - - return parsedResourceMetrics, nil -} - -// updateMetrics updates values for all available metrics -func updateMetrics(log logger.LoggerInterface, mm1 *MetricsMap, mm2 *MetricsMap) { - mm1.Lock() - mm2.Lock() - defer mm1.Unlock() - defer mm2.Unlock() - - for k, md2 := range mm2.internal { - if md1, ok := mm1.internal[k]; ok { - //Iterate over the labels - for l, m2 := range md2.values { - if m1, ok := md1.values[l]; ok { - switch md1.metricType { - case Total: - md1.values[l].value = m1.value + m2.value - case Maximum: - md1.values[l].value = math.Max(m1.value, m2.value) - case Minimum: - md1.values[l].value = math.Min(m1.value, m2.value) - case Current: - md1.values[l].value = m2.value - default: - log.Printf("Metrics: Should not reach here - only a set enumeration of metric types. %d is unknown...", md1.metricType) - } - } else { - md1.values[l] = m2 - } - } - } else { - mm1.internal[k] = mm2.internal[k] - } - } -} diff --git a/internal/metrics/update_test.go b/internal/metrics/update_test.go deleted file mode 100644 index 11be2eb..0000000 --- a/internal/metrics/update_test.go +++ /dev/null @@ -1,550 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package metrics - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/prometheus/client_golang/prometheus" -) - -var normaliseTests = []struct { - md metricData - val int - expected float64 -}{ - {metricData{metricUnits: Microseconds}, 1, 0.000001}, - {metricData{metricUnits: Microseconds}, 2000, 0.002}, - {metricData{metricUnits: Microseconds}, 0, 0.0}, - {metricData{metricUnits: Microseconds}, -1, 0.0}, - {metricData{metricUnits: Seconds}, 1, 1.0}, - {metricData{metricUnits: Seconds}, 100, 100.0}, - {metricData{metricUnits: Seconds}, 0, 0.0}, - {metricData{metricUnits: Seconds}, -1, 0.0}, - {metricData{metricUnits: Bytes}, 1, 1.0}, - {metricData{metricUnits: Bytes}, 1999, 1999.0}, - {metricData{metricUnits: Bytes}, 0, 0.0}, - {metricData{metricUnits: Bytes}, -1, 0.0}, - {metricData{metricUnits: MegaBytes}, 1, 1048576.0}, - {metricData{metricUnits: MegaBytes}, 50, 52428800.0}, - {metricData{metricUnits: MegaBytes}, 0, 0.0}, - {metricData{metricUnits: MegaBytes}, -1, 0.0}, - {metricData{metricUnits: Count}, 1, 1.0}, - {metricData{metricUnits: Count}, 542, 542.0}, - {metricData{metricUnits: Count}, 0, 0.0}, - {metricData{metricUnits: Count}, -1, 0.0}, -} - -func TestNormalise(t *testing.T) { - for _, tt := range normaliseTests { - t.Run(fmt.Sprintf("%d:%d", tt.md.metricUnits, tt.val), func(t *testing.T) { - actual := tt.md.Normalise(tt.val) - if actual != tt.expected { - t.Errorf("Expected %d of type %d to normalise to %f, but got %f", tt.val, tt.md.metricUnits, tt.expected, actual) - } - }) - } -} - -func TestInitialiseMetrics(t *testing.T) { - - /* - Get all the metric maps - */ - msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap := generateMetricNamesMap() - jvmMetricNamesMap := generateResourceMetricNamesMap() - - /* - Merge all the metric name maps into a single map to iterate over - */ - metricMapArray := [3]map[string]metricLookup{msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap, jvmMetricNamesMap} - - aggregatedMetricsMap := make(map[string]metricLookup) - disabledMetricsMap := make(map[string]metricLookup) - - for _, m := range metricMapArray { - for k, v := range m { - if v.enabled { - aggregatedMetricsMap[k] = v - } else { - disabledMetricsMap[k] = v - } - } - } - - /* - Initialise the metrics and check that: - - All entries from the metric name maps that are enabled are included - - There are no entries that are not in the metric name maps - */ - metrics := initialiseMetrics(getTestLogger()) - - t.Logf("Iterating over aggregated metric name maps") - for k, v := range aggregatedMetricsMap { - t.Logf("- %s", k) - - metric, ok := metrics.internal[k] - if !ok { - t.Error("Expected metric not found in map") - } else { - if metric.name != v.name { - t.Errorf("Expected name=%s; actual %s", v.name, metric.name) - } - if metric.description != v.description { - t.Errorf("Expected description=%s; actual %s", v.description, metric.description) - } - if metric.metricType != v.metricType { - t.Errorf("Expected metricType=%v; actual %v", v.metricType, metric.metricType) - } - if metric.metricLevel != v.metricLevel { - t.Errorf("Expected metricLevel=%v; actual %v", v.metricLevel, metric.metricLevel) - } - if metric.metricUnits != v.metricUnits { - t.Errorf("Expected metricUnits=%v; actual %v", v.metricUnits, metric.metricUnits) - } - if len(metric.values) != 0 { - t.Errorf("Expected values-size=%d; actual %d", 0, len(metric.values)) - } - } - } - - if len(metrics.internal) != len(aggregatedMetricsMap) { - t.Errorf("Map contains unexpected metrics, map size=%d", len(metrics.internal)) - } - - t.Logf("Iterating over map of disabled metric names") - for k, _ := range disabledMetricsMap { - t.Logf("- %s", k) - - metric, ok := metrics.internal[k] - if ok { - t.Errorf("Unexpected metric (%s) found in map: %+v", metric.name, metric) - } - } -} - -func TestParseMetrics_AccountingAndStatistics(t *testing.T) { - log := getTestLogger() - - expectedValues := map[string]int{ - "MsgFlow/TotalElapsedTime": 310845, - "MsgFlow/MaximumElapsedTime": 54772, - "MsgFlow/MinimumElapsedTime": 49184, - "MsgFlow/TotalCpuTime": 262984, - "MsgFlow/MaximumCpuTime": 53386, - "MsgFlow/MinimumCpuTime": 40644, - "MsgFlow/TotalSizeOfInputMessages": 2376, - "MsgFlow/MaximumSizeOfInputMessages": 396, - "MsgFlow/MinimumSizeOfInputMessages": 396, - "MsgFlow/TotalInputMessages": 6, - "MsgFlow/TotalCPUTimeWaiting": 125000, - "MsgFlow/TotalElapsedTimeWaiting": 18932397, - "MsgFlow/NumberOfThreadsInPool": 1, - "MsgFlow/TimesMaximumNumberOfThreadsReached": 6, - "MsgFlow/TotalNumberOfMQErrors": 0, - "MsgFlow/TotalNumberOfMessagesWithErrors": 0, - "MsgFlow/TotalNumberOfErrorsProcessingMessages": 0, - "MsgFlow/TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages": 0, - "MsgFlow/TotalNumberOfCommits": 0, - "MsgFlow/TotalNumberOfBackouts": 0, - } - - expectedNodeValues := map[string]int{ - "HTTP Input/MsgFlowNode/TotalElapsedTime": 62219, - "HTTP Input/MsgFlowNode/MaximumElapsedTime": 11826, - "HTTP Input/MsgFlowNode/MinimumElapsedTime": 8797, - "HTTP Input/MsgFlowNode/TotalCpuTime": 20747, - "HTTP Input/MsgFlowNode/MaximumCpuTime": 10440, - "HTTP Input/MsgFlowNode/MinimumCpuTime": 1, - "HTTP Input/MsgFlowNode/TotalInvocations": 6, - "HTTP Input/MsgFlowNode/InputTerminals": 0, - "HTTP Input/MsgFlowNode/OutputTerminals": 4, - "HTTP Reply/MsgFlowNode/TotalElapsedTime": 248626, - "HTTP Reply/MsgFlowNode/MaximumElapsedTime": 42946, - "HTTP Reply/MsgFlowNode/MinimumElapsedTime": 37639, - "HTTP Reply/MsgFlowNode/TotalCpuTime": 242237, - "HTTP Reply/MsgFlowNode/MaximumCpuTime": 42946, - "HTTP Reply/MsgFlowNode/MinimumCpuTime": 31250, - "HTTP Reply/MsgFlowNode/TotalInvocations": 6, - "HTTP Reply/MsgFlowNode/InputTerminals": 1, - "HTTP Reply/MsgFlowNode/OutputTerminals": 2, - } - - /* - Parse a JSON string into a StatisticsDataStruct - */ - accountingAndStatisticsString := - "{\"data\":{\"WMQIStatisticsAccounting\":{\"RecordType\":\"SnapShot\",\"RecordCode\":\"SnapShot\",\"MessageFlow\":{\"BrokerLabel\":\"integration_server\",\"BrokerUUID\":\"\",\"ExecutionGroupName\":\"testintegrationserver\",\"ExecutionGroupUUID\":\"00000000-0000-0000-0000-000000000000\",\"MessageFlowName\":\"msgflow1\",\"ApplicationName\":\"application1\",\"StartDate\":\"2018-08-30\",\"StartTime\":\"13:51:11.277\",\"GMTStartTime\":\"2018-08-30T12:51:11.277+00:00\",\"EndDate\":\"2018-08-30\",\"EndTime\":\"13:51:31.514\",\"GMTEndTime\":\"2018-08-30T12:51:31.514+00:00\",\"TotalElapsedTime\":310845,\"MaximumElapsedTime\":54772,\"MinimumElapsedTime\":49184,\"TotalCPUTime\":262984,\"MaximumCPUTime\":53386,\"MinimumCPUTime\":40644,\"CPUTimeWaitingForInputMessage\":125000,\"ElapsedTimeWaitingForInputMessage\":18932397,\"TotalInputMessages\":6,\"TotalSizeOfInputMessages\":2376,\"MaximumSizeOfInputMessages\":396,\"MinimumSizeOfInputMessages\":396,\"NumberOfThreadsInPool\":1,\"TimesMaximumNumberOfThreadsReached\":6,\"TotalNumberOfMQErrors\":0,\"TotalNumberOfMessagesWithErrors\":0,\"TotalNumberOfErrorsProcessingMessages\":0,\"TotalNumberOfTimeOutsWaitingForRepliesToAggregateMessages\":0,\"TotalNumberOfCommits\":0,\"TotalNumberOfBackouts\":0,\"AccountingOrigin\":\"Anonymous\"},\"NumberOfThreads\":0,\"ThreadStatistics\":[],\"NumberOfNodes\":2,\"Nodes\":[{\"Label\":\"HTTP Input\",\"Type\":\"WSInputNode\",\"TotalElapsedTime\":62219,\"MaximumElapsedTime\":11826,\"MinimumElapsedTime\":8797,\"TotalCPUTime\":20747,\"MaximumCPUTime\":10440,\"MinimumCPUTime\":1,\"CountOfInvocations\":6,\"NumberOfInputTerminals\":0,\"NumberOfOutputTerminals\":4,\"TerminalStatistics\":[]},{\"Label\":\"HTTP Reply\",\"Type\":\"WSReplyNode\",\"TotalElapsedTime\":248626,\"MaximumElapsedTime\":42946,\"MinimumElapsedTime\":37639,\"TotalCPUTime\":242237,\"MaximumCPUTime\":42946,\"MinimumCPUTime\":31250,\"CountOfInvocations\":6,\"NumberOfInputTerminals\":1,\"NumberOfOutputTerminals\":2,\"TerminalStatistics\":[]}]}},\"event\":2}" - - var sds StatisticsDataStruct - - unmarshallError := json.Unmarshal([]byte(accountingAndStatisticsString), &sds) - - if unmarshallError != nil { - t.Errorf("Error parsing json: %e", unmarshallError) - return - } - - mm, parseError := parseMetrics(log, &sds) - if parseError != nil { - t.Errorf("Error parsing metrics: %e", parseError) - return - } - msgFlowMetricNamesMap, msgFlowNodeMetricNamesMap := generateMetricNamesMap() - - for k, v := range msgFlowMetricNamesMap { - if v.enabled == false { - metric, ok := mm.internal[k] - if ok { - t.Errorf("Unexpected metric (%s) found in map: %+v", k, metric) - } - } else { - metric, ok := mm.internal[k] - if !ok { - t.Errorf("Missing expected metric (%s)", k) - } - if metric.name != v.name { - t.Errorf("Expected name=%s; actual %s", v.name, metric.name) - } - if metric.description != v.description { - t.Errorf("Expected description=%s; actual %s", v.description, metric.description) - } - if metric.metricType != v.metricType { - t.Errorf("Expected metricType=%v; actual %v", v.metricType, metric.metricType) - } - if metric.metricLevel != v.metricLevel { - t.Errorf("Expected metricLevel=%v; actual %v", v.metricLevel, metric.metricLevel) - } - if metric.metricUnits != v.metricUnits { - t.Errorf("Expected metricUnits=%v; actual %v", v.metricUnits, metric.metricUnits) - } - if len(metric.values) != 1 { - t.Errorf("Expected values-size=%d; actual %d", 1, len(metric.values)) - } - - for vk, values := range metric.values { - if vk != "Anonymous_application1_msgflow1" { - t.Errorf("Expected values key=%s; actual %s", "Anonymous_application1_msgflow1", vk) - } - - for label, labelValue := range values.labels { - switch label { - case serverLabel: - if labelValue != "testintegrationserver" { - t.Errorf("Expected server label=%s; actual %s", "testintegrationserver", labelValue) - } - case applicationLabel: - if labelValue != "application1" { - t.Errorf("Expected application label=%s; actual %s", "application1", labelValue) - } - case msgflowPrefix: - if labelValue != "msgflow1" { - t.Errorf("Expected msgflow label=%s; actual %s", "msgflow1", labelValue) - } - case originLabel: - if labelValue != "Anonymous" { - t.Errorf("Expected origin label=%s; actual %s", "Anonymous", labelValue) - } - default: - t.Errorf("Unexpected label (%s) found for metric: %s", label, metric.name) - } - } - - if values.value != metric.Normalise(expectedValues[k]) { - t.Errorf("Expected %s value=%f; actual %f", metric.name, metric.Normalise(expectedValues[k]), values.value) - } - } - } - } - - for k, v := range msgFlowNodeMetricNamesMap { - if v.enabled == false { - metric, ok := mm.internal[k] - if ok { - t.Errorf("Unexpected metric (%s) found in map: %+v", metric.name, metric) - } - } else { - metric, ok := mm.internal[k] - if !ok { - t.Errorf("Missing expected metric (%s)", k) - } - if metric.name != v.name { - t.Errorf("Expected name=%s; actual %s", v.name, metric.name) - } - if metric.description != v.description { - t.Errorf("Expected description=%s; actual %s", v.description, metric.description) - } - if metric.metricType != v.metricType { - t.Errorf("Expected metricType=%v; actual %v", v.metricType, metric.metricType) - } - if metric.metricLevel != v.metricLevel { - t.Errorf("Expected metricLevel=%v; actual %v", v.metricLevel, metric.metricLevel) - } - if metric.metricUnits != v.metricUnits { - t.Errorf("Expected metricUnits=%v; actual %v", v.metricUnits, metric.metricUnits) - } - if len(metric.values) != 2 { - t.Errorf("Expected values-size=%d; actual %d", 2, len(metric.values)) - } - - for vk, values := range metric.values { - - nodeName, ok := values.labels["msgflownode"] - if !ok { - t.Errorf("Missing label for msgflownode name: %s", k) - } - - if vk != "Anonymous_application1_msgflow1_"+nodeName { - t.Errorf("Expected values key=%s; actual %s", "Anonymous_application1_msgflow1_"+nodeName, vk) - } - - for label, labelValue := range values.labels { - switch label { - case serverLabel: - if labelValue != "testintegrationserver" { - t.Errorf("Expected server label=%s; actual %s", "testintegrationserver", labelValue) - } - case applicationLabel: - if labelValue != "application1" { - t.Errorf("Expected application label=%s; actual %s", "application1", labelValue) - } - case msgflowPrefix: - if labelValue != "msgflow1" { - t.Errorf("Expected msgflow label=%s; actual %s", "msgflow1", labelValue) - } - case originLabel: - if labelValue != "Anonymous" { - t.Errorf("Expected origin label=%s; actual %s", "Anonymous", labelValue) - } - case msgflownodeLabel: - // TODO: Check label value - case msgflownodeTypeLabel: - // TODO: Check label value - default: - t.Errorf("Unexpected label (%s) found for metric: %s", label, metric.name) - } - } - - if values.value != metric.Normalise(expectedNodeValues[nodeName+"/"+k]) { - t.Errorf("Expected %s value=%f; actual %f", metric.name, metric.Normalise(expectedValues[nodeName+"/"+k]), values.value) - } - } - } - } -} - -func TestParseMetrics_ResourceStatistics(t *testing.T) { - log := getTestLogger() - - expectedValues := map[string]int{ - "JVM/Summary/InitialMemoryInMB": 305, - "JVM/Summary/UsedMemoryInMB": 40, - "JVM/Summary/CommittedMemoryInMB": 314, - "JVM/Summary/MaxMemoryInMB": -1, - "JVM/Summary/CumulativeGCTimeInSeconds": 0, - "JVM/Summary/CumulativeNumberOfGCCollections": 132, - "JVM/Heap/InitialMemoryInMB": 32, - "JVM/Heap/UsedMemoryInMB": 18, - "JVM/Heap/CommittedMemoryInMB": 34, - "JVM/Heap/MaxMemoryInMB": 256, - "JVM/Native/InitialMemoryInMB": 273, - "JVM/Native/UsedMemoryInMB": 22, - "JVM/Native/CommittedMemoryInMB": 280, - "JVM/Native/MaxMemoryInMB": -1, - "JVM/ScavengerGC/CumulativeGCTimeInSeconds": 0, - "JVM/ScavengerGC/CumulativeNumberOfGCCollections": 131, - "JVM/GlobalGC/CumulativeGCTimeInSeconds": 0, - "JVM/GlobalGC/CumulativeNumberOfGCCollections": 1, - } - - resourceStatisticsString := "{\"data\":{\"ResourceStatistics\":{\"brokerLabel\":\"integration_server\",\"brokerUUID\":\"\",\"executionGroupName\":\"testintegrationserver\",\"executionGroupUUID\":\"00000000-0000-0000-0000-000000000000\",\"collectionStartDate\":\"2018-08-28\",\"collectionStartTime\":\"21:13:33\",\"startDate\":\"2018-08-30\",\"startTime\":\"13:50:54\",\"endDate\":\"2018-08-30\",\"endTime\":\"13:51:15\",\"timezone\":\"Europe/London\",\"ResourceType\":[{\"name\":\"JVM\",\"resourceIdentifier\":[{\"name\":\"summary\",\"InitialMemoryInMB\":305,\"UsedMemoryInMB\":40,\"CommittedMemoryInMB\":314,\"MaxMemoryInMB\":-1,\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":132},{\"name\":\"Heap Memory\",\"InitialMemoryInMB\":32,\"UsedMemoryInMB\":18,\"CommittedMemoryInMB\":34,\"MaxMemoryInMB\":256},{\"name\":\"Non-Heap Memory\",\"InitialMemoryInMB\":273,\"UsedMemoryInMB\":22,\"CommittedMemoryInMB\":280,\"MaxMemoryInMB\":-1},{\"name\":\"Garbage Collection - scavenge\",\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":131},{\"name\":\"Garbage Collection - global\",\"CumulativeGCTimeInSeconds\":0,\"CumulativeNumberOfGCCollections\":1}]}]}},\"event\":0}" - - var sds StatisticsDataStruct - - unmarshallError := json.Unmarshal([]byte(resourceStatisticsString), &sds) - - if unmarshallError != nil { - t.Errorf("Error parsing json: %e", unmarshallError) - } - - mm, parseError := parseMetrics(log, &sds) - if parseError != nil { - t.Errorf("Error parsing metrics: %e", parseError) - return - } - jvmMetricNamesMap := generateResourceMetricNamesMap() - - for k, v := range jvmMetricNamesMap { - if v.enabled == false { - metric, ok := mm.internal[k] - if ok { - t.Errorf("Unexpected metric (%s) found in map: %+v", metric.name, metric) - } - } else { - metric, ok := mm.internal[k] - if !ok { - t.Errorf("Missing expected metric (%s)", k) - } - if metric.name != v.name { - t.Errorf("Expected name=%s; actual %s", v.name, metric.name) - } - if metric.description != v.description { - t.Errorf("Expected description=%s; actual %s", v.description, metric.description) - } - if metric.metricType != v.metricType { - t.Errorf("Expected metricType=%v; actual %v", v.metricType, metric.metricType) - } - if metric.metricLevel != v.metricLevel { - t.Errorf("Expected metricLevel=%v; actual %v", v.metricLevel, metric.metricLevel) - } - if metric.metricUnits != v.metricUnits { - t.Errorf("Expected metricUnits=%v; actual %v", v.metricUnits, metric.metricUnits) - } - if len(metric.values) != 1 { - t.Errorf("Expected values-size=%d; actual %d", 1, len(metric.values)) - } - - for _, values := range metric.values { - for label, labelValue := range values.labels { - switch label { - case serverLabel: - if labelValue != "testintegrationserver" { - t.Errorf("Expected server label=%s; actual %s", "testintegrationserver", labelValue) - } - default: - t.Errorf("Unexpected label (%s) found for metric: %s", label, metric.name) - } - } - - if values.value != metric.Normalise(expectedValues[k]) { - t.Errorf("Expected %s value=%f; actual %f", metric.name, metric.Normalise(expectedValues[k]), values.value) - } - } - } - } -} - -var updateTests = []struct { - mType MetricType - mValue1 float64 - mValue2 float64 - expected float64 -}{ - {Total, 9.0, 5.0, 14.0}, - {Total, 0.0, 5.0, 5.0}, - {Total, 32.0, 0.0, 32.0}, - {Total, 0.0, 0.0, 0.0}, - {Minimum, 0.0, 0.0, 0.0}, - {Minimum, 1.0, 0.0, 0.0}, - {Minimum, 0.0, 3.4, 0.0}, - {Minimum, 5.0, 23.7, 5.0}, - {Minimum, 31.0, 30.9, 30.9}, - {Maximum, 0.0, 0.0, 0.0}, - {Maximum, 1.0, 0.0, 1.0}, - {Maximum, 0.0, 3.4, 3.4}, - {Maximum, 5.0, 23.7, 23.7}, - {Maximum, 31.0, 30.9, 31.0}, - {Current, 0.0, 0.0, 0.0}, - {Current, 1.0, 0.0, 0.0}, - {Current, 0.0, 3.4, 3.4}, - {Current, 5.0, 23.7, 23.7}, - {Current, 31.0, 30.9, 30.9}, -} - -func TestUpdateMetrics_Simple(t *testing.T) { - log := getTestLogger() - - for _, tt := range updateTests { - mm1 := NewMetricsMap() - mm2 := NewMetricsMap() - - m1 := metricData{metricType: tt.mType} - m1.values = make(map[string]*Metric) - m1.values["test_val_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: tt.mValue1} - mm1.internal["test_mm_key"] = &m1 - - m2 := metricData{metricType: tt.mType} - m2.values = make(map[string]*Metric) - m2.values["test_val_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: tt.mValue2} - mm2.internal["test_mm_key"] = &m2 - - t.Run(fmt.Sprintf("%d", tt.mType), func(t *testing.T) { - updateMetrics(log, mm1, mm2) - actual := mm1.internal["test_mm_key"].values["test_val_key"].value - if actual != tt.expected { - t.Errorf("Expected update of type:%d with values %f and %f to result in a new value of %f, but actual=%f", tt.mType, tt.mValue1, tt.mValue2, tt.expected, actual) - } - }) - } -} - -func TestUpdateMetrics_NewValue(t *testing.T) { - log := getTestLogger() - - mm1 := NewMetricsMap() - mm2 := NewMetricsMap() - - m1 := metricData{metricType: Total} - m1.values = make(map[string]*Metric) - m1.values["non_existent_test_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: 4.0} - mm1.internal["test_mm_key"] = &m1 - - m2 := metricData{metricType: Total} - m2.values = make(map[string]*Metric) - m2.values["existing_test_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: 7.1} - mm2.internal["test_mm_key"] = &m2 - - updateMetrics(log, mm1, mm2) - actual1 := mm1.internal["test_mm_key"].values["existing_test_key"].value - if actual1 != 7.1 { - t.Errorf("Value for metric key existing_test_key expected:%f, actual=%f", 7.1, actual1) - } - - actual2 := mm1.internal["test_mm_key"].values["non_existent_test_key"].value - if actual2 != 4.0 { - t.Errorf("Value for metric key non_existent_test_key expected:%f, actual=%f", 4.0, actual2) - } -} - -func TestUpdateMetrics_NewKey(t *testing.T) { - log := getTestLogger() - - mm1 := NewMetricsMap() - mm2 := NewMetricsMap() - - m1 := metricData{metricType: Total} - m1.values = make(map[string]*Metric) - m1.values["test_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: 4.0} - mm1.internal["new_key"] = &m1 - - m2 := metricData{metricType: Total} - m2.values = make(map[string]*Metric) - m2.values["test_key"] = &Metric{labels: prometheus.Labels{serverLabel: "test_server"}, value: 7.1} - mm2.internal["old_key"] = &m2 - - updateMetrics(log, mm1, mm2) - actual1 := mm1.internal["old_key"].values["test_key"].value - if actual1 != 7.1 { - t.Errorf("Value for metric key existing_test_key expected:%f, actual=%f", 7.1, actual1) - } - - actual2 := mm1.internal["new_key"].values["test_key"].value - if actual2 != 4.0 { - t.Errorf("Value for metric key non_existent_test_key expected:%f, actual=%f", 4.0, actual2) - } -} diff --git a/internal/name/name.go b/internal/name/name.go deleted file mode 100644 index b43ade3..0000000 --- a/internal/name/name.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ - -// Package name contains code to manage the queue manager name -package name - -import ( - "os" - "regexp" -) - -// sanitizeName removes any invalid characters from a queue manager name -func sanitizeName(name string) string { - var re = regexp.MustCompile("[^a-zA-Z0-9._%/]") - return re.ReplaceAllString(name, "") -} - -// GetIntegrationServerName resolves the integration server naem to use. -// Resolved from either an environment variable, or the hostname. -func GetIntegrationServerName() (string, error) { - var name string - var err error - name, ok := os.LookupEnv("ACE_SERVER_NAME") - if !ok || name == "" { - name, err = os.Hostname() - if err != nil { - return "", err - } - name = sanitizeName(name) - } - return name, nil -} diff --git a/internal/name/name_internal_test.go b/internal/name/name_internal_test.go deleted file mode 100644 index d6c8a4f..0000000 --- a/internal/name/name_internal_test.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package name - -import ( - "testing" -) - -var sanitizeTests = []struct { - in string - out string -}{ - {"foo", "foo"}, - {"foo-0", "foo0"}, - {"foo-", "foo"}, - {"-foo", "foo"}, - {"foo_0", "foo_0"}, -} - -func TestSanitizeName(t *testing.T) { - for _, table := range sanitizeTests { - s := sanitizeName(table.in) - if s != table.out { - t.Errorf("sanitizeName(%v) - expected %v, got %v", table.in, table.out, s) - } - } -} diff --git a/internal/name/name_test.go b/internal/name/name_test.go deleted file mode 100644 index 79d9ca0..0000000 --- a/internal/name/name_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -© Copyright IBM Corporation 2018 - -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. -*/ -package name_test - -import ( - "os" - "testing" - - "github.com/ot4i/ace-docker/internal/name" -) - -func TestGetIntegrationServerNameFromEnv(t *testing.T) { - const data string = "bar" - err := os.Setenv("ACE_SERVER_NAME", data) - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - n, err := name.GetIntegrationServerName() - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - if n != data { - t.Errorf("Expected name=%v, got name=%v", data, n) - } -} diff --git a/internal/trace/trace_handler.go b/internal/trace/trace_handler.go deleted file mode 100644 index 0bbe76f..0000000 --- a/internal/trace/trace_handler.go +++ /dev/null @@ -1,433 +0,0 @@ -/* -© Copyright IBM Corporation 2021 - -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. -*/ - -// Package trace contains code to collect trace files -package trace - -import ( - "archive/zip" - "bytes" - "crypto/sha256" - "crypto/subtle" - "crypto/tls" - "crypto/x509" - "errors" - "io" - "net/http" - "os" - "os/exec" - "path/filepath" - "strconv" - "strings" - - "github.com/ot4i/ace-docker/common/logger" -) - -var log logger.LoggerInterface - -var traceDir = "/home/aceuser/ace-server/config/common/log" -var credsDir = "/home/aceuser/initial-config/webusers" - -var tlsEnabled = os.Getenv("ACE_ADMIN_SERVER_SECURITY") == "true" -var caPath = os.Getenv("ACE_ADMIN_SERVER_CA") -var certFile = os.Getenv("ACE_ADMIN_SERVER_CERT") -var keyFile = os.Getenv("ACE_ADMIN_SERVER_KEY") - -var credentials []Credential - -type includeFile func(string) bool -type zipFunction func(ZipWriterInterface) error - -type ReqBody struct { - Type string -} - -type ZipWriterInterface interface { - Create(string) (io.Writer, error) - Close() error -} - -type FileReaderInterface interface { - ReadFile(string) ([]byte, error) -} - -type FileReader struct{} - -func (fr *FileReader) ReadFile(path string) ([]byte, error) { - return os.ReadFile(path) -} - -type Credential struct { - Username [32]byte - Password [32]byte -} - -type ServerInterface interface { - Start(address string, mux *http.ServeMux) - StartTLS(address string, mux *http.ServeMux, caCertPool *x509.CertPool, certPath string, keyPath string) -} - -type Server struct{} - -func (s *Server) Start(address string, mux *http.ServeMux) { - server := &http.Server{ - Addr: address, - Handler: mux, - } - go func() { - err := server.ListenAndServe() - if err != nil { - log.Println("Tracing: Trace API server terminated with error " + err.Error()) - } else { - log.Println("Tracing: Trace API server terminated") - } - }() -} - -func (s *Server) StartTLS(address string, mux *http.ServeMux, caCertPool *x509.CertPool, certFile string, keyFile string) { - server := &http.Server{ - Addr: address, - Handler: mux, - TLSConfig: &tls.Config{ - ClientCAs: caCertPool, - ClientAuth: tls.RequireAndVerifyClientCert, - }, - } - go func() { - err := server.ListenAndServeTLS(certFile, keyFile) - if err != nil { - log.Println("Tracing: Trace API server terminated with error " + err.Error()) - } else { - log.Println("Tracing: Trace API server terminated") - } - }() -} - -func StartServer(logger logger.LoggerInterface, portNumber int) error { - log = logger - - err := readBasicAuthCreds(credsDir, &FileReader{}) - if err != nil { - log.Println("Tracing: No web admin users have been found. The trace APIs will be run without credential verification.") - } - return startTraceServer(&Server{}, portNumber) -} - -func startTraceServer(server ServerInterface, portNumber int) error { - address := ":" + strconv.Itoa(portNumber) - - mux := http.NewServeMux() - serviceTraceHandler := http.HandlerFunc(serviceTraceRouterHandler) - userTraceHandler := http.HandlerFunc(userTraceRouterHandler) - mux.Handle("/collect-service-trace", basicAuthMiddlware(serviceTraceHandler)) - mux.Handle("/collect-user-trace", basicAuthMiddlware(userTraceHandler)) - - if tlsEnabled { - caCertPool, err := getCACertPool(caPath, &FileReader{}) - if err != nil { - return err - } - server.StartTLS(address, mux, caCertPool, certFile, keyFile) - } else { - server.Start(address, mux) - } - return nil -} - -func userTraceRouterHandler(res http.ResponseWriter, req *http.Request) { - traceRouteHandler(res, req, zipUserTrace) -} - -func serviceTraceRouterHandler(res http.ResponseWriter, req *http.Request) { - traceRouteHandler(res, req, zipServiceTrace) -} - -func traceRouteHandler(res http.ResponseWriter, req *http.Request, zipFunc zipFunction) { - if req.Method != http.MethodPost { - res.WriteHeader(http.StatusMethodNotAllowed) - return - } - - res.Header().Set("Transfer-Encoding", "chunked") - res.Header().Set("Content-Disposition", "attachment; filename=\"trace.zip\"") - - zipWriter := zip.NewWriter(res) - defer zipWriter.Close() - - err := zipFunc(zipWriter) - - if err != nil { - http.Error(res, err.Error(), http.StatusInternalServerError) - } -} - -func zipUserTrace(zipWriter ZipWriterInterface) error { - log.Println("Tracing: Collecting user trace") - err := zipDir(traceDir, zipWriter, func(fileName string) bool { - return strings.Contains(fileName, ".userTrace.") - }) - if err != nil { - log.Error("Tracing: Failed to collect user trace. Error: " + err.Error()) - return err - } - log.Println("Tracing: Finished collecting user trace") - return nil -} - -func zipServiceTrace(zipWriter ZipWriterInterface) error { - log.Println("Tracing: Collecting service trace") - err := zipDir(traceDir, zipWriter, func(fileName string) bool { - return strings.Contains(fileName, ".trace.") || strings.Contains(fileName, ".exceptionLog.") - }) - if err != nil { - log.Error("Tracing: Failed to collect service trace and exception logs. Error: " + err.Error()) - return err - } - - err = addEnvToZip(zipWriter, "env.txt") - if err != nil { - log.Error("Tracing: Failed to get integration server env. Error: " + err.Error()) - return err - } - - _ = runOSCommand(zipWriter, "ps eww.txt", "ps", "eww") - - log.Println("Tracing: Finished collecting service trace") - return nil -} - -func addEnvToZip(zipWriter ZipWriterInterface, filename string) error { - log.Println("Tracing: Adding environment variables to zip") - - var envVars []byte - for _, element := range os.Environ() { - element += "\n" - envVars = append(envVars, element...) - } - - err := addEntryToZip(zipWriter, filename, envVars) - if err != nil { - log.Error("Tracing: Unable to add env vars to zip. Error: " + err.Error()) - return err - } - - return nil -} - -func runOSCommand(zipWriter ZipWriterInterface, filename string, command string, arg ...string) error { - log.Println("Tracing: Collecting output of command: " + command) - cmd := exec.Command(command, arg...) - var out bytes.Buffer - cmd.Stdout = &out - - err := cmd.Run() - if err != nil { - log.Error("Tracing: Unable to run command " + command + ": " + err.Error()) - return err - } - - outBytes := out.Bytes() - - err = addEntryToZip(zipWriter, filename, outBytes) - if err != nil { - log.Error("Tracing: Unable to add output of command: " + command + " to zip. Error: " + err.Error()) - return err - } - - return nil -} - -func addEntryToZip(zipWriter ZipWriterInterface, filename string, fileContents []byte) error { - zipEntry, err := zipWriter.Create(filename) - if err != nil { - log.Error("Tracing: Failed to write header for " + filename) - return err - } - - if _, err := zipEntry.Write(fileContents); err != nil { - log.Error("Tracing: Failed to add " + filename + " to archive") - return err - } - - return nil -} - -func zipDir(traceDir string, zipWriter ZipWriterInterface, testFunc includeFile) error { - log.Println("Tracing: Creating archive of " + traceDir) - stat, err := os.Stat(traceDir) - if err != nil { - log.Error("Tracing: Directory " + traceDir + " does not exist") - return err - } - - if !stat.Mode().IsDir() { - log.Error("Tracing: " + traceDir + " is not a directory") - return errors.New(traceDir + " is not a directory") - } - - return filepath.Walk(traceDir, func(path string, fileInfo os.FileInfo, err error) error { - if fileInfo.Mode().IsDir() { - return nil - } - if testFunc(fileInfo.Name()) { - return zipFile(path, zipWriter) - } - return nil - }) -} - -func zipFile(path string, zipWriter ZipWriterInterface) error { - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - - if fileInfo, err := file.Stat(); err == nil { - log.Println("Tracing: Adding " + fileInfo.Name() + " to archive") - - zipEntry, err := zipWriter.Create(fileInfo.Name()) - if err != nil { - log.Error("Tracing: Failed to write header for " + fileInfo.Name()) - return err - } - - if _, err := io.Copy(zipEntry, file); err != nil { - log.Error("Tracing: Failed to add " + fileInfo.Name() + " to archive") - return err - } - } - - return nil -} - -func readBasicAuthCreds(credsDir string, fileReader FileReaderInterface) error { - stat, err := os.Stat(credsDir) - if err != nil { - return err - } - - if !stat.Mode().IsDir() { - return errors.New(credsDir + " is not a directory") - } - - return filepath.Walk(credsDir, func(path string, fileInfo os.FileInfo, err error) error { - if fileInfo.Mode().IsDir() { - return nil - } - - fileName := fileInfo.Name() - - if fileName == "admin-users.txt" || fileName == "operator-users.txt" { - file, err := fileReader.ReadFile(path) - if err != nil { - return err - } - - fileString := strings.TrimSpace(string(file)) - - lines := strings.Split(fileString, "\n") - for _, line := range lines { - if line != "" && !strings.HasPrefix(line, "#") { - fields := strings.Fields(line) - if len(fields) != 2 { - return errors.New("Tracing: Unable to parse " + fileName) - } - // using hashes means that the length of the byte array to compare is always the same - credentials = append(credentials, Credential{ - Username: sha256.Sum256([]byte(fields[0])), - Password: sha256.Sum256([]byte(fields[1])), - }) - } - } - - log.Println("Tracing: Added credentials from " + fileName + " to trace router") - } - return nil - }) -} - -func basicAuthMiddlware(next http.Handler) http.Handler { - return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - if len(credentials) > 0 { - username, password, ok := req.BasicAuth() - - if ok { - usernameHash := sha256.Sum256([]byte(username)) - passwordHash := sha256.Sum256([]byte(password)) - - for _, credential := range credentials { - // subtle.ConstantTimeCompare takes the same amount of time to run, regardless of whether the slices match or not - usernameMatch := subtle.ConstantTimeCompare(usernameHash[:], credential.Username[:]) - passwordMatch := subtle.ConstantTimeCompare(passwordHash[:], credential.Password[:]) - if usernameMatch+passwordMatch == 2 { - next.ServeHTTP(res, req) - return - } - } - } - - http.Error(res, "Unauthorized", http.StatusUnauthorized) - } else { - next.ServeHTTP(res, req) - } - }) -} - -func getCACertPool(caPath string, fileReader FileReaderInterface) (*x509.CertPool, error) { - caCertPool := x509.NewCertPool() - - stat, err := os.Stat(caPath) - - if err != nil { - log.Printf("Tracing: %s does not exist", caPath) - return nil, err - } - - if stat.IsDir() { - // path is a directory load all certs - log.Printf("Tracing: Using CA Certificate folder %s", caPath) - filepath.Walk(caPath, func(cert string, info os.FileInfo, err error) error { - if strings.HasSuffix(cert, "crt.pem") { - log.Printf("Tracing: Adding Certificate %s to CA pool", cert) - binaryCert, err := fileReader.ReadFile(cert) - if err != nil { - log.Printf("Tracing: Error reading CA Certificate %s", err.Error()) - return nil - } - ok := caCertPool.AppendCertsFromPEM(binaryCert) - if !ok { - log.Printf("Tracing: Failed to parse Certificate %s", cert) - } - } - return nil - }) - } else { - log.Printf("Tracing: Using CA Certificate file %s", caPath) - caCert, err := fileReader.ReadFile(caPath) - if err != nil { - log.Errorf("Tracing: Error reading CA Certificate %s", err) - return nil, err - } - ok := caCertPool.AppendCertsFromPEM(caCert) - if !ok { - log.Error("Tracing: Failed to parse root CA Certificate") - return nil, errors.New("failed to parse root CA Certificate") - } - } - - return caCertPool, nil -} diff --git a/internal/trace/trace_handler_test.go b/internal/trace/trace_handler_test.go deleted file mode 100644 index d63272c..0000000 --- a/internal/trace/trace_handler_test.go +++ /dev/null @@ -1,859 +0,0 @@ -/* -© Copyright IBM Corporation 2021 - -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. -*/ - -package trace - -import ( - "archive/zip" - "bytes" - "crypto/rand" - "crypto/rsa" - "crypto/sha256" - "crypto/x509" - "encoding/pem" - "errors" - "io" - "math/big" - "net/http" - "net/http/httptest" - "os" - "strings" - "testing" - - "github.com/ot4i/ace-docker/common/logger" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var testLogger, _ = logger.NewLogger(os.Stdout, true, true, "test") - -func TestStartTraceServer(t *testing.T) { - log = testLogger - - t.Run("Error creating cert pool", func(t *testing.T) { - tlsEnabled = true - caPath = "capath" - err := startTraceServer(&Server{}, 7891) - require.Error(t, err) - }) - - t.Run("TLS server when ACE_ADMIN_SERVER_SECURITY is true", func(t *testing.T) { - defer func() { - os.RemoveAll("capath") - }() - tlsEnabled = true - caPath = "capath" - certFile = "certfile" - keyFile = "keyfile" - - err := os.MkdirAll("capath", 0755) - require.NoError(t, err) - - startTraceServer(&TestServer{ - t: t, - expectedAddress: ":7891", - expectedCertFile: certFile, - expectedKeyFile: keyFile, - }, 7891) - }) - - t.Run("HTTP server when ACE_ADMIN_SERVER_SECURITY is not true", func(t *testing.T) { - tlsEnabled = false - startTraceServer(&TestServer{ - t: t, - expectedAddress: ":7891", - }, 7891) - }) -} - -func TestUserTraceRouterHandler(t *testing.T) { - log = testLogger - - handler := http.HandlerFunc(userTraceRouterHandler) - url := "/collect-user-trace" - - t.Run("Sends an error if not a POST request", func(t *testing.T) { - request, _ := http.NewRequest("GET", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusMethodNotAllowed, response.Code) - }) - - t.Run("Sends an error if the trace can't be collected", func(t *testing.T) { - traceDir = "test/trace" - request, _ := http.NewRequest("POST", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusInternalServerError, response.Code) - }) - - t.Run("Streams a zip file for user trace", func(t *testing.T) { - defer restoreUserTrace() - setUpUserTrace(t) - - request, _ := http.NewRequest("POST", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - require.Equal(t, http.StatusOK, response.Code) - - body, _ := io.ReadAll(response.Body) - zipReader, err := zip.NewReader(bytes.NewReader(body), int64(len(body))) - require.NoError(t, err) - - files := checkZip(t, zipReader) - assert.Len(t, files, 1) - assert.Contains(t, files, "test.userTrace.txt") - }) -} - -func TestServiceTraceRouteHandler(t *testing.T) { - log = testLogger - - handler := http.HandlerFunc(serviceTraceRouterHandler) - url := "/collect-service-trace" - - t.Run("Sends an error if not a POST request", func(t *testing.T) { - request, _ := http.NewRequest("GET", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusMethodNotAllowed, response.Code) - }) - - t.Run("Sends an error if the trace can't be collected", func(t *testing.T) { - traceDir = "test/trace" - - request, _ := http.NewRequest("POST", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - assert.Equal(t, http.StatusInternalServerError, response.Code) - }) - - t.Run("Streams a zip file for service trace", func(t *testing.T) { - defer restoreServiceTrace() - setUpServiceTrace(t) - - request, _ := http.NewRequest("POST", url, nil) - response := httptest.NewRecorder() - - handler.ServeHTTP(response, request) - require.Equal(t, http.StatusOK, response.Code) - - body, _ := io.ReadAll(response.Body) - zipReader, err := zip.NewReader(bytes.NewReader(body), int64(len(body))) - require.NoError(t, err) - - files := checkZip(t, zipReader) - assert.Contains(t, files, "test.trace.txt") - assert.Contains(t, files, "test.exceptionLog.txt") - assert.Contains(t, files, "env.txt") - }) -} - -func TestZipUserTrace(t *testing.T) { - log = testLogger - - defer restoreUserTrace() - setUpUserTrace(t) - - t.Run("Builds a zip with user trace", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - - err := zipUserTrace(zipWriter) - require.NoError(t, err) - - zipWriter.Close() - - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - filesInZip := checkZip(t, zipReader) - assert.Len(t, filesInZip, 1) - assert.Contains(t, filesInZip, "test.userTrace.txt") - }) - - t.Run("Returns an error when it can't collect user trace", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := FailOnFileNameZipWriter{ - failOnFileName: "test.userTrace.txt", - zipWriter: zip.NewWriter(&buffer), - } - err := zipUserTrace(zipWriter) - assert.EqualError(t, err, "Unable to write test.userTrace.txt") - }) -} - -func TestZipServiceTrace(t *testing.T) { - log = testLogger - - defer restoreServiceTrace() - setUpServiceTrace(t) - - t.Run("Builds a zip with service trace, exception logs, env, and ps eww output", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - - err := zipServiceTrace(zipWriter) - require.NoError(t, err) - - zipWriter.Close() - - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - files := checkZip(t, zipReader) - assert.Contains(t, files, "test.trace.txt") - assert.Contains(t, files, "test.exceptionLog.txt") - assert.Contains(t, files, "env.txt") - }) - - t.Run("Failure test cases", func(t *testing.T) { - failureTestCases := []string{ - "test.trace.txt", - "env.txt", - } - - for _, fileName := range failureTestCases { - t.Run(fileName, func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := FailOnFileNameZipWriter{ - failOnFileName: fileName, - zipWriter: zip.NewWriter(&buffer), - } - err := zipServiceTrace(zipWriter) - assert.EqualError(t, err, "Unable to write "+fileName) - }) - } - }) -} - -func TestRunOSCommand(t *testing.T) { - log = testLogger - - t.Run("Returns an error if it can't run the command", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := runOSCommand(zipWriter, "file.txt", "asdasdd") - assert.Error(t, err) - zipWriter.Close() - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - assert.Len(t, checkZip(t, zipReader), 0) - }) - - t.Run("Returns an error if there is an error when creating a file in the zip", func(t *testing.T) { - zipWriter := CreateFailureZipWriter{} - err := runOSCommand(zipWriter, "file.txt", "echo", "hello world") - assert.Error(t, err) - }) - - t.Run("Returns an error if the command output can't be written to the zip", func(t *testing.T) { - zipWriter := WriteFailureZipWriter{} - err := runOSCommand(zipWriter, "file.txt", "echo", "hello world") - assert.Error(t, err) - }) - - t.Run("Adds the command output to the zip if successful", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - - err := runOSCommand(zipWriter, "file.txt", "echo", "hello world") - assert.NoError(t, err) - - zipWriter.Close() - - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - - files := checkZip(t, zipReader) - assert.Len(t, files, 1) - assert.Contains(t, files, "file.txt") - }) -} - -func TestZipDir(t *testing.T) { - log = testLogger - - // Create directories and files which will be archived - err := os.MkdirAll("subdir/parent/child", 0755) - require.NoError(t, err) - defer os.RemoveAll("subdir") - - files := []string{"subdir/parent/file1.txt", "subdir/parent/child/file2.txt", "subdir/parent/file3.txt"} - - for _, fileName := range files { - file, err := os.Create(fileName) - require.NoError(t, err) - _, err = file.WriteString("This is a test") - require.NoError(t, err) - } - - t.Run("Calls zipFile for each file and only adds files which pass the test function ", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := zipDir("subdir", zipWriter, func(fileName string) bool { - return !strings.Contains(fileName, "1") - }) - zipWriter.Close() - require.NoError(t, err) - - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - - files := checkZip(t, zipReader) - assert.Len(t, files, 2) - assert.Contains(t, files, "file2.txt") - assert.Contains(t, files, "file3.txt") - }) - - t.Run("Returns an error if the directory does not exist", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := zipDir("does-not-exist", zipWriter, func(string) bool { return true }) - zipWriter.Close() - assert.Error(t, err) - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - assert.Len(t, checkZip(t, zipReader), 0) - }) - - t.Run("Returns an error if passed a file that is not a directory", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := zipDir("subdir/parent/file1.txt", zipWriter, func(string) bool { return true }) - zipWriter.Close() - assert.EqualError(t, err, "subdir/parent/file1.txt is not a directory") - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - assert.Len(t, checkZip(t, zipReader), 0) - }) - - t.Run("Creates an empty zip if there are no files which pass the test function", func(t *testing.T) { - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := zipDir("subdir", zipWriter, func(fileName string) bool { - return !strings.Contains(fileName, "file") - }) - zipWriter.Close() - assert.NoError(t, err) - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - assert.Len(t, checkZip(t, zipReader), 0) - }) -} - -func TestZipFile(t *testing.T) { - log = testLogger - fileNameToZip := "fileToZip.txt" - - testSetup := func() { - // Create file which will be archived - fileToZip, err := os.Create(fileNameToZip) - require.NoError(t, err) - _, err = fileToZip.WriteString("This is a test") - require.NoError(t, err) - } - - t.Run("Returns an error when the file cannot be opened", func(t *testing.T) { - err := zipFile("badPath", nil) - assert.Error(t, err) - }) - - t.Run("Returns an error when it fails to create the file in the zip", func(t *testing.T) { - defer os.Remove(fileNameToZip) - testSetup() - - zipWriter := CreateFailureZipWriter{} - - err := zipFile(fileNameToZip, zipWriter) - assert.EqualError(t, err, "Failed to create") - }) - - t.Run("Returns an error when it fails to add the file to the zip", func(t *testing.T) { - defer os.Remove(fileNameToZip) - testSetup() - - zipWriter := WriteFailureZipWriter{} - - err := zipFile(fileNameToZip, zipWriter) - assert.EqualError(t, err, "Failed to write") - }) - - t.Run("Returns with no error when the header and file are successfully written to the zip", func(t *testing.T) { - defer os.Remove(fileNameToZip) - testSetup() - - var buffer bytes.Buffer - zipWriter := zip.NewWriter(&buffer) - err := zipFile("fileToZip.txt", zipWriter) - assert.NoError(t, err) - zipWriter.Close() - - zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(len(buffer.Bytes()))) - require.NoError(t, err) - files := checkZip(t, zipReader) - assert.Equal(t, 1, len(files)) - assert.Contains(t, files, "fileToZip.txt") - }) -} - -func TestReadBasicAuthCreds(t *testing.T) { - credsDir := "credentials" - - setupDir := func() { - err := os.MkdirAll(credsDir, 0755) - require.NoError(t, err) - } - - cleanUpDir := func() { - err := os.RemoveAll(credsDir) - require.NoError(t, err) - } - - t.Run("Returns an error if the directory does not exist", func(t *testing.T) { - err := readBasicAuthCreds("does/not/exist", &FileReader{}) - require.Error(t, err) - }) - - t.Run("Returns an error if the input parameter is not a directory", func(t *testing.T) { - setupDir() - defer cleanUpDir() - - _, err := os.Create(credsDir + "/emptyFile.txt") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir+"/emptyFile.txt", &FileReader{}) - require.EqualError(t, err, "credentials/emptyFile.txt is not a directory") - }) - - t.Run("Returns an error if there is an error reading a file", func(t *testing.T) { - setupDir() - defer cleanUpDir() - - _, err := os.Create(credsDir + "/admin-users.txt") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir, &ErrorFileReader{}) - require.EqualError(t, err, "Unable to read file") - }) - - t.Run("Returns an error if it fails to parse the credentials file", func(t *testing.T) { - setupDir() - defer cleanUpDir() - - file, err := os.Create(credsDir + "/admin-users.txt") - require.NoError(t, err) - _, err = file.WriteString("This is a test") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir, &FileReader{}) - require.EqualError(t, err, "Tracing: Unable to parse admin-users.txt") - }) - - t.Run("Returns nil if the credentials have all been read and parsed - single line files", func(t *testing.T) { - log = testLogger - - setupDir() - defer cleanUpDir() - - credentials = []Credential{} - - file, err := os.Create(credsDir + "/admin-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user1 pass1") - require.NoError(t, err) - - file, err = os.Create(credsDir + "/operator-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user2 pass2") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir, &FileReader{}) - require.NoError(t, err) - - require.Len(t, credentials, 2) - assert.Equal(t, sha256.Sum256([]byte("user1")), credentials[0].Username) - assert.Equal(t, sha256.Sum256([]byte("pass1")), credentials[0].Password) - assert.Equal(t, sha256.Sum256([]byte("user2")), credentials[1].Username) - assert.Equal(t, sha256.Sum256([]byte("pass2")), credentials[1].Password) - }) - - t.Run("Returns nil if the credentials have all been read and parsed - multi line files, trailing spaces and comments", func(t *testing.T) { - log = testLogger - - setupDir() - defer cleanUpDir() - - credentials = []Credential{} - - file, err := os.Create(credsDir + "/admin-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user1 pass1\nuser2 pass2\n") - require.NoError(t, err) - - file, err = os.Create(credsDir + "/operator-users.txt") - require.NoError(t, err) - _, err = file.WriteString("# this shouldn't cause an error \n# nor should this\nuser3 pass3 \n ") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir, &FileReader{}) - require.NoError(t, err) - - require.Len(t, credentials, 3) - assert.Equal(t, sha256.Sum256([]byte("user1")), credentials[0].Username) - assert.Equal(t, sha256.Sum256([]byte("pass1")), credentials[0].Password) - assert.Equal(t, sha256.Sum256([]byte("user2")), credentials[1].Username) - assert.Equal(t, sha256.Sum256([]byte("pass2")), credentials[1].Password) - assert.Equal(t, sha256.Sum256([]byte("user3")), credentials[2].Username) - assert.Equal(t, sha256.Sum256([]byte("pass3")), credentials[2].Password) - }) - - t.Run("does not add viewer, auditor or editor users", func(t *testing.T) { - log = testLogger - - setupDir() - defer cleanUpDir() - - credentials = []Credential{} - - file, err := os.Create(credsDir + "/auditor-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user1 pass1") - require.NoError(t, err) - - file, err = os.Create(credsDir + "/operator-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user2 pass2") - require.NoError(t, err) - - file, err = os.Create(credsDir + "/editor-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user3 pass3") - require.NoError(t, err) - - file, err = os.Create(credsDir + "/viewer-users.txt") - require.NoError(t, err) - _, err = file.WriteString("user4 pass4") - require.NoError(t, err) - - err = readBasicAuthCreds(credsDir, &FileReader{}) - require.NoError(t, err) - - require.Len(t, credentials, 1) - assert.Equal(t, sha256.Sum256([]byte("user2")), credentials[0].Username) - assert.Equal(t, sha256.Sum256([]byte("pass2")), credentials[0].Password) - }) -} - -func TestBasicAuthMiddlware(t *testing.T) { - setCredentials := func() { - credentials = []Credential{{ - Username: sha256.Sum256([]byte("user1")), - Password: sha256.Sum256([]byte("pass1")), - }, { - Username: sha256.Sum256([]byte("user2")), - Password: sha256.Sum256([]byte("pass2")), - }, - } - } - - t.Run("No credentials defined", func(t *testing.T) { - credentials = []Credential{} - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - - var called bool - - handlerToTest := basicAuthMiddlware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - called = true - })) - handlerToTest.ServeHTTP(response, req) - - assert.True(t, called) - }) - - t.Run("No basic auth credentials in request", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - - handlerToTest := basicAuthMiddlware(nil) - handlerToTest.ServeHTTP(response, req) - - assert.Equal(t, 401, response.Result().StatusCode) - }) - - t.Run("Invalid basic auth credentials", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - req.SetBasicAuth("invaliduser", "invalidpass") - - handlerToTest := basicAuthMiddlware(nil) - handlerToTest.ServeHTTP(response, req) - - assert.Equal(t, 401, response.Result().StatusCode) - }) - - t.Run("Matching username", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - req.SetBasicAuth("user1", "invalidpass") - - handlerToTest := basicAuthMiddlware(nil) - handlerToTest.ServeHTTP(response, req) - - assert.Equal(t, 401, response.Result().StatusCode) - }) - - t.Run("Matching password", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - req.SetBasicAuth("invaliduser", "pass1") - - handlerToTest := basicAuthMiddlware(nil) - handlerToTest.ServeHTTP(response, req) - - assert.Equal(t, 401, response.Result().StatusCode) - }) - - t.Run("Matches first credentials", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - req.SetBasicAuth("user1", "pass1") - - var called bool - - handlerToTest := basicAuthMiddlware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - called = true - })) - handlerToTest.ServeHTTP(response, req) - - assert.True(t, called) - }) - - t.Run("Matches second credentials", func(t *testing.T) { - setCredentials() - response := httptest.NewRecorder() - req := httptest.NewRequest("GET", "http://testing", nil) - req.SetBasicAuth("user2", "pass2") - - var called bool - - handlerToTest := basicAuthMiddlware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - called = true - })) - handlerToTest.ServeHTTP(response, req) - - assert.True(t, called) - }) -} -func TestGetCACertPool(t *testing.T) { - log = testLogger - - defer func() { - os.RemoveAll("cert-dir") - }() - - err := os.MkdirAll("cert-dir", 0755) - require.NoError(t, err) - - _, err = os.Create("cert-dir/empty-crt.pem") // empty file for parsing errors - require.NoError(t, err) - - file, err := os.Create("cert-dir/valid-crt.pem") - require.NoError(t, err) - - cert := createValidCA() - _, err = file.Write(cert) - require.NoError(t, err) - - t.Run("Returns an error if caPath is not a file", func(t *testing.T) { - _, err := getCACertPool("does-not-exist", &FileReader{}) - require.Error(t, err) - }) - - t.Run("Returns an error if the ca file cannot be read", func(t *testing.T) { - _, err := getCACertPool("cert-dir/valid-crt.pem", &ErrorFileReader{}) - require.Error(t, err) - }) - - t.Run("Returns an error if the ca file cannot be parsed", func(t *testing.T) { - _, err := getCACertPool("cert-dir/empty-crt.pem", &FileReader{}) - require.Error(t, err) - }) - - t.Run("Returns a caPool with one cert if the ca file is added successfully", func(t *testing.T) { - caCertPool, err := getCACertPool("cert-dir/valid-crt.pem", &FileReader{}) - require.NoError(t, err) - assert.Len(t, caCertPool.Subjects(), 1) - }) - - t.Run("Does not return an error when a file reading error occurs in a directory", func(t *testing.T) { - caCertPool, err := getCACertPool("cert-dir", &ErrorFileReader{}) - require.NoError(t, err) - assert.Len(t, caCertPool.Subjects(), 0) // both files won't be read - }) - - t.Run("Does not return an error when files can't be parsed", func(t *testing.T) { - caCertPool, err := getCACertPool("cert-dir", &FileReader{}) - require.NoError(t, err) - assert.Len(t, caCertPool.Subjects(), 1) // the empty file will fail to parse - }) -} - -func checkZip(t *testing.T, zipReader *zip.Reader) []string { - var files []string - for _, f := range zipReader.File { - files = append(files, f.FileHeader.Name) - } - return files -} - -func setUpUserTrace(t *testing.T) { - traceDir = "test/trace" - - err := os.MkdirAll(traceDir, 0755) - require.NoError(t, err) - - files := []string{ - traceDir + "/test.userTrace.txt", - traceDir + "/no-match.txt", - } - - for _, fileName := range files { - file, err := os.Create(fileName) - require.NoError(t, err) - _, err = file.WriteString("This is a test") - require.NoError(t, err) - } -} - -func restoreUserTrace() { - os.RemoveAll("test") -} - -func setUpServiceTrace(t *testing.T) { - traceDir = "test/trace" - - err := os.MkdirAll(traceDir, 0755) - require.NoError(t, err) - - files := []string{ - "/test.trace.txt", - "/test.exceptionLog.txt", - "/no-match.txt", - } - - for _, fileName := range files { - file, err := os.Create(traceDir + fileName) - require.NoError(t, err) - _, err = file.WriteString("This is a test") - require.NoError(t, err) - } -} - -func restoreServiceTrace() { - os.RemoveAll("test") -} - -func createValidCA() []byte { - privKey, _ := rsa.GenerateKey(rand.Reader, 4096) - ca := &x509.Certificate{ - SerialNumber: &big.Int{}, - IsCA: true, - } - - caBytes, _ := x509.CreateCertificate(rand.Reader, ca, ca, &privKey.PublicKey, privKey) - - caPEM := new(bytes.Buffer) - _ = pem.Encode(caPEM, &pem.Block{ - Type: "CERTIFICATE", - Bytes: caBytes, - }) - - return caPEM.Bytes() -} - -type CreateFailureZipWriter struct{} - -func (zw CreateFailureZipWriter) Create(filename string) (io.Writer, error) { - return nil, errors.New("Failed to create") -} -func (zw CreateFailureZipWriter) Close() error { - return nil -} - -type WriteFailureZipWriter struct{} - -func (zw WriteFailureZipWriter) Create(filename string) (io.Writer, error) { - zipEntry := WriteFailureZipEntry{} - return zipEntry, nil -} -func (zw WriteFailureZipWriter) Close() error { - return nil -} - -type WriteFailureZipEntry struct{} - -func (ze WriteFailureZipEntry) Write(p []byte) (n int, err error) { - return 0, errors.New("Failed to write") -} - -type FailOnFileNameZipWriter struct { - failOnFileName string - zipWriter ZipWriterInterface -} - -func (zw FailOnFileNameZipWriter) Create(filename string) (io.Writer, error) { - if filename == zw.failOnFileName { - return nil, errors.New("Unable to write " + zw.failOnFileName) - } - return zw.zipWriter.Create(filename) -} -func (zw FailOnFileNameZipWriter) Close() error { - return zw.zipWriter.Close() -} - -type ErrorFileReader struct{} - -func (fr *ErrorFileReader) ReadFile(string) ([]byte, error) { - return nil, errors.New("Unable to read file") -} - -type TestServer struct { - t *testing.T - expectedAddress string - expectedCertFile string - expectedKeyFile string -} - -func (s *TestServer) Start(address string, mux *http.ServeMux) { - assert.Equal(s.t, s.expectedAddress, address) -} - -func (s *TestServer) StartTLS(address string, mux *http.ServeMux, caCertPool *x509.CertPool, certFile string, keyFile string) { - assert.Equal(s.t, s.expectedAddress, address) - assert.Equal(s.t, s.expectedCertFile, certFile) - assert.Equal(s.t, s.expectedKeyFile, keyFile) -} diff --git a/internal/webadmin/testdata/initial-config/webusers/admin-users.txt b/internal/webadmin/testdata/initial-config/webusers/admin-users.txt deleted file mode 100644 index bc07495..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/admin-users.txt +++ /dev/null @@ -1 +0,0 @@ -ibm-ace-dashboard-admin 1758F07A-8BEF-448C-B020-C25946AF3E94 \ No newline at end of file diff --git a/internal/webadmin/testdata/initial-config/webusers/audit-users.txt b/internal/webadmin/testdata/initial-config/webusers/audit-users.txt deleted file mode 100644 index 2926f91..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/audit-users.txt +++ /dev/null @@ -1 +0,0 @@ -ibm-ace-dashboard-audit 929064C2-0017-4B34-A883-219A4D1AC944 \ No newline at end of file diff --git a/internal/webadmin/testdata/initial-config/webusers/editor-users.txt b/internal/webadmin/testdata/initial-config/webusers/editor-users.txt deleted file mode 100644 index d4073aa..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/editor-users.txt +++ /dev/null @@ -1 +0,0 @@ -ibm-ace-dashboard-editor 28DBC34B-C0FD-44BF-8100-99DB686B6DB2 \ No newline at end of file diff --git a/internal/webadmin/testdata/initial-config/webusers/operator-users.txt b/internal/webadmin/testdata/initial-config/webusers/operator-users.txt deleted file mode 100644 index 20c5008..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/operator-users.txt +++ /dev/null @@ -1 +0,0 @@ -ibm-ace-dashboard-operator 68FE7808-8EC2-4395-97D0-A776D2A61912 \ No newline at end of file diff --git a/internal/webadmin/testdata/initial-config/webusers/server.conf.yaml b/internal/webadmin/testdata/initial-config/webusers/server.conf.yaml deleted file mode 100644 index b2b8775..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/server.conf.yaml +++ /dev/null @@ -1,4 +0,0 @@ -RestAdminListener: - authorizationEnabled: true - authorizationMode: file - basicAuth: true \ No newline at end of file diff --git a/internal/webadmin/testdata/initial-config/webusers/viewer-users.txt b/internal/webadmin/testdata/initial-config/webusers/viewer-users.txt deleted file mode 100644 index e93014e..0000000 --- a/internal/webadmin/testdata/initial-config/webusers/viewer-users.txt +++ /dev/null @@ -1 +0,0 @@ -ibm-ace-dashboard-viewer EF086556-74B8-4FB0-ACF8-CC59E1F3DB5F \ No newline at end of file diff --git a/internal/webadmin/webadmin.go b/internal/webadmin/webadmin.go deleted file mode 100644 index 0d810db..0000000 --- a/internal/webadmin/webadmin.go +++ /dev/null @@ -1,222 +0,0 @@ -package webadmin - -import ( - "crypto/rand" - "crypto/sha512" - b64 "encoding/base64" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/ot4i/ace-docker/common/logger" - "golang.org/x/crypto/pbkdf2" - "gopkg.in/yaml.v2" -) - -var ( - readFile = os.ReadFile - mkdirAll = os.MkdirAll - writeFile = os.WriteFile - readDir = os.ReadDir - processWebAdminUsers = processWebAdminUsersLocal - applyFileAuthOverrides = applyFileAuthOverridesLocal - outputFiles = outputFilesLocal - unmarshal = yaml.Unmarshal - marshal = yaml.Marshal - readWebUsersTxt = readWebUsersTxtLocal - version string = "12.0.0.0" - homedir string = "/home/aceuser/" - webusersDir string = "/home/aceuser/initial-config/webusers/" -) - -func ConfigureWebAdminUsers(log logger.LoggerInterface) error { - serverConfContent, err := readServerConfFile() - if err != nil { - log.Errorf("Error reading server.conf.yaml: %v", err) - return err - } - - webAdminUserInfo, err := processWebAdminUsers(log, webusersDir) - if err != nil { - log.Errorf("Error processing WebAdmin users: %v", err) - return err - } - serverconfYaml, err := applyFileAuthOverrides(log, webAdminUserInfo, serverConfContent) - if err != nil { - log.Errorf("Error applying file auth overrides: %v", err) - return err - } - err = writeServerConfFile(serverconfYaml) - if err != nil { - log.Errorf("Error writing server.conf.yaml: %v", err) - return err - } - - for webAdminUserName, webAdminPass := range webAdminUserInfo { - m := map[string]string{ - "password": keyGen(webAdminPass), - "role": webAdminUserName, - "version": version, - } - err := outputFiles(log, m) - if err != nil { - log.Errorf("Error writing WebAdmin files: %v", err) - return err - } - } - return nil -} - -func processWebAdminUsersLocal(log logger.LoggerInterface, dir string) (map[string]string, error) { - userInfo := map[string]string{} - - fileList, err := readDir(dir) - if err != nil { - log.Errorf("Error reading directory: %v", err) - return nil, err - } - - for _, file := range fileList { - if filepath.Ext(file.Name()) == ".txt" { - username, password, err := readWebUsersTxt(log, dir+file.Name()) - if err != nil { - log.Errorf("Error reading WebAdmin users.txt file: %v", err) - return nil, err - } - userInfo[username] = password - } - } - return userInfo, nil -} - -func applyFileAuthOverridesLocal(log logger.LoggerInterface, webAdminUserInfo map[string]string, serverconfContent []byte) ([]byte, error) { - serverconfMap := make(map[interface{}]interface{}) - err := unmarshal([]byte(serverconfContent), &serverconfMap) - if err != nil { - log.Errorf("Error unmarshalling server.conf.yaml content: %v", err) - return nil, err - } - - permissionsMap := map[string]string{ - "admin": "read+:write+:execute+", - "operator": "read+:write-:execute+", - "editor": "read+:write+:execute-", - "audit": "read+:write-:execute-", - "viewer": "read+:write-:execute-", - } - - if serverconfMap["Security"] == nil { - serverconfMap["Security"] = map[interface{}]interface{}{} - security := serverconfMap["Security"].(map[interface{}]interface{}) - if security["DataPermissions"] == nil && security["Permissions"] == nil { - security["DataPermissions"] = map[interface{}]interface{}{} - dataPermissions := security["DataPermissions"].(map[interface{}]interface{}) - security["Permissions"] = map[interface{}]interface{}{} - permissions := security["Permissions"].(map[interface{}]interface{}) - if _, ok := webAdminUserInfo["ibm-ace-dashboard-admin"]; ok { - dataPermissions["admin"] = permissionsMap["admin"] - permissions["admin"] = permissionsMap["admin"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-operator"]; ok { - permissions["operator"] = permissionsMap["operator"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-editor"]; ok { - permissions["editor"] = permissionsMap["editor"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-audit"]; ok { - permissions["audit"] = permissionsMap["audit"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-viewer"]; ok { - permissions["viewer"] = permissionsMap["viewer"] - } - } - } else { - security := serverconfMap["Security"].(map[interface{}]interface{}) - if security["DataPermissions"] == nil && security["Permissions"] == nil { - security["DataPermissions"] = map[interface{}]interface{}{} - dataPermissions := security["DataPermissions"].(map[interface{}]interface{}) - security["Permissions"] = map[interface{}]interface{}{} - permissions := security["Permissions"].(map[interface{}]interface{}) - if _, ok := webAdminUserInfo["ibm-ace-dashboard-admin"]; ok { - dataPermissions["admin"] = permissionsMap["admin"] - permissions["admin"] = permissionsMap["admin"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-operator"]; ok { - permissions["operator"] = permissionsMap["operator"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-editor"]; ok { - permissions["editor"] = permissionsMap["editor"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-audit"]; ok { - permissions["audit"] = permissionsMap["audit"] - } - if _, ok := webAdminUserInfo["ibm-ace-dashboard-viewer"]; ok { - permissions["viewer"] = permissionsMap["viewer"] - } - } - } - - serverconfYaml, err := marshal(&serverconfMap) - if err != nil { - log.Errorf("Error marshalling server.conf.yaml overrides: %v", err) - return nil, err - } - - return serverconfYaml, nil - -} - -func keyGen(password string) string { - salt := make([]byte, 16) - rand.Read(salt) - dk := pbkdf2.Key([]byte(password), salt, 65536, 64, sha512.New) - return fmt.Sprintf("PBKDF2-SHA-512:%s:%s", b64EncodeString(salt), b64EncodeString(dk)) -} - -func readServerConfFile() ([]byte, error) { - return readFile(homedir + "ace-server/overrides/server.conf.yaml") - -} - -func writeServerConfFile(content []byte) error { - return writeFile(homedir+"ace-server/overrides/server.conf.yaml", content, 0644) -} - -func outputFilesLocal(log logger.LoggerInterface, files map[string]string) error { - dir := homedir + "ace-server/config/registry/integration_server/CurrentVersion/WebAdmin/user/" - webadminDir := dir + files["role"] - err := mkdirAll(webadminDir, 0755) - if err != nil { - log.Errorf("Error creating directories: %v", err) - return err - } - - for fileName, fileContent := range files { - // The 'role' is populated from the users.txt files in initial-config e.g. admin-users.txt we need to trim this to the actual role which would be 'admin' - fileContent = strings.TrimPrefix(fileContent, "ibm-ace-dashboard-") - err := writeFile(webadminDir+"/"+fileName, []byte(fileContent), 0660) - if err != nil { - log.Errorf("Error writing files: %v %s", err, fileName) - return err - } - - } - - return nil -} - -func b64EncodeString(data []byte) string { - return b64.StdEncoding.EncodeToString(data) -} - -func readWebUsersTxtLocal(log logger.LoggerInterface, filename string) (string, string, error) { - out, err := readFile(filename) - if err != nil { - log.Errorf("Error reading WebAdmin users.txt file: %v", err) - return "", "", err - } - - credentials := strings.Fields(string(out)) - return credentials[0], credentials[1], nil -} diff --git a/internal/webadmin/webadmin_test.go b/internal/webadmin/webadmin_test.go deleted file mode 100644 index b95cc5b..0000000 --- a/internal/webadmin/webadmin_test.go +++ /dev/null @@ -1,490 +0,0 @@ -package webadmin - -import ( - b64 "encoding/base64" - "errors" - "os" - "strings" - "testing" - - "github.com/ot4i/ace-docker/common/logger" - "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" -) - -// Allows us to read server.conf.yaml out into a struct which makes it easier check the values -type ServerConf struct { - RestAdminListener struct { - AuthorizationEnabled bool `yaml:"authorizationEnabled"` - } `yaml:"RestAdminListener"` - Security struct { - LdapAuthorizeAttributeToRoleMap struct { - RandomField string `yaml:"randomfield"` - } `yaml:"LdapAuthorizeAttributeToRoleMap"` - DataPermissions struct { - Admin string `yaml:"admin"` - } `yaml:"DataPermissions"` - Permissions struct { - Admin string `yaml:"admin"` - Audit string `yaml:"audit"` - Editor string `yaml:"editor"` - Operator string `yaml:"operator"` - Viewer string `yaml:"viewer"` - } `yaml:"Permissions"` - } `yaml:"Security"` -} -type ServerConfWithoutSecurity struct { - RestAdminListener struct { - AuthorizationEnabled bool `yaml:"authorizationEnabled"` - } `yaml:"RestAdminListener"` -} - -type ServerConfNoPermissions struct { - RestAdminListener struct { - AuthorizationEnabled bool `yaml:"authorizationEnabled"` - } `yaml:"RestAdminListener"` - Security struct { - LdapAuthorizeAttributeToRoleMap struct { - RandomField string `yaml:"randomfield"` - } `yaml:"LdapAuthorizeAttributeToRoleMap"` - } `yaml:"Security"` -} - -func Test_ConfigureWebAdminUsers(t *testing.T) { - log, _ := logger.NewLogger(os.Stdout, true, false, "testloger") - oldReadFile := readFile - oldProcessWebAdminUsers := processWebAdminUsers - oldApplyFileAuthOverrides := applyFileAuthOverrides - oldWriteFile := writeFile - oldOutputFiles := outputFiles - t.Run("Golden path - all functions are free from errors and ConfigureWebAdminUsers returns nil", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, nil - } - - processWebAdminUsers = func(logger.LoggerInterface, string) (map[string]string, error) { - usersMap := map[string]string{ - "ibm-ace-dashboard-admin": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - } - - return usersMap, nil - } - - applyFileAuthOverrides = func(log logger.LoggerInterface, webAdminUserInfo map[string]string, serverconfContent []byte) ([]byte, error) { - - return nil, nil - } - writeFile = func(name string, data []byte, perm os.FileMode) error { - return nil - } - outputFiles = func(logger.LoggerInterface, map[string]string) error { - return nil - } - err := ConfigureWebAdminUsers(log) - assert.NoError(t, err) - readFile = oldReadFile - processWebAdminUsers = oldProcessWebAdminUsers - applyFileAuthOverrides = oldApplyFileAuthOverrides - writeFile = oldWriteFile - outputFiles = oldOutputFiles - - }) - - t.Run("readServerConfFile returns an error unable to read server.conf.yaml file", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, errors.New("Unable to read server.conf.yaml") - } - err := ConfigureWebAdminUsers(log) - assert.Error(t, err) - assert.Equal(t, "Unable to read server.conf.yaml", err.Error()) - readFile = oldReadFile - - }) - t.Run("processAdminUsers returns an error unable to process webadmin users", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, nil - } - - processWebAdminUsers = func(log logger.LoggerInterface, dir string) (map[string]string, error) { - return nil, errors.New("Unable to process web admin users") - } - - err := ConfigureWebAdminUsers(log) - assert.Error(t, err) - assert.Equal(t, "Unable to process web admin users", err.Error()) - readFile = oldReadFile - processWebAdminUsers = oldProcessWebAdminUsers - - }) - - t.Run("applyFileAuthOverrides returns an error unable to apply file auth overrides", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, nil - } - - processWebAdminUsers = func(log logger.LoggerInterface, dir string) (map[string]string, error) { - return nil, nil - } - - applyFileAuthOverrides = func(log logger.LoggerInterface, webAdminUserInfo map[string]string, serverconfContent []byte) ([]byte, error) { - return nil, errors.New("Unable to apply file auth overrides") - } - - err := ConfigureWebAdminUsers(log) - assert.Error(t, err) - assert.Equal(t, "Unable to apply file auth overrides", err.Error()) - readFile = oldReadFile - processWebAdminUsers = oldProcessWebAdminUsers - applyFileAuthOverrides = oldApplyFileAuthOverrides - - }) - - t.Run("writeServerConfFile error writing server.conf.yaml overrides back into the file", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, nil - } - - processWebAdminUsers = func(log logger.LoggerInterface, dir string) (map[string]string, error) { - return nil, nil - } - - applyFileAuthOverrides = func(log logger.LoggerInterface, webAdminUserInfo map[string]string, serverconfContent []byte) ([]byte, error) { - return nil, nil - } - writeFile = func(name string, data []byte, perm os.FileMode) error { - return errors.New("Error writing server.conf.yaml back after overrides") - } - err := ConfigureWebAdminUsers(log) - assert.Error(t, err) - assert.Equal(t, "Error writing server.conf.yaml back after overrides", err.Error()) - readFile = oldReadFile - processWebAdminUsers = oldProcessWebAdminUsers - applyFileAuthOverrides = oldApplyFileAuthOverrides - writeFile = oldWriteFile - - }) - - t.Run("writeServerConfFile error writing server.conf.yaml overrides back into the file", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return nil, nil - } - - processWebAdminUsers = func(logger.LoggerInterface, string) (map[string]string, error) { - usersMap := map[string]string{ - "ibm-ace-dashboard-admin": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - } - - return usersMap, nil - } - - applyFileAuthOverrides = func(log logger.LoggerInterface, webAdminUserInfo map[string]string, serverconfContent []byte) ([]byte, error) { - - return nil, nil - } - writeFile = func(name string, data []byte, perm os.FileMode) error { - return nil - } - outputFiles = func(logger.LoggerInterface, map[string]string) error { - return errors.New("Error outputting files during password generation") - } - err := ConfigureWebAdminUsers(log) - assert.Error(t, err) - assert.Equal(t, "Error outputting files during password generation", err.Error()) - readFile = oldReadFile - processWebAdminUsers = oldProcessWebAdminUsers - applyFileAuthOverrides = oldApplyFileAuthOverrides - writeFile = oldWriteFile - outputFiles = oldOutputFiles - }) -} - -func Test_processWebAdminUsers(t *testing.T) { - log, _ := logger.NewLogger(os.Stdout, true, false, "testloger") - t.Run("readDir returns error reading directory", func(t *testing.T) { - oldReadDir := readDir - readDir = func(name string) ([]os.DirEntry, error) { - return nil, errors.New("Error reading directory") - } - _, err := processWebAdminUsers(log, "dir") - assert.Error(t, err) - assert.Equal(t, "Error reading directory", err.Error()) - - readDir = oldReadDir - }) - t.Run("Golden path - processWebAdminUsers loops over fileList and falls readWebUsersTxt for each .txt file ", func(t *testing.T) { - webAdminUsers, err := processWebAdminUsers(log, "testdata/initial-config/webusers/") - assert.NoError(t, err) - assert.Equal(t, "1758F07A-8BEF-448C-B020-C25946AF3E94", webAdminUsers["ibm-ace-dashboard-admin"]) - assert.Equal(t, "68FE7808-8EC2-4395-97D0-A776D2A61912", webAdminUsers["ibm-ace-dashboard-operator"]) - assert.Equal(t, "28DBC34B-C0FD-44BF-8100-99DB686B6DB2", webAdminUsers["ibm-ace-dashboard-editor"]) - assert.Equal(t, "929064C2-0017-4B34-A883-219A4D1AC944", webAdminUsers["ibm-ace-dashboard-audit"]) - assert.Equal(t, "EF086556-74B8-4FB0-ACF8-CC59E1F3DB5F", webAdminUsers["ibm-ace-dashboard-viewer"]) - }) - - t.Run("readWebUsersTxt fails to read files", func(t *testing.T) { - oldReadWebUsersTxt := readWebUsersTxt - readWebUsersTxt = func(logger logger.LoggerInterface, filename string) (string, string, error) { - return "", "", errors.New("Error reading WebAdmin users txt file") - } - _, err := processWebAdminUsers(log, "testdata/initial-config/webusers") - assert.Error(t, err) - assert.Equal(t, "Error reading WebAdmin users txt file", err.Error()) - - readWebUsersTxt = oldReadWebUsersTxt - }) - -} - -func Test_applyFileAuthOverrides(t *testing.T) { - log, _ := logger.NewLogger(os.Stdout, true, false, "testloger") - usersMap := map[string]string{ - "ibm-ace-dashboard-admin": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - "ibm-ace-dashboard-operator": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - "ibm-ace-dashboard-editor": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - "ibm-ace-dashboard-audit": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - "ibm-ace-dashboard-viewer": "12AB0C96-E155-43FA-BA03-BD93AA2166E0", - } - t.Run("Golden path - server.conf.yaml is populated as expected", func(t *testing.T) { - // Pass in server.conf.yaml with some fields populated to prove we don't remove existing overrides - servConf := &ServerConfWithoutSecurity{} - servConf.RestAdminListener.AuthorizationEnabled = true - servConfByte, err := yaml.Marshal(servConf) - assert.NoError(t, err) - - serverConfContent, err := applyFileAuthOverrides(log, usersMap, servConfByte) - assert.NoError(t, err) - - serverconfMap := make(map[interface{}]interface{}) - err = yaml.Unmarshal(serverConfContent, &serverconfMap) - assert.NoError(t, err) - // This struct has the security tab so that it can parse all the information out to checked in assertions - var serverConfWithSecurity ServerConf - err = yaml.Unmarshal(serverConfContent, &serverConfWithSecurity) - if err != nil { - t.Log(err) - t.Fail() - - } - - assert.Equal(t, "read+:write+:execute+", serverConfWithSecurity.Security.DataPermissions.Admin) - assert.Equal(t, "read+:write+:execute+", serverConfWithSecurity.Security.Permissions.Admin) - - assert.Equal(t, "read+:write-:execute+", serverConfWithSecurity.Security.Permissions.Operator) - assert.Equal(t, "read+:write+:execute-", serverConfWithSecurity.Security.Permissions.Editor) - assert.Equal(t, "read+:write-:execute-", serverConfWithSecurity.Security.Permissions.Audit) - assert.Equal(t, "read+:write-:execute-", serverConfWithSecurity.Security.Permissions.Viewer) - - }) - t.Run("server.conf.yaml has a Security entry but no entry for DataPermissions or Permissions - to prove we still change permissions if security exists in yaml", func(t *testing.T) { - - servConf := &ServerConfNoPermissions{} - servConf.Security.LdapAuthorizeAttributeToRoleMap.RandomField = "randomstring" - servConfByte, err := yaml.Marshal(servConf) - assert.NoError(t, err) - - serverConfContent, err := applyFileAuthOverrides(log, usersMap, servConfByte) - assert.NoError(t, err) - - serverconfMap := make(map[interface{}]interface{}) - err = yaml.Unmarshal(serverConfContent, &serverconfMap) - assert.NoError(t, err) - - // If the Permissions or DataPermissions do not exist we create them and therefore the below struct is to parse them into to make the `assert.Equal` checks easy - var serverConfWithSecurity ServerConf - err = yaml.Unmarshal(serverConfContent, &serverConfWithSecurity) - if err != nil { - t.Log(err) - t.Fail() - } - - assert.Equal(t, "read+:write+:execute+", serverConfWithSecurity.Security.DataPermissions.Admin) - assert.Equal(t, "read+:write+:execute+", serverConfWithSecurity.Security.Permissions.Admin) - - assert.Equal(t, "read+:write-:execute+", serverConfWithSecurity.Security.Permissions.Operator) - assert.Equal(t, "read+:write+:execute-", serverConfWithSecurity.Security.Permissions.Editor) - assert.Equal(t, "read+:write-:execute-", serverConfWithSecurity.Security.Permissions.Audit) - assert.Equal(t, "read+:write-:execute-", serverConfWithSecurity.Security.Permissions.Viewer) - - }) - - t.Run("Unable to unmarhsall server conf into map for parsing", func(t *testing.T) { - oldUnmarshal := unmarshal - unmarshal = func(in []byte, out interface{}) (err error) { - return errors.New("Unable to unmarshall server conf") - } - - _, err := applyFileAuthOverrides(log, usersMap, []byte{}) - assert.Error(t, err) - assert.Equal(t, "Unable to unmarshall server conf", err.Error()) - unmarshal = oldUnmarshal - }) - - t.Run("Unable to marshall server conf after processing", func(t *testing.T) { - oldMarshal := marshal - marshal = func(in interface{}) (out []byte, err error) { - return nil, errors.New("Unable to marshall server conf") - } - _, err := applyFileAuthOverrides(log, usersMap, []byte{}) - assert.Error(t, err) - assert.Equal(t, "Unable to marshall server conf", err.Error()) - marshal = oldMarshal - }) -} -func Test_KeyGen(t *testing.T) { - // Result is of the format ALGORITHM:SALT:ENCRYPTED-PASSWORD - result := keyGen("afc6dd77-ee58-4a51-8ecd-26f55e2ce2fb") - splitResult := strings.Split(result, ":") - - // Decode salt - decodedString, err := b64.StdEncoding.DecodeString(splitResult[1]) - if err != nil { - t.Log(err) - t.Fail() - } - - // Decode password - decodedPasswordString, err := b64.StdEncoding.DecodeString(splitResult[2]) - if err != nil { - t.Log(err) - t.Fail() - } - assert.Equal(t, "PBKDF2-SHA-512", splitResult[0]) - assert.Equal(t, 16, len(decodedString)) - assert.Equal(t, 64, len(decodedPasswordString)) -} -func Test_readServerConfFile(t *testing.T) { - readFile = func(name string) ([]byte, error) { - serverConfContent := []byte("this is a fake server.conf.yaml file") - return serverConfContent, nil - } - serverConfContent, err := readServerConfFile() - assert.NoError(t, err) - assert.Equal(t, "this is a fake server.conf.yaml file", string(serverConfContent)) -} - -func Test_writeServerConfFile(t *testing.T) { - writeFile = func(name string, data []byte, perm os.FileMode) error { - return nil - } - serverConfContent := []byte{} - err := writeServerConfFile(serverConfContent) - assert.NoError(t, err) -} - -func Test_outputFiles(t *testing.T) { - log, _ := logger.NewLogger(os.Stdout, true, false, "testloger") - m := map[string]string{ - "password": "password1234", - "role": "ibm-ace-dashboard-admin", - "version": "12.0.0.0", - } - t.Run("Golden path scenario - Outputting all files is successful and we get a nil error", func(t *testing.T) { - oldmkdirAll := mkdirAll - oldwriteFile := writeFile - mkdirAll = func(path string, perm os.FileMode) error { - return nil - } - writeFile = func(name string, data []byte, perm os.FileMode) error { - /* - This UT will fail if the code to trim 'ibm-ace-dashboard-' from the contents of the 'role' file gets removed. - This contents gets read in dfrom users.txt file e.g. admin-users.txt with 'ibm-ace-dashboard- PASSWORD' as the format. - Example - 'ibm-ace-dashboard-admin 08FDD35A-6EA0-4D48-A87D-E6373D414824' - We need to trim the 'ibm-ace-dashboard-admin' down to 'admin' as that is the role that is used in the server.conf.yaml overrides. - */ - if strings.Contains(name, "role") { - if strings.Contains(string(data), "ibm-ace-dashboard-") { - t.Log("writeFile should be called with only the role e.g. 'admin' and not 'ibm-ace-dashboard-admin'") - t.Fail() - } - } - return nil - } - err := outputFiles(log, m) - assert.NoError(t, err) - mkdirAll = oldmkdirAll - writeFile = oldwriteFile - }) - - t.Run("mkdirAll fails to create the directories for WebAdmin users", func(t *testing.T) { - oldmkdirAll := mkdirAll - mkdirAll = func(path string, perm os.FileMode) error { - return errors.New("mkdirAll fails to create WebAdmin users text") - } - outputFiles(log, m) - mkdirAll = oldmkdirAll - }) - - t.Run("Writing the file to disk fails", func(t *testing.T) { - oldmkdirAll := mkdirAll - mkdirAll = func(path string, perm os.FileMode) error { - return nil - } - oldwriteFile := writeFile - writeFile = func(name string, data []byte, perm os.FileMode) error { - return errors.New("Unable to write files to disk") - } - err := outputFiles(log, m) - assert.Error(t, err) - mkdirAll = oldmkdirAll - writeFile = oldwriteFile - }) - -} -func Test_b64EncodeString(t *testing.T) { - type args struct { - data []byte - } - tests := []struct { - name string - args args - want string - }{ - { - name: "Base64 the following text - hello", - args: args{data: []byte("hello")}, - want: "aGVsbG8=", - }, - { - name: "Base64 the following text - randomtext", - args: args{data: []byte("randomtext")}, - want: "cmFuZG9tdGV4dA==", - }, - { - name: "Base64 the following text - afc6dd77-ee58-4a51-8ecd-26f55e2ce2fb", - args: args{data: []byte("afc6dd77-ee58-4a51-8ecd-26f55e2ce2fb")}, - want: "YWZjNmRkNzctZWU1OC00YTUxLThlY2QtMjZmNTVlMmNlMmZi", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := b64EncodeString(tt.args.data); got != tt.want { - t.Errorf("b64EncodeString() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_readWebUsersTxt(t *testing.T) { - log, _ := logger.NewLogger(os.Stdout, true, false, "testloger") - t.Run("readWebUsersTxt success scenario - returns the username and password with nil error", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return []byte("ibm-ace-dashboard-admin afc6dd77-ee58-4a51-8ecd-26f55e2ce2f"), nil - } - - username, password, err := readWebUsersTxt(log, "admin-users.txt") - assert.NoError(t, err) - assert.Equal(t, "ibm-ace-dashboard-admin", username) - assert.Equal(t, "afc6dd77-ee58-4a51-8ecd-26f55e2ce2f", password) - - }) - t.Run("readWebUsersTxt failure scenario - returns empty username and password with error", func(t *testing.T) { - readFile = func(name string) ([]byte, error) { - return []byte{}, errors.New("Error reading file") - } - - username, password, err := readWebUsersTxt(log, "admin-users.txt") - assert.Equal(t, "", username) - assert.Equal(t, "", password) - assert.Error(t, err) - }) -} diff --git a/licenses/LICENSE b/licenses/LICENSE new file mode 100644 index 0000000..7b0e98d --- /dev/null +++ b/licenses/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018 IBM Corporation + + 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. diff --git a/licenses/non_ibm_license b/licenses/non_ibm_license deleted file mode 100644 index 55d9257..0000000 Binary files a/licenses/non_ibm_license and /dev/null differ diff --git a/licenses/notices b/licenses/notices deleted file mode 100644 index e303f93..0000000 Binary files a/licenses/notices and /dev/null differ diff --git a/sample/Dockerfile.aceonly b/sample/Dockerfile.aceonly deleted file mode 100644 index cea0cce..0000000 --- a/sample/Dockerfile.aceonly +++ /dev/null @@ -1,16 +0,0 @@ -FROM ace-only:latest - -USER root - -COPY bars_aceonly /home/aceuser/bars -RUN chmod -R ugo+rwx /home/aceuser - -USER 1000 - -RUN ace_compile_bars.sh - -USER root - -RUN chmod -R ugo+rwx /home/aceuser - -USER 1000 \ No newline at end of file diff --git a/sample/PIs/CallHTTPSEcho.zip b/sample/PIs/CallHTTPSEcho.zip deleted file mode 100644 index 307dfa5..0000000 Binary files a/sample/PIs/CallHTTPSEcho.zip and /dev/null differ diff --git a/sample/PIs/CallMQEcho.zip b/sample/PIs/CallMQEcho.zip deleted file mode 100644 index b1da86d..0000000 Binary files a/sample/PIs/CallMQEcho.zip and /dev/null differ diff --git a/sample/PIs/CallMQMultiEcho.zip b/sample/PIs/CallMQMultiEcho.zip deleted file mode 100644 index 91668b1..0000000 Binary files a/sample/PIs/CallMQMultiEcho.zip and /dev/null differ diff --git a/sample/PIs/HTTPSEcho.zip b/sample/PIs/HTTPSEcho.zip deleted file mode 100644 index 241614c..0000000 Binary files a/sample/PIs/HTTPSEcho.zip and /dev/null differ diff --git a/sample/PIs/MQEcho.zip b/sample/PIs/MQEcho.zip deleted file mode 100644 index 58d57c0..0000000 Binary files a/sample/PIs/MQEcho.zip and /dev/null differ diff --git a/sample/PIs/MQMultiEcho.zip b/sample/PIs/MQMultiEcho.zip deleted file mode 100644 index aae63c6..0000000 Binary files a/sample/PIs/MQMultiEcho.zip and /dev/null differ diff --git a/sample/README.md b/sample/README.md deleted file mode 100644 index fa7f592..0000000 --- a/sample/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Sample - -The sample folder contains Docker files that build a sample image containing sample applications and Integration Server configuration. This requires you to mount the sample `initial-config` folder as well. - -## Build the sample image - -You need to assign everyone with read+write permissions for all files that you ADD/COPY into your custom image. The same goes for any files generated from running a script inside your custom image. This is to support the container being run under the OCP "restricted" ID. - -### Sample based on the ACE only image - -First [build the ACE only image](../README.md#build-an-image-with-app-connect-enterprise-only). - -In the `sample` folder: - -``` -docker build -t aceapp --file Dockerfile.aceonly . -``` - -## Run the sample image -### ACE only image - -To run a container based on the ACE only image and these settings: -- ACE server name `ACESERVER` -- listener for ACE web ui on port `7600` -- listener for ACE HTTP on port `7600` -- ACE truststore password `truststorepwd` -- ACE keystore password `keystorepwd` - -And mounting `sample/initial-config` with the sample configuration into `/home/aceuser/initial-config`. - -> **Note**: Always mount any initial config to be processed on start up to `/home/aceuser/initial-config`. - -`docker run --name aceapp -p 7600:7600 -p 7800:7800 -p 7843:7843 --env LICENSE=accept --env ACE_SERVER_NAME=ACESERVER --mount type=bind,src=/{path to repo}/sample/initial-config,dst=/home/aceuser/initial-config --env ACE_TRUSTSTORE_PASSWORD=truststorepwd --env ACE_KEYSTORE_PASSWORD=keystorepwd aceapp:latest` - -## What is in the sample? - -- **bars_aceonly** contains BAR files for sample applications that don't need MQ. These will be copied into the image (at build time) to `/home/aceuser/bars` and compiled. The Integration Server will pick up and deploy this files on start up. These set of BAR files will be copied when building an image with ACE only or ACE & MQ. -- **dashboards** contains json defined sample grafana and kibana dashboards. This image has a prometheus exporter, which makes information available to prometheus for statistics data. The grafana dashboard gives a sample visualization of this data. The kibana dashboard is based on the json output from an Integration Server (v11.0.0.2). `LOG_FORMAT` env variable has to be set to `json`. -- **initial-config** is a directory that can be mounted by the container. This contains sample configuration files that the container will process on start up. -- **PIs** contain Project Interchange files with the source for the applications that will be loaded from `bars_aceonly` and `bars_mq`. -- **Dockerfile.aceonly** the Dockerfile that builds "FROM" the `ace-only` image and builds an application image. -- **Dockerfile.acemq** the Dockerfile that builds "FROM" the `ace-mq` image and builds an application image. - -## What are the sample applications? -All of the applications either just echo back a timestamp, or call another flow that echoes a timestamp: - -- **HTTPSEcho** - Presents an echo service over a HTTPS endpoint on port 7843. This uses self-signed certificates (from `initial-config/keystore`). You can call this by going to https://localhost:7843/Echo (though you will get an exception about the certificate), or running `curl -k https://localhost:7843/Echo`. This demonstrates how to deploy a flow that presents a HTTPS endpoint, and how to apply a policy and custom `server.conf.yaml` overrides. -- **CallHTTPSEcho** - Wraps a call to `HTTPSEcho` and presents a service over HTTP that is convenient to call. This uses out self-signed CA certificate (from `initial-config/truststore`) to ensure the call to the HTTPS server is trusted. You can call this by going to http://localhost:7800/CallHTTPSEcho, or running `curl http://localhost:7800/CallHTTPSEcho`. This demonstrates how to deploy flow that calls a HTTPS endpoint with specific trust certificates. diff --git a/sample/bars_aceonly/CallHTTPSEcho.bar b/sample/bars_aceonly/CallHTTPSEcho.bar deleted file mode 100644 index a861e04..0000000 Binary files a/sample/bars_aceonly/CallHTTPSEcho.bar and /dev/null differ diff --git a/sample/bars_aceonly/HTTPSEcho.bar b/sample/bars_aceonly/HTTPSEcho.bar deleted file mode 100644 index 4c6347d..0000000 Binary files a/sample/bars_aceonly/HTTPSEcho.bar and /dev/null differ diff --git a/sample/dashboards/ibm-ace-grafana-dashboard.json b/sample/dashboards/ibm-ace-grafana-dashboard.json deleted file mode 100644 index bac6945..0000000 --- a/sample/dashboards/ibm-ace-grafana-dashboard.json +++ /dev/null @@ -1,2305 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "5.2.0" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "5.0.0" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "5.0.0" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "5.0.0" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "description": "", - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": null, - "iteration": 1539896079460, - "links": [], - "panels": [ - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 27, - "panels": [], - "title": "Msgflow Invocations", - "type": "row" - }, - { - "aliasColors": { - "acedemois.Echo": "#f2c96d", - "demo2is.Echo": "#7eb26d" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 10, - "x": 0, - "y": 1 - }, - "id": 6, - "interval": "", - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "repeatDirection": "v", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(delta(ibmace_msgflow_messages_total{server=~'$server', application=~'$application', msgflow=~'$msgflow'}[5m])) by (server, application, msgflow)", - "format": "time_series", - "hide": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{ msgflow }}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Messages", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "transparent": false, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 7, - "x": 10, - "y": 1 - }, - "id": 23, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Total Msgflow Invocations", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "link": false, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "short" - }, - { - "alias": "Server", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflow_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "title": "Msgflow Invocations by Server", - "transform": "timeseries_aggregations", - "type": "table" - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 7, - "x": 17, - "y": 1 - }, - "id": 24, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Total Msgflow Errors", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "link": false, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "short" - }, - { - "alias": "Server", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflow_errors_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "title": "Msgflow Errors by Server", - "transform": "timeseries_aggregations", - "type": "table" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 10 - }, - "id": 29, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 0, - "y": 11 - }, - "id": 12, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(increase(ibmace_msgflow_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}[5m])) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Msgflow CPU Time by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "CPU Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 9, - "y": 11 - }, - "id": 18, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "avg(ibmace_msgflow_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}/ibmace_msgflow_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Average Msgflow CPU Time by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "CPU Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 18, - "y": 11 - }, - "id": 16, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "CPU Time", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "ms" - }, - { - "alias": "Server", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflow_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "title": "Total Msgflow CPU Time by Server", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflow CPU Time", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 11 - }, - "id": 31, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 0, - "y": 21 - }, - "id": 19, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(increase(ibmace_msgflow_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}[5m])) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Msgflow Elapsed Time by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "Elapsed Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 9, - "y": 21 - }, - "id": 20, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "avg(ibmace_msgflow_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}/ibmace_msgflow_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Average Msgflow Elapsed Time by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "Elapsed Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 18, - "y": 21 - }, - "id": 21, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Server", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "Elapsed Time", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "ms" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflow_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "title": "Total Msgflow Elapsed Time by Server", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflow Elapsed Time", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 12 - }, - "id": 33, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 0, - "y": 31 - }, - "id": 25, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(increase(ibmace_msgflow_messages_bytes_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}[5m])) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Msgflow Bytes Processed by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": "Bytes Processed", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 9, - "y": 31 - }, - "id": 35, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "avg(ibmace_msgflow_messages_bytes_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}/ibmace_msgflow_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Average Msgflow Bytes Processed by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": "Bytes Processed", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 18, - "y": 31 - }, - "id": 37, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Server", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "Bytes", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "short" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflow_messages_bytes_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "title": "Total Msgflow Bytes Processed by Server", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflow Bytes", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 13 - }, - "id": 39, - "panels": [ - { - "aliasColors": { - "acedemois.Echo": "#f2c96d", - "demo2is.Echo": "#7eb26d" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 10, - "x": 0, - "y": 41 - }, - "id": 40, - "interval": "", - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeatDirection": "v", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(delta(ibmace_msgflownode_messages_total{server=~'$server', application=~'$application', msgflow=~'$msgflow'}[5m])) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "hide": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{ msgflow }}.{{msgflownode}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Messages", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "transparent": false, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 7, - "x": 10, - "y": 41 - }, - "id": 42, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Total Msgflownode Invocations", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "link": false, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "short" - }, - { - "alias": "Msgflownode", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflownode_messages_total{server=~'$server', application=~'$application', msgflow=~'$msgflow'}) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "title": "Invocations by Msgflownodes", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflownode Invocations", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 14 - }, - "id": 44, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 0, - "y": 51 - }, - "id": 45, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(increase(ibmace_msgflownode_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}[5m])) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Msgflownode CPU Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "CPU Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 9, - "y": 51 - }, - "id": 46, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "avg(ibmace_msgflownode_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}/ibmace_msgflownode_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Average Msgflownode CPU Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "CPU ms", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 18, - "y": 51 - }, - "id": 47, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Msgflownode", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "CPU Time", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "ms" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflownode_cpu_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server,application,msgflow,msgflownode)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "title": "CPU Time by Msgflownode", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflownode CPU Time", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 15 - }, - "id": 49, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 0, - "y": 61 - }, - "id": 50, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(increase(ibmace_msgflownode_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}[5m])) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Msgflownode Elapsed Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "Elapsed Time", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 9, - "x": 9, - "y": 61 - }, - "id": 51, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "avg(ibmace_msgflownode_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}/ibmace_msgflownode_messages_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server, application, msgflow, msgflownode)", - "format": "time_series", - "instant": false, - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Average Msgflownode Elapsed Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "ms", - "label": "Elapsed ms", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 18, - "y": 61 - }, - "id": 52, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "Msgflownode", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Metric", - "thresholds": [], - "type": "string", - "unit": "short" - }, - { - "alias": "Elapsed Time", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 2, - "mappingType": 1, - "pattern": "Current", - "thresholds": [], - "type": "number", - "unit": "ms" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "sum(ibmace_msgflownode_elapsed_time_seconds_total{server=~'$server',application=~'$application',msgflow=~'$msgflow'}) by (server,application,msgflow,msgflownode)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}.{{msgflow}}.{{msgflownode}}", - "refId": "A" - } - ], - "title": "Elapsed Time by Msgflownode", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "title": "Msgflownode Elapsed Time", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 16 - }, - "id": 54, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 8, - "x": 0, - "y": 62 - }, - "id": 59, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(ibmace_jvm_global_gcs_total{server=~'$server'}) by (server)", - "format": "time_series", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Global GCs by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 8, - "x": 8, - "y": 62 - }, - "id": 56, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(ibmace_jvm_summary_gcs_total{server=~'$server'}) by (server)", - "format": "time_series", - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Scavenger GCs by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "prometheus", - "fill": 1, - "gridPos": { - "h": 9, - "w": 8, - "x": 16, - "y": 62 - }, - "id": 57, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(ibmace_jvm_summary_used_memory_bytes{server=~'$server'}) by (server)", - "format": "time_series", - "interval": "300s", - "intervalFactor": 1, - "legendFormat": "{{server}}.heap", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "JVM Heap Used by Server", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "title": "JVM Resource", - "type": "row" - } - ], - "refresh": false, - "schemaVersion": 16, - "style": "dark", - "tags": [ - "App Connect Enterprise", - "ACE" - ], - "templating": { - "list": [ - { - "allValue": ".*", - "current": {}, - "datasource": "prometheus", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "server", - "options": [], - "query": "label_values(ibmace_msgflow_messages_total, server)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": ".*", - "current": {}, - "datasource": "prometheus", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "application", - "options": [], - "query": "label_values(ibmace_msgflow_messages_total, application)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": ".*", - "current": {}, - "datasource": "prometheus", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "msgflow", - "options": [], - "query": "label_values(ibmace_msgflow_messages_total, msgflow)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-6h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "utc", - "title": "IBM App Connect Enterprise", - "uid": "2GhmoPJik", - "version": 36 -} diff --git a/sample/dashboards/ibm-ace-kibana5-dashboard.json b/sample/dashboards/ibm-ace-kibana5-dashboard.json deleted file mode 100644 index c0ae6b9..0000000 --- a/sample/dashboards/ibm-ace-kibana5-dashboard.json +++ /dev/null @@ -1,132 +0,0 @@ -[ - { - "_id": "2ec556f0-d14a-11e8-a912-33b3894d5781", - "_type": "dashboard", - "_source": { - "title": "App-Connect-Enterprise", - "hits": 0, - "description": "", - "panelsJSON": "[{\"col\":7,\"id\":\"fedd8120-d148-11e8-a912-33b3894d5781\",\"panelIndex\":1,\"row\":6,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":1,\"id\":\"ff69d810-d147-11e8-a912-33b3894d5781\",\"panelIndex\":3,\"row\":3,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":7,\"id\":\"4b05c540-d148-11e8-a912-33b3894d5781\",\"panelIndex\":4,\"row\":3,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":1,\"id\":\"c1db8600-d148-11e8-a912-33b3894d5781\",\"panelIndex\":5,\"row\":9,\"size_x\":12,\"size_y\":4,\"type\":\"visualization\"},{\"col\":1,\"id\":\"94b593d0-d24e-11e8-a999-556a245d56b8\",\"panelIndex\":7,\"row\":6,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":1,\"columns\":[\"message\",\"ibm_serverName\",\"type\",\"loglevel\"],\"id\":\"9a320c80-d145-11e8-a912-33b3894d5781\",\"panelIndex\":8,\"row\":13,\"size_x\":12,\"size_y\":18,\"sort\":[\"@timestamp\",\"asc\"],\"type\":\"search\"},{\"size_x\":12,\"size_y\":2,\"panelIndex\":9,\"type\":\"visualization\",\"id\":\"395e6600-d312-11e8-849b-6df49d41b7f0\",\"col\":1,\"row\":1}]", - "optionsJSON": "{\"darkTheme\":false}", - "uiStateJSON": "{\"P-1\":{\"vis\":{\"colors\":{\"ERROR\":\"#BF1B00\",\"FATAL\":\"#962D82\",\"INFO\":\"#629E51\",\"WARN\":\"#E0752D\"}}},\"P-3\":{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}},\"P-4\":{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}},\"P-7\":{\"vis\":{\"colors\":{\"Start Resource\":\"#64B0C8\",\"Start Server\":\"#629E51\",\"Stop Resource\":\"#E0752D\",\"Stop Server\":\"#BF1B00\"}}}}", - "version": 1, - "timeRestore": false, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}],\"highlightAll\":true,\"version\":true}" - } - } - }, - { - "_id": "9a320c80-d145-11e8-a912-33b3894d5781", - "_type": "search", - "_source": { - "title": "App-Connect-Enterprise", - "description": "", - "hits": 0, - "columns": [ - "message", - "ibm_serverName", - "type", - "loglevel" - ], - "sort": [ - "@timestamp", - "asc" - ], - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"logstash-*\",\"highlightAll\":true,\"version\":true,\"query\":{\"query_string\":{\"query\":\"ibm_product:\\\"IBM App Connect Enterprise\\\"\",\"analyze_wildcard\":true}},\"filter\":[]}" - } - } - }, - { - "_id": "ff69d810-d147-11e8-a912-33b3894d5781", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Top5-Hosts-Generating-Log-Events", - "visState": "{\"title\":\"App-Connect-Enterprise-Top5-Hosts-Generating-Log-Events\",\"type\":\"table\",\"params\":{\"perPage\":5,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"host.keyword\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", - "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[]}" - } - } - }, - { - "_id": "c1db8600-d148-11e8-a912-33b3894d5781", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Top-5-Log-Events", - "visState": "{\"title\":\"App-Connect-Enterprise-Top-5-Log-Events\",\"type\":\"histogram\",\"params\":{\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{\"text\":\"@timestamp per 5 minutes\"}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"histogram\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"ibm_messageId.keyword\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[]}" - } - } - }, - { - "_id": "94b593d0-d24e-11e8-a999-556a245d56b8", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Start-Stop-Events", - "visState": "{\"title\":\"App-Connect-Enterprise-Start-Stop-Events\",\"type\":\"histogram\",\"params\":{\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{\"text\":\"@timestamp per 5 minutes\"}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"histogram\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"filters\",\"schema\":\"group\",\"params\":{\"filters\":[{\"input\":{\"query\":{\"query_string\":{\"query\":\"ibm_messageId:\\\"1989I\\\"\",\"analyze_wildcard\":true}}},\"label\":\"Stop Server\"},{\"input\":{\"query\":{\"query_string\":{\"query\":\"ibm_messageId:\\\"1990I\\\"\",\"analyze_wildcard\":true}}},\"label\":\"Start Server\"},{\"input\":{\"query\":{\"query_string\":{\"query\":\"ibm_messageId:\\\"2155I\\\" AND message:\\\"Stop\\\"\",\"analyze_wildcard\":true}}},\"label\":\"Stop Resource\"},{\"input\":{\"query\":{\"query_string\":{\"query\":\"ibm_messageId:\\\"2155I\\\" AND message:\\\"Start\\\"\",\"analyze_wildcard\":true}}},\"label\":\"Start Resource\"}]}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[]}" - } - } - }, - { - "_id": "fedd8120-d148-11e8-a912-33b3894d5781", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Log-Events-By-Level", - "visState": "{\"title\":\"App-Connect-Enterprise-Log-Events-By-Level\",\"type\":\"histogram\",\"params\":{\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{\"text\":\"@timestamp per 5 minutes\"}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"histogram\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"loglevel.keyword\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[]}" - } - } - }, - { - "_id": "4b05c540-d148-11e8-a912-33b3894d5781", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Top5-Servers-Generating-Error-Log-Events", - "visState": "{\"title\":\"App-Connect-Enterprise-Top5-Servers-Generating-Error-Log-Events\",\"type\":\"table\",\"params\":{\"perPage\":5,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"ibm_serverName.keyword\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"\"}}],\"listeners\":{}}", - "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[{\"meta\":{\"index\":\"logstash-*\",\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"loglevel.keyword\",\"value\":\"ERROR\"},\"query\":{\"match\":{\"loglevel.keyword\":{\"query\":\"ERROR\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}]}" - } - } - }, - { - "_id": "395e6600-d312-11e8-849b-6df49d41b7f0", - "_type": "visualization", - "_source": { - "title": "App-Connect-Enterprise-Log-Events", - "visState": "{\"title\":\"App-Connect-Enterprise-Log-Events\",\"type\":\"histogram\",\"params\":{\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{\"text\":\"@timestamp per 3 hours\"}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"histogram\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "savedSearchId": "9a320c80-d145-11e8-a912-33b3894d5781", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[]}" - } - } - } -] diff --git a/sample/initial-config/keystore/extra-key.crt b/sample/initial-config/keystore/extra-key.crt deleted file mode 100644 index 11a1c47..0000000 --- a/sample/initial-config/keystore/extra-key.crt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDrzCCApcCCQC7U68DCojUcDANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UEBhMC -R0IxEjAQBgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UE -CgwLSUJNIFVLIEx0ZC4xEDAOBgNVBAsMB0FDRSBJQ1AxFjAUBgNVBAMMDVRlc3Qg -Um9vdCBDQTIxIjAgBgkqhkiG9w0BCQEWE3Rlc3RlcjJAZXhhbXBsZS5jb20wHhcN -MTgxMDMwMTcwNzU4WhcNMzgxMDMwMTcwNzU4WjCBmjELMAkGA1UEBhMCR0IxEjAQ -BgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UECgwLSUJN -IFVLIEx0ZC4xDDAKBgNVBAsMA0FDRTEdMBsGA1UEAwwUbWFjaGluZTIuZXhhbXBs -ZS5jb20xIjAgBgkqhkiG9w0BCQEWE3Rlc3RlcjJAZXhhbXBsZS5jb20wggEiMA0G -CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6d4WygE2z2uWfbhNFDdp/pBzGmB6Z -KiqAdGvMsRriV8JQ4M2/2rskiWXhXe5jKRuedy1TZuyW9CZwmEg0TIIn2OA2JShP -xM+DIWqkg8ZyPNf3vxtchbTP2BCfy6TJoan4svTRDTKlFygtzuEjIFFH5etZKrnI -Olag1cv0+FiuwbU0Y/90BO3cce6KqHNNKe41nltljzg9RGeyg8iv8KVoM447a+yb -4uRLQWzPmFwS2mhTcEn54ScyfqvgL8s0wpRmjL5rAiwjngUNN5Cir8R21qGbDRq9 -S2S02job3Ifr35gzxt+OpfIhcGaiN5f8c+a6pHzKbVzEXVR9xnH9BptjAgMBAAEw -DQYJKoZIhvcNAQELBQADggEBAMT90o79LMS0Zt0ccE8SfSewtX+EgZQoDNvfClzt -T6fMNtSLoWNVj6R6WG/t/BzaMXBpXu5JOKbAXVcfj3kyHgOLvt2Mfpe3gb+zKu6g -HERP7ecTc1+SwlzQVxQH0fOUGcfX/CjGHxrzJGc0iS91UJpsruFY1Hjy98PTqEG4 -G1ANrZcUYs7RKIjKB5TUx70nJUkIfYjBVSRV/TrUhz+Fc0JkmJhljMa/i8X8LnEx -F5WmurPu96pEExtl4w9CSj/LnfIZ0IEqV39eHvMCf8m5TV3z91zlSvLLRnvajBvo -XHfhIivt5uNLqjL/cCA8shNXl3nctSSZcp1CfJABocKeF5I= ------END CERTIFICATE----- diff --git a/sample/initial-config/keystore/extra-key.key b/sample/initial-config/keystore/extra-key.key deleted file mode 100644 index 4139337..0000000 --- a/sample/initial-config/keystore/extra-key.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQI259pfAK40VwCAggA -MB0GCWCGSAFlAwQBAgQQ1N3YBP6dS3qRIBmsord4vgSCBNApgHCqfecEvW4UYwIm -IPLfFVMeKLSIsrih3auMumVoIAPIOGTxMbQoAayET2ZLwuX2hW4vFcT/xGuSASXN -bh7t4PDSTNllzV6Epj5Qk2qefOPwmG2o75LDGIbF+lfkZlKaMNmmxyWm5wceY4+W -wDIKFoQMURLH2/PaigjFmQem2XPacH6dnnmxITWjvq/cLuFGRgKi4M6Isj9cIBwM -PU/f/GGntF4lMJHp0bw7LNj80DSuCYi3iHnS+mqw1TXc4u2xTcWOmkefvHu3/vEq -htfSjOCeF3uy9sfLmO+AAzOaTxDKee1aI2/q9W49Y4cjBO5fcQ3kXMWUoFr2cz7v -OUMsySNj1PG0bOFFxxYKffu+LRvg7rqYCEB5LLUpt6doLUA1BSmytBXfsIXu3THK -ERY+dc26yzPuLE9BKs2B4nAzms0kqxyLc+NllOB1DERsbH4vJzIQ85xrHnHJTwoA -0vuA2dp4wFYtNlSASur73OTSKBBSVILywOjQctIoowsoHx6m1RDQL9CT5nngfI02 -J8lmxOv10UclLFKaist5Sc+NGAmcHPjH1IdSBIiGBgMnrumLCDZtgLfx0D5XBbKq -eJ+u8z6qafCwvQ9LE4ItT4ubK9qnTJWdrO0lb6IVcJYbDlw/7wpb5vG9DJjI4pd6 -rVuy4zjuuVY2wCPPvauNKlTeZ4J51qM35r4B93vCkHTq050dW4/+JR+iaoK99M0/ -WpS9JN3DZq0Dj92aRKPcjHQ1cUYdYCpqz1D5doliS6vWFHNnuDbxVWxe28qLyKm+ -xa5gb5k//OVla98YaLXwuYVsUaJvQVdikwx+Ri5B47mNsMydtgOAUZk+u7hK2HcX -gYB7Ub2HzfzhVcq8sK+nVrUkW6E89Op0mpexR/pIaqAkPNbtSNt9z1Th9M7Z/ugL -q/LQH/UceP1vvBops3GAJB43XbpPqnah4I6A2omrnOGJTIitFQl0unLeVewvJwFz -YzmdyQzavHWcHWRMHDt64HZaZ/nkCNr8uYwyxoOM7hwdaI3ioQuWtbKRH4Hku0rE -G/bvuTtz7Rxsy+pJ3wpJFsgpN9ga7f/shx8bU/A+S/gAel2wtyhoshUVmY9pjtFS -Cuq6KXxpa9+AF0Y7nAcSFUdmGmU25Rtz6Patq70YPk5sq5YmfM1yTrL/djY7itfi -wBZ+H2PSymOMLl9qIZlhuF95dtO4pI7TIwFDFO/UdH06EmplzdCNR9YwIZ7ho5Sm -cJ/gR2TIpSLGH3wU5XC1UnVzcWibiuL70R918ZPRLnbLN9/3BwnljL4CN73D3voS -ZZW0odChcOKcJRgBEwMcCRQpmBPpHoxpQiWEgp3/hF01lgWyEINkXOdy3sU8lDXL -rctd2tz8XsfvR6qIf2yVIoP68XdgvgWUPGBJo5LKCbuRWno+gz/Empb3I5FlkisC -/vrxcd19BM6Ik4b1ql4xv+WpkCL26W0Vdy8dSVvi6pEpABWdMjUbJJ5Jq8JwTxFC -jF6dOTG7dWiIhwJjInSvKGUXRWsFpKtKph8XWG+zZxr3Gt3ugUh0OsTfgl9hQalv -+wP+0IPxeZI9m5YJhbxehhqcoxm8oRZUr8lmNAgCuZ1B6WEm14HFhbkHeidOJoR0 -7q0nN48QJmB5qZU4ewh1GxnBSA== ------END ENCRYPTED PRIVATE KEY----- diff --git a/sample/initial-config/keystore/extra-key.pass b/sample/initial-config/keystore/extra-key.pass deleted file mode 100644 index 21c3f34..0000000 --- a/sample/initial-config/keystore/extra-key.pass +++ /dev/null @@ -1 +0,0 @@ -passrods diff --git a/sample/initial-config/keystore/mykey.crt b/sample/initial-config/keystore/mykey.crt deleted file mode 100644 index bc374d9..0000000 --- a/sample/initial-config/keystore/mykey.crt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDrDCCApQCCQDNRiR1q5bTpTANBgkqhkiG9w0BAQsFADCBlTELMAkGA1UEBhMC -R0IxEjAQBgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UE -CgwLSUJNIFVLIEx0ZC4xEDAOBgNVBAsMB0FDRSBJQ1AxFTATBgNVBAMMDFRlc3Qg -Um9vdCBDQTEhMB8GCSqGSIb3DQEJARYSdGVzdGVyQGV4YW1wbGUuY29tMB4XDTE4 -MTAzMDE2NTMxM1oXDTM4MTAzMDE2NTMxM1owgZkxCzAJBgNVBAYTAkdCMRIwEAYD -VQQIDAlIYW1wc2hpcmUxEDAOBgNVBAcMB0h1cnNsZXkxFDASBgNVBAoMC0lCTSBV -SyBMdGQuMQwwCgYDVQQLDANBQ0UxHTAbBgNVBAMMFG1hY2hpbmUxLmV4YW1wbGUu -Y29tMSEwHwYJKoZIhvcNAQkBFhJ0ZXN0ZXJAZXhhbXBsZS5jb20wggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDiAcYbiWT11r5abrC/NVPNCXKfLAXZ118t -igpA32UsBAJCwtWeipudbPQphW/mesZR8Aw1l4TqbDg5au59WF9PaLAf//Jeu/I6 -E9uE/8a+dOXZYHTNPs5E28Vnq89y/KdrB2+Woc71tadwOdsTYLBn4LbAVPK2/nhh -aoRWI//MIo+YhjDiftbiNh6t5B7JvxchQPKgCUDkHM3FXTsbFBZa8APYMnvPnCRs -shcCFQAhddE7Hj3E/DzNGo+J9B0/hrqSUY/InO3eHtv4m07F/XzHvZEcmr/z8Prw -90Npe80DRVU9NVQIl6z+ZfE56vv/l+bgkVhm3XtUEn6WtiYcbqCvAgMBAAEwDQYJ -KoZIhvcNAQELBQADggEBACPuF5la86PJ8+ffgcPhEJId72uEPCUL4PkcDV+8ipOU -Y8WwM/CSfmPVF19lDlQm863uWWkWVyzJhAyfNToQqtO3R+bpRqQKD0+3mwkRmCo/ -csyfRC3LLVWg0XKEaf+nrt1//VOj4yuCRhThMo8JbThV8ROpDq1ePtgQqxMojKNW -XrTSxSkInhAv023Yhq4XchZwwznC4kQVfSNbabgZMkI94C/g+E/h5PjUFRFG8ac/ -EFC/4DpkQUFmCASBpRx/nTYfV1lVQLIwP7Uyv6+PcjmoM2eGmgUTH2kNAZdi8uNB -ElKbk1bfIb9UXywxYXyCHQXmkqYJhPNN+qjTuDs1WDA= ------END CERTIFICATE----- diff --git a/sample/initial-config/keystore/mykey.key b/sample/initial-config/keystore/mykey.key deleted file mode 100644 index e40e6d0..0000000 --- a/sample/initial-config/keystore/mykey.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQI0jhb33E2+FACAggA -MB0GCWCGSAFlAwQBAgQQ0xVmu+JzxIO6ZG6JJ5Q2PgSCBNDXPo0GUvARv44TGMaF -DfHu1k/CYV8+5cA2vp2W90qRPfROG1jGgfIb0KMWgPLmSRVJMvdg/rxkBJVMKYzi -Y3VHuO3pdx06uWyG1ay8Ki8KDj2eg/mBidlmcdG1GtKtUGkVePX74CGlIFDStG+U -a/k5E4sfpoDBtXQ39gqF9TMu3LrC8Ze4LvkEyXuvJwqQZlJbdelG4Z2TSBewJiSL -VDM7yJ+iuZZyafzWhRXc3vUMnbP3pQYn39e86VmBks9ibrBa0uwvVZTs1lkGa1TA -Uu037oER28NG5AtmurGlQfSEUxfXCobXOwlCk4Di7kPMy2F3S/RbzvObrr6TM8p/ -X64nVua4lEOTy1ntfmcEoMMgTWpCiSQmU8pPykC1BwjI6CqU+riChkOvJMs9L1c4 -v6anAvawtmBV9gSfeWhPOtZGuVXDlTmo/DUWDFIEMZes2srs3y5Yhb9dhQqqZzQT -1b+bHpXnb0CE7E/sFLck/IKU2f4KfIEqsEuXFCMnK1Q9A3mdN+lW6+qhsFXcIShQ -6a9ESjTijUFilZWWotf8QLyCfk7dIlE6WaL1j8aTIspcqGnNlMh5XMPrlEOWAK1z -+yJRrICfZd5D8bgTEHL2klbULQ+w+FEU80rFap9HsVfuhl+7S3m2wWMXLcSVu0QU -qPyUTGfbGDZwnS8wkCend3eZIiIYgunFTYp0uY0Dk8ruyeEfn1bTESEnb8lvzrhe -Kq4Bdn72F2hqGcTIvNXg0Xl4OEYFVKoV7GC/0QxPmbXcJT/SaNeHhjFQZRcxu1Cc -rFvpBKf+YCF6ru9TiBaScAEMBjFhJOE1LAHVVlrN2BTLXeH2E6nbXBAHlXu5vGGr -iE3ngp7t6OgOLLreUGrkPllH2Gw1aLOSSHjuxgj8NCV4HijPx19ncap40Kut6hcb -O9+GoEokHAXGjYbJ342QY9x8SLnFLLITlL0ZgWLgPlv8fsdWnWvdDdH0jlrK/Uz+ -7kGmWSap1tNUlpGzc96Q9t21GmPas6NRbfupSm7ptM1L+VFyr7yzwKP4GRHK66Oo -FgIdHoFFMw4/8yXGIl2t/ltnkMOm0Usn4AK2XNyAsNYvzwrpTz3By7gBiDOo0lFL -tBDmoDBRICpSjQvjMFRjd/2Akc44kcoLlXp18hyi7oqH09jcB8Fskeu8aIsVPSoH -1V0nMgtNq7WIr9Kq3vGyZuSpGWG08bEczg/PaoAWpgnxPA2VUQgx8N7DLGqm7rOt -QhpWqnKB2CkjlLIdO2cJ2zNqATr9Z8iMQ7xRvvosuOEWqRnu3pQhTsndMh1NxE2s -0nL4npJfNkvRYo/AlCeikxdX1ylz8Pxe/4nxatBfRBxXw2Ol2wjr21oIsYrOF7uy -jR5GFEc43b7NKlSbht4upAlzSooOGme09fIFtwORLnIxxZoRv0uYujaOiIz2COWU -RKxU23lqw90EMDLzg/G9EJFMX2tFIbphJJIDf2SIOgmiIpefHvpi0uRt5ssZ7fco -rvuLveQE72THH53RTpKA6xz4PqZmOf4zG7gWGx76rb8sBbL/GwF07JzcYh5yIq21 -kwozZroxCLJSka72oABx6+HcjGS0am3+CBuSqdpc5P1X1DoCfZvIo+9k5kcGdFRC -i46A38SrjFgEJjKkL2aQ8vXsKQ== ------END ENCRYPTED PRIVATE KEY----- diff --git a/sample/initial-config/keystore/mykey.pass b/sample/initial-config/keystore/mykey.pass deleted file mode 100644 index 21c3f34..0000000 --- a/sample/initial-config/keystore/mykey.pass +++ /dev/null @@ -1 +0,0 @@ -passrods diff --git a/sample/initial-config/mqsc/config.mqsc b/sample/initial-config/mqsc/config.mqsc deleted file mode 100644 index 997f055..0000000 --- a/sample/initial-config/mqsc/config.mqsc +++ /dev/null @@ -1 +0,0 @@ -DEFINE QLOCAL('test') \ No newline at end of file diff --git a/sample/initial-config/odbcini/odbc.ini b/sample/initial-config/odbcini/odbc.ini deleted file mode 100644 index 3befcc7..0000000 --- a/sample/initial-config/odbcini/odbc.ini +++ /dev/null @@ -1,40 +0,0 @@ -;####################################### -;#### List of data sources stanza ###### -;####################################### - -[ODBC Data Sources] -ORACLEDB=DataDirect ODBC Oracle Wire Protocol - -;########################################### -;###### Individual data source stanzas ##### -;########################################### - -;# Oracle stanza -[ORACLEDB] -Driver=/opt/ibm/ace-12/server/ODBC/drivers/lib/UKora95.so -Description=DataDirect ODBC Oracle Wire Protocol -HostName=OracleServerMachineName -PortNumber=1521 -ServiceName=OracleServiceName -CatalogOptions=0 -EnableStaticCursorsForLongData=0 -ApplicationUsingThreads=1 -EnableDescribeParam=1 -OptimizePrepare=1 -WorkArounds=536870912 -ProcedureRetResults=1 -ColumnSizeAsCharacter=1 -LoginTimeout=0 -EnableNcharSupport=0 -;# Uncomment the next setting if you wish to use Oracle TIMESTAMP WITH TIMEZONE columns -;# EnableTimestampwithTimezone=1 - -;########################################## -;###### Mandatory information stanza ###### -;########################################## - -[ODBC] -InstallDir=/opt/ibm/ace-12/server/ODBC/drivers -UseCursorLib=0 -IANAAppCodePage=4 -UNICODE=UTF-8 diff --git a/sample/initial-config/policy/default.policyxml b/sample/initial-config/policy/default.policyxml deleted file mode 100644 index bf4a1f9..0000000 --- a/sample/initial-config/policy/default.policyxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - 7843 - 0.0.0.0 - -1 - 100 - 200 - 1000 - 100 - false - * - false - Content-Type - -1 - GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS - Accept,Accept-Language,Content-Language,Content-Type - !RC4+RSA:HIGH:+MEDIUM:+LOW - false - 300 - 100 - mykey - - /home/aceuser/ace-server/keystore.jks - keystorepwd - /home/aceuser/ace-server/truststore.jks - truststorepwd - - diff --git a/sample/initial-config/policy/policy.descriptor b/sample/initial-config/policy/policy.descriptor deleted file mode 100644 index bdfa6f2..0000000 --- a/sample/initial-config/policy/policy.descriptor +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/sample/initial-config/serverconf/server.conf.yaml b/sample/initial-config/serverconf/server.conf.yaml deleted file mode 100644 index 67e64f0..0000000 --- a/sample/initial-config/serverconf/server.conf.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -ResourceManagers: - JVM: - truststoreType: 'JKS' - truststoreFile: '/home/aceuser/ace-server/truststore.jks' - truststorePass: 'setdbparms::truststore' - -# Defaults: -# Policies: -# HTTPSConnector: 'HTTPS' - -Defaults: - defaultApplication: '' # Name a default application under which independent resources will be placed - policyProject: 'DefaultPolicies' # Name of the Policy project that will be used for unqualified Policy references - Policies: - # Set default policy names, optionally qualified with a policy project as {policy project}:name - HTTPSConnector: 'HTTPS' # Default HTTPS connector policy diff --git a/sample/initial-config/setdbparms/setdbparms.txt b/sample/initial-config/setdbparms/setdbparms.txt deleted file mode 100644 index 39b3c54..0000000 --- a/sample/initial-config/setdbparms/setdbparms.txt +++ /dev/null @@ -1,3 +0,0 @@ -# resource user password -setdbparms::truststore "my username" truststorepwd -mqsisetdbparms -w /home/aceuser/ace-server -n salesforce::SecurityIdentity -u "my username" -p myPassword -c myClientID -s myClientSecret \ No newline at end of file diff --git a/sample/initial-config/truststore/cacert.crt b/sample/initial-config/truststore/cacert.crt deleted file mode 100644 index 697eb58..0000000 --- a/sample/initial-config/truststore/cacert.crt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDqDCCApACCQC/RYKb+/vOrjANBgkqhkiG9w0BAQsFADCBlTELMAkGA1UEBhMC -R0IxEjAQBgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UE -CgwLSUJNIFVLIEx0ZC4xEDAOBgNVBAsMB0FDRSBJQ1AxFTATBgNVBAMMDFRlc3Qg -Um9vdCBDQTEhMB8GCSqGSIb3DQEJARYSdGVzdGVyQGV4YW1wbGUuY29tMB4XDTE4 -MTAzMDE2NTE0NloXDTM4MTAzMDE2NTE0NlowgZUxCzAJBgNVBAYTAkdCMRIwEAYD -VQQIDAlIYW1wc2hpcmUxEDAOBgNVBAcMB0h1cnNsZXkxFDASBgNVBAoMC0lCTSBV -SyBMdGQuMRAwDgYDVQQLDAdBQ0UgSUNQMRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0Ex -ITAfBgkqhkiG9w0BCQEWEnRlc3RlckBleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBAPbdh9B8KJVou0IisgISqDVFjlAQmpsdcKQi9P1s -9DzGIuDghEwb21v/JW25U4+xJ4CULjVx+moHXLapP4tNpBTE2x8p4qEuOJROA3xr -m99nW6UnOEnM4stjdlt14ihKxiiu1DvGluBsnz3P9BSNmLCLhxcSgPpRUUqstiiK -hca1HxZQUF5EdijhzXA/R/afVNM/TftDBDuIw61rNlxIp/33STPZ0nUWY0lubQ8J -sLpDX73jKx5itpJ2gi99uR1KLrOwTWYEr/mGXFqyZjHkHEiE5+nIPd0q9+1f4Vh4 -H2fTLrpAJkrIAZ6sRNrIaxlEtAHqJkMm36PHzO7JY4/lyaMCAwEAATANBgkqhkiG -9w0BAQsFAAOCAQEAX/0szi4ObvIUAuZwu2Lb7H0rNZZ8r0HsJ4NuaQ11VpeyBsx/ -MSW2JepdA34xM7dfvc9ef7hoC8xHGt/PKUu+pNoum/XuLTnWoulch8rg0IqqPX6S -/xjbi6laAhr0xn3uepp8NBLbzjHRdvAmmhkgUphKrPSGOG0ThrRJQGjk3dW6KEQl -NPT1kA5GaM1/4oxslO6VYACnj+CUwb6RsksEsKjh9CM0UbSr1gvzzqC/xmNIJTpU -T9ADO5QBrAjpmGvnTNkM+iBLUDsKLkREmn+1epdkKx8lnOq7AvPlJpVvwAQU94Dh -+zyKzULDHnExNSikkAKtJHYY7MIaP0/Lyuf2+Q== ------END CERTIFICATE----- diff --git a/sample/initial-config/truststore/extra-cert.crt b/sample/initial-config/truststore/extra-cert.crt deleted file mode 100644 index f4a4749..0000000 --- a/sample/initial-config/truststore/extra-cert.crt +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDrDCCApQCCQCNcazfuU39uTANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UEBhMC -R0IxEjAQBgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UE -CgwLSUJNIFVLIEx0ZC4xEDAOBgNVBAsMB0FDRSBJQ1AxFjAUBgNVBAMMDVRlc3Qg -Um9vdCBDQTIxIjAgBgkqhkiG9w0BCQEWE3Rlc3RlcjJAZXhhbXBsZS5jb20wHhcN -MTgxMDMwMTcwNzEzWhcNMzgxMDMwMTcwNzEzWjCBlzELMAkGA1UEBhMCR0IxEjAQ -BgNVBAgMCUhhbXBzaGlyZTEQMA4GA1UEBwwHSHVyc2xleTEUMBIGA1UECgwLSUJN -IFVLIEx0ZC4xEDAOBgNVBAsMB0FDRSBJQ1AxFjAUBgNVBAMMDVRlc3QgUm9vdCBD -QTIxIjAgBgkqhkiG9w0BCQEWE3Rlc3RlcjJAZXhhbXBsZS5jb20wggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVUJRklaHFtUTFsfoUa7PoQolOzgKqtP0J -Mg1x9RUWUjVGClz0b19ak4Uk7+U6tczUWfy5MZw9hJp3mI96yJXsvwAkaSlVlCIk -Auz7VvrkHwj9o+4+C8IuFItU/W5ARtj9VLng/cEP6i7S7PbJ33AUL19PgCrK1Zpt -rSioTdZdy5yd2MZPGdaT6R9b+We9F7yF6VK0zB4U5fJOeiNpVPOfa8BIEOzYI2WG -/i7iEMjK92d2Ktb/9ZFyVYMs7TCNWavRAjATz6CFCkBxSa/Ly2JMskD4AFVUuYBI -GDY6q1OhOaHwsVO/nA8pDmTYZrdPjSjzMBbMHhSegOiJewm6whEbAgMBAAEwDQYJ -KoZIhvcNAQELBQADggEBAH4l6dQgMW/mu7YwwVy4ZCgY9VpJ8cSePxV5kS+L6oz6 -vhkKD9TEQ/X7fXSnL0BbgCG/YhzLg+7No0dRHMmEh4typSZjc5KrcV5ExHzWDd0B -V/zGetFTuqtE43I93isPP0b8nPhfcrQcfVIRLN1EvT8engI68pq2PoOz7HPo+YT7 -wp+0vTaUw6q7I5+ZXjEnykoytO7gExXnY/z4al2ey6VVyrGiFjz62Q+tQFNshmgR -F6Y50d+SvM3+RPe/oA8GqJWAhcn6oU7Jn3+snmCMGYH0nylSo8fvz86bbxqGMVJR -zIOCUiypnnyNsutqqUVVHb0E10TDBkSHD4VQCZ7TUKA= ------END CERTIFICATE----- diff --git a/sample/initial-config/webusers/admin-users.txt b/sample/initial-config/webusers/admin-users.txt deleted file mode 100644 index 77dd8fe..0000000 --- a/sample/initial-config/webusers/admin-users.txt +++ /dev/null @@ -1,2 +0,0 @@ -admin1 passwd1 -admin2 passwd2 diff --git a/sample/initial-config/webusers/viewer-users.txt b/sample/initial-config/webusers/viewer-users.txt deleted file mode 100644 index 42b294d..0000000 --- a/sample/initial-config/webusers/viewer-users.txt +++ /dev/null @@ -1,2 +0,0 @@ -viewer1 passwd1 -viewer2 passwd2 diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000..8532151 --- /dev/null +++ b/samples/README.md @@ -0,0 +1,9 @@ +# Samples + +The samples folder contains Dockerfiles that build a sample image containing sample applications. + +* [Update base package sample](updateBase/README.md) - This sample applies updates all the base OS packages. This can be used to resolve CVEs in the base packages +* [iFix sample](applyIfix/README.md) - This sample applies an iFix provided by IBM to an existing image. +* [Bar sample](bars/README.md) - This sample adds some bar files to an existing image. +* [Scripts sample](scripts/README.md) - This sample adds scripts which are run on startup. + diff --git a/samples/applyIfix/Dockerfile b/samples/applyIfix/Dockerfile new file mode 100644 index 0000000..5cce8a3 --- /dev/null +++ b/samples/applyIfix/Dockerfile @@ -0,0 +1,14 @@ +ARG FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 +ARG IFIX +FROM ${FROMIMAGE} + +ADD ifix/.tar.gz /home/aceuser/ifix + +USER root + +RUN cd /home/aceuser/ifix \ + && ./mqsifixinst.sh /opt/ibm/ace-12 install \ + && cd /home/aceuser \ + && rm -rf /home/aceuser/fix + +USER 1001 diff --git a/samples/applyIfix/README.md b/samples/applyIfix/README.md new file mode 100644 index 0000000..e886a6f --- /dev/null +++ b/samples/applyIfix/README.md @@ -0,0 +1,17 @@ + +# iFix Sample + +## What is in the sample? + +This sample applies an iFix provided by IBM to an existing image. + +## Building the sample + +- First [build the ACE image](../README.md#Building-a-container-image) or obtain one of the shipped images +- Download the appropriate iFix provided by IBM and place it into the fix directory +- Update the dockerfile to reference the iFix i.e. replace \ with the name of the ifix you've downloaded i.e. 12.0.3.0-ACE-LinuxX64-TFIT39515A +- In the `sample/scripts/applyIfix` folder: + + ```bash + docker build -t aceapp --build-arg FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 --file Dockerfile . + ``` diff --git a/samples/applyIfix/ifix/.gitignore b/samples/applyIfix/ifix/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/samples/applyIfix/ifix/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/samples/bars/CustomerDatabaseV1.bar b/samples/bars/CustomerDatabaseV1.bar new file mode 100644 index 0000000..29f07cb Binary files /dev/null and b/samples/bars/CustomerDatabaseV1.bar differ diff --git a/samples/bars/Dockerfile b/samples/bars/Dockerfile new file mode 100644 index 0000000..5bb1a24 --- /dev/null +++ b/samples/bars/Dockerfile @@ -0,0 +1,12 @@ +ARG FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 +FROM ${FROMIMAGE} + +USER root + +COPY *.bar /tmp +RUN export LICENSE=accept \ + && . /opt/ibm/ace-12/server/bin/mqsiprofile \ + && set -x && for FILE in /tmp/*.bar; do ibmint deploy --input-bar-file "$FILE" --output-work-directory /home/aceuser/ace-server/ 2>&1 > /tmp/deploys; done \ + && chmod -R ugo+rwx /home/aceuser/ + +USER 1001 \ No newline at end of file diff --git a/samples/bars/README.md b/samples/bars/README.md new file mode 100644 index 0000000..692ddca --- /dev/null +++ b/samples/bars/README.md @@ -0,0 +1,34 @@ + +# Bars Sample + +## What is in the sample? + +- **bars_aceonly** contains a BAR for sample applications that don't need MQ. These will be copied into the image (at build time) to `/home/aceuser/bars` and compiled. The Integration Server will pick up and deploy this files on start up. These set of BAR files will be copied when building an image with ACE only or ACE & MQ. + +## Building the sample + +First [build the ACE image](../README.md#Building-a-container-image) or obtain one of the shipped images + +In the `sample/bars` folder: + +```bash +docker build -t aceapp --build-arg FROMIMAGE=ace:12.0.4.0-r1 --file Dockerfile . +``` + +## Running the sample + +The sample application is a copy of one of the ACE samples called CustomerDB. This provides a RestAPI which can be queries which will return information about customers. + +To run the application launch the container using a command such as: + +```bash +`docker run -d -p 7600:7600 -p 7800:7800 -e LICENSE=accept aceapp` +``` + +To exercise the flow run a command such as: + +```bash +curl --request GET \ + --url 'http://96fa448ea76e:7800/customerdb/v1/customers?max=REPLACE_THIS_VALUE' \ + --header 'accept: application/json' +``` diff --git a/samples/bars/test.sh b/samples/bars/test.sh new file mode 100755 index 0000000..947e9b8 --- /dev/null +++ b/samples/bars/test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +docker ps | grep -q ace +i=0 + +while ! docker logs ace | grep -q "Integration server has finished initialization"; +do + if [ $i -gt 30 ]; + then + echo "Failed to start - logs:" + docker logs ace + exit 1 + fi + sleep 1 + echo "waited $i secods for startup to complete...continue waiting" + ((i=i+1)) +done +echo "Integration Server started" +echo "Sending test request" +status_code=$(curl --write-out %{http_code} --silent --output /dev/null --request GET --url 'http://localhost:7800/customerdb/v1/customers?max=1' --header 'accept: application/json') +if [[ "$status_code" -ne 200 ]] ; then + echo "IS failed to respond with 200, it responded with $status_code" +fi +echo "Successfuly send test request" diff --git a/samples/scripts/Dockerfile b/samples/scripts/Dockerfile new file mode 100644 index 0000000..d3e6f7b --- /dev/null +++ b/samples/scripts/Dockerfile @@ -0,0 +1,16 @@ +ARG FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 +FROM ${FROMIMAGE} + +USER root + +# Required for the setdbparms script to run +RUN microdnf update && microdnf install python3 && microdnf clean all \ + && ln -s /usr/bin/python3 /usr/local/bin/python + +COPY server.conf.yaml /home/aceuser/ace-server/ + +RUN mkdir -p /home/aceuser/initial-config/setdbparms/ +COPY ace_config_* /home/aceuser/initial-config/ +RUN chmod -R ugo+rwx /home/aceuser/ + +USER 1001 \ No newline at end of file diff --git a/samples/scripts/README.md b/samples/scripts/README.md new file mode 100644 index 0000000..ca496b1 --- /dev/null +++ b/samples/scripts/README.md @@ -0,0 +1,26 @@ + +# Scripts Sample + +## What is in the sample? + +This sample includes copying in a script which should run before the IntegrationServer starts up. These scripts are used to process a mounted file which contains some credentials. + +## Building the sample + +First [build the ACE image](../README.md#Building-a-container-image) or obtain one of the shipped images + +In the `sample/scripts` folder: + +```bash +docker build -t aceapp --build-arg FROMIMAGE=ace:12.0.4.0-r1 --file Dockerfile . +``` + +## Running the sample + +To run the application launch the container using a command such as: + +```bash +`docker run --name aceapp -d -p 7600:7600 -p 7800:7800 -v /setdbparms:/home/aceuser/initial-config/setdbparms -e LICENSE=accept aceapp` +``` + +On startup the logs will show that the configured scripts are run before starting the integration server. These credentials can then be used by flows referencing the appropriate resource diff --git a/ace_config_logging.sh b/samples/scripts/ace_config_logging.sh similarity index 58% rename from ace_config_logging.sh rename to samples/scripts/ace_config_logging.sh index ba390af..5f1577e 100755 --- a/ace_config_logging.sh +++ b/samples/scripts/ace_config_logging.sh @@ -7,25 +7,10 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v20.html -if [ -z "${ACE_SERVER_NAME}" ]; then - export ACE_SERVER_NAME=$(hostname | sed -e 's/[^a-zA-Z0-9._%/]//g') -fi - log() { MSG=$1 TIMESTAMP=$(date +%Y-%m-%dT%H:%M:%S.%3NZ%:z) - - if [ "${LOG_FORMAT}" == "json" ]; then - HOST=$(hostname) - PID=$$ - PROCESSNAME=$(basename $0) - USERNAME=$(id -un) - ESCAPEDMSG=$(echo $MSG | sed -e 's/[\"]/\\&/g') - # TODO: loglevel - echo "{\"host\":\"${HOST}\",\"ibm_datetime\":\"${TIMESTAMP}\",\"ibm_processId\":\"${PID}\",\"ibm_processName\":\"${PROCESSNAME}\",\"ibm_serverName\":\"${ACE_SERVER_NAME}\",\"ibm_userName\":\"${USERNAME}\",\"message\":\"${ESCAPEDMSG}\",\"ibm_type\":\"ace_containerlog\"}" - else - echo "${TIMESTAMP} ${MSG}" - fi + echo "${TIMESTAMP} ${MSG}" } # logAndExitIfError - if the return code given is 0 and the command outputed text, log it to stdout diff --git a/ace_config_setdbparms.sh b/samples/scripts/ace_config_setdbparms.sh similarity index 54% rename from ace_config_setdbparms.sh rename to samples/scripts/ace_config_setdbparms.sh index 0c40dda..6bb3217 100755 --- a/ace_config_setdbparms.sh +++ b/samples/scripts/ace_config_setdbparms.sh @@ -7,6 +7,21 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v20.html +function argStrings { + shlex() { + python -c $'import sys, shlex\nfor arg in shlex.split(sys.stdin):\n\tsys.stdout.write(arg)\n\tsys.stdout.write(\"\\0\")' + } + args=() + while IFS='' read -r -d ''; do + args+=( "$REPLY" ) + done < <(shlex <<<$1) + + log "${args[0]}" + log "${args[1]}" + log "${args[2]}" + +} + if [ -z "$MQSI_VERSION" ]; then source /opt/ibm/ace-12/server/bin/mqsiprofile fi @@ -26,17 +41,19 @@ if [ -s "/home/aceuser/initial-config/setdbparms/setdbparms.txt" ]; then continue fi IFS=${OLDIFS} - if [[ $line == mqsisetdbparms* ]]; then + if [[ $line == mqsisetdbparms* ]]; then log "Running suppplied mqsisetdbparms command" OUTPUT=`eval "$line"` else - - printf "%s" "$line" | xargs -n 1 printf "%s\n" > /tmp/creds - IFS=$'\n' read -d '' -r -a lines < /tmp/creds - - - log "Setting user and password for resource: ${lines[0]}" - cmd="mqsisetdbparms -w /home/aceuser/ace-server -n \"${lines[0]}\" -u \"${lines[1]}\" -p \"${lines[2]}\" 2>&1" + shlex() { + python -c $'import sys, shlex\nfor arg in shlex.split(sys.stdin):\n\tsys.stdout.write(arg)\n\tsys.stdout.write(\"\\0\")' + } + args=() + while IFS='' read -r -d ''; do + args+=( "$REPLY" ) + done < <(shlex <<<$line) + log "Setting user and password for resource: ${args[0]}" + cmd="mqsisetdbparms -w /home/aceuser/ace-server -n \"${args[0]}\" -u \"${args[1]}\" -p \"${args[2]}\" 2>&1" OUTPUT=`eval "$cmd"` echo $OUTPUT fi @@ -44,4 +61,4 @@ if [ -s "/home/aceuser/initial-config/setdbparms/setdbparms.txt" ]; then done fi -log "setdbparms configuration complete" +log "setdbparms configuration complete" \ No newline at end of file diff --git a/samples/scripts/server.conf.yaml b/samples/scripts/server.conf.yaml new file mode 100644 index 0000000..e5c1172 --- /dev/null +++ b/samples/scripts/server.conf.yaml @@ -0,0 +1,3 @@ +StartupScripts: + SetDBParms: + command: '/home/aceuser/initial-config/ace_config_setdbparms.sh' diff --git a/samples/scripts/setdbparms/setdbparms.txt b/samples/scripts/setdbparms/setdbparms.txt new file mode 100644 index 0000000..f833b10 --- /dev/null +++ b/samples/scripts/setdbparms/setdbparms.txt @@ -0,0 +1,6 @@ +# Lines starting with a "#" are ignored +# Each line which starts mqsisetdbparms will be run as written +# Alternatively each line should specify the , separated by a single space +# Each line will be processed by calling... +# mqsisetdbparms ${ACE_SERVER_NAME} -n -u -p +resource1 user1 password1 \ No newline at end of file diff --git a/samples/updateBase/Dockerfile b/samples/updateBase/Dockerfile new file mode 100644 index 0000000..7bcca1b --- /dev/null +++ b/samples/updateBase/Dockerfile @@ -0,0 +1,8 @@ +ARG FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 +FROM ${FROMIMAGE} + +USER root + +RUN RUN microdnf update && microdnf clean all + +USER 1001 \ No newline at end of file diff --git a/samples/updateBase/README.md b/samples/updateBase/README.md new file mode 100644 index 0000000..9354e5a --- /dev/null +++ b/samples/updateBase/README.md @@ -0,0 +1,14 @@ +# updateBase Sample + +## What is in the sample? + +This sample applies updates all the base OS packages. This can be used to resolve CVEs in the base packages + +## Building the sample + +- First [build the ACE image](../README.md#Building-a-container-image) or obtain one of the shipped images +- In the `sample/scripts/updateBase` folder: + + ```bash + docker build -t aceapp --build-arg FROMIMAGE=cp.icr.io/cp/appc/ace:12.0.4.0-r1 --file Dockerfile . + ``` diff --git a/test-and-coverage.sh b/test-and-coverage.sh deleted file mode 100755 index d07730d..0000000 --- a/test-and-coverage.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -e - -# Array of packages at 100% test coverage - Once a package has been fully covered it will be added to this list -COVERED_PACKAGES=('webadmin') -TEST_OUTPUT=$(go test $(go list ./... | grep -v /test/) -covermode=atomic -coverprofile cover.out) -COVERAGE_REGRESSION=false - -for i in ${COVERED_PACKAGES[@]}; do - COV=$(echo "$TEST_OUTPUT" | grep "$i" | awk '{ print $5 }') - if [[ "$COV" != "100.0%" ]]; then - echo "$i is not at 100% test coverage." - COVERAGE_REGRESSION=true - fi -done - -if [[ $COVERAGE_REGRESSION == true ]]; then - echo "Please address the coverage regression." - exit 1 -fi - - -# This is the current expected code coverage -CURRENT_COVERAGE=58.1 -LATEST=$(go tool cover -func cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}') -echo "Latest coverage: $LATEST" -echo "Expected Coverage: $CURRENT_COVERAGE" -result=$(echo "$LATEST >= $CURRENT_COVERAGE" | bc -l) -if [ $result -gt 0 ]; then - echo "PASSED - Coverage Check" -else - echo "Failed to meet required coverage value: $CURRENT_COVERAGE" - exit 1 - -fi -if [ "$LATEST" != "$CURRENT_COVERAGE" ]; then - echo "\nFAILED - You must update the CURRENT_COVERAGE in travis to match the new benchmark: $LATEST" - exit 1 -fi diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..947e9b8 --- /dev/null +++ b/test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +docker ps | grep -q ace +i=0 + +while ! docker logs ace | grep -q "Integration server has finished initialization"; +do + if [ $i -gt 30 ]; + then + echo "Failed to start - logs:" + docker logs ace + exit 1 + fi + sleep 1 + echo "waited $i secods for startup to complete...continue waiting" + ((i=i+1)) +done +echo "Integration Server started" +echo "Sending test request" +status_code=$(curl --write-out %{http_code} --silent --output /dev/null --request GET --url 'http://localhost:7800/customerdb/v1/customers?max=1' --header 'accept: application/json') +if [[ "$status_code" -ne 200 ]] ; then + echo "IS failed to respond with 200, it responded with $status_code" +fi +echo "Successfuly send test request" diff --git a/ubi/Dockerfile-legacy.aceonly b/ubi/Dockerfile-legacy.aceonly deleted file mode 100644 index 4648f0f..0000000 --- a/ubi/Dockerfile-legacy.aceonly +++ /dev/null @@ -1,113 +0,0 @@ -FROM golang:latest as builder - -WORKDIR /go/src/github.com/ot4i/ace-docker/ - -COPY go.mod . -COPY go.sum . -RUN go mod download - -COPY cmd/ ./cmd -COPY internal/ ./internal -COPY common/ ./common -RUN go version -RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\"" ./cmd/runaceserver/ -RUN go build ./cmd/chkaceready/ -RUN go build ./cmd/chkacehealthy/ - -# Run all unit tests -RUN go test -v ./cmd/runaceserver/ -RUN go test -v ./internal/... -RUN go test -v ./common/... -RUN go vet ./cmd/... ./internal/... ./common/... - -ARG ACE_INSTALL=ace-12.0.1.0.tar.gz -ARG IFIX_LIST="" -WORKDIR /opt/ibm -COPY deps/$ACE_INSTALL . -COPY ./ApplyIFixes.sh /opt/ibm -RUN mkdir ace-12 -RUN tar -xzf $ACE_INSTALL --absolute-names --exclude ace-12.\*/tools --exclude ace-12.\*/server/bin/TADataCollector.sh --exclude ace-12.\*/server/transformationAdvisor/ta-plugin-ace.jar --strip-components 1 --directory /opt/ibm/ace-12 \ - && ./ApplyIFixes.sh $IFIX_LIST \ - && rm ./ApplyIFixes.sh - -FROM registry.access.redhat.com/ubi8/ubi-minimal - -ENV SUMMARY="Integration Server for App Connect Enterprise" \ - DESCRIPTION="Integration Server for App Connect Enterprise" \ - PRODNAME="AppConnectEnterprise" \ - COMPNAME="IntegrationServer" - -LABEL summary="$SUMMARY" \ - description="$DESCRIPTION" \ - io.k8s.description="$DESCRIPTION" \ - io.k8s.display-name="Integration Server for App Connect Enterprise" \ - io.openshift.tags="$PRODNAME,$COMPNAME" \ - com.redhat.component="$PRODNAME-$COMPNAME" \ - name="$PRODNAME/$COMPNAME" \ - vendor="IBM" \ - version="REPLACE_VERSION" \ - release="REPLACE_RELEASE" \ - license="IBM" \ - maintainer="Hybrid Integration Platform Cloud" \ - io.openshift.expose-services="" \ - usage="" - -# Add required license as text file in Liceses directory (GPL, MIT, APACHE, Partner End User Agreement, etc) -COPY /licenses/ /licenses/ - -RUN microdnf update && microdnf install findutils util-linux unzip python39 tar procps openssl && microdnf clean all \ - && ln -s /usr/bin/python3 /usr/local/bin/python \ - && mkdir /etc/ACEOpenTracing /opt/ACEOpenTracing /var/log/ACEOpenTracing && chmod 777 /var/log/ACEOpenTracing /etc/ACEOpenTracing - -# Force reinstall tzdata package to get zoneinfo files -RUN microdnf reinstall tzdata -y - -# Create OpenTracing directories, update permissions and copy in any library or configuration files needed -COPY deps/OpenTracing/library/* ./opt/ACEOpenTracing/ -COPY deps/OpenTracing/config/* ./etc/ACEOpenTracing/ - -WORKDIR /opt/ibm - -COPY --from=builder /opt/ibm/ace-12 /opt/ibm/ace-12 - -# Copy in PID1 process -COPY --from=builder /go/src/github.com/ot4i/ace-docker/runaceserver /usr/local/bin/ -COPY --from=builder /go/src/github.com/ot4i/ace-docker/chkace* /usr/local/bin/ - -# Copy in script files -COPY *.sh /usr/local/bin/ - -COPY ubi/generic_invalid/invalid_license.msgflow /home/aceuser/temp/gen -COPY ubi/generic_invalid/InvalidLicenseJava.jar /home/aceuser/temp/gen -COPY ubi/generic_invalid/application.descriptor /home/aceuser/temp - -# Create a user to run as, create the ace workdir, and chmod script files -RUN /opt/ibm/ace-12/ace make registry global accept license silently \ - && useradd -u 1000 -d /home/aceuser -G mqbrkrs,wheel aceuser \ - && mkdir -p /var/mqsi \ - && mkdir -p /home/aceuser/initial-config \ - && su - -c '. /opt/ibm/ace-12/server/bin/mqsiprofile && mqsicreateworkdir /home/aceuser/ace-server' \ - && chmod -R 777 /home/aceuser \ - && chmod -R 777 /var/mqsi \ - && su - -c '. /opt/ibm/ace-12/server/bin/mqsiprofile && echo $MQSI_JREPATH && chmod g+w $MQSI_JREPATH/lib/security/cacerts' \ - && chmod -R 777 /home/aceuser/temp \ - && chmod 777 /opt/ibm/ace-12/server/ODBC/dsdriver/odbc_cli/clidriver/license - -COPY git.commit /home/aceuser/ - -# Set BASH_ENV to source mqsiprofile when using docker exec bash -c -ENV BASH_ENV=/usr/local/bin/ace_env.sh - -# Expose ports. 7600, 7800, 7843 for ACE; 9483 for ACE metrics -EXPOSE 7600 7800 7843 9483 - -WORKDIR /home/aceuser - -ENV LOG_FORMAT=basic - -# Set user to prevent container running as root by default -USER 1000 - -# Set entrypoint to run management script - -ENTRYPOINT ["runaceserver"] diff --git a/ubi/Dockerfile.aceonly b/ubi/Dockerfile.aceonly deleted file mode 100644 index aa57586..0000000 --- a/ubi/Dockerfile.aceonly +++ /dev/null @@ -1,119 +0,0 @@ -FROM golang:latest as builder - -WORKDIR /go/src/github.com/ot4i/ace-docker/ - -COPY go.mod . -COPY go.sum . -RUN go mod download - -COPY cmd/ ./cmd -COPY internal/ ./internal -COPY common/ ./common -RUN go version -RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\"" ./cmd/runaceserver/ -RUN go build ./cmd/chkaceready/ -RUN go build ./cmd/chkacehealthy/ - -# Run all unit tests -RUN go test -v ./cmd/runaceserver/ -RUN go test -v ./internal/... -RUN go test -v ./common/... -RUN go vet ./cmd/... ./internal/... ./common/... - -ARG ACE_INSTALL=ace-12.0.1.0.tar.gz -ARG IFIX_LIST="" -WORKDIR /opt/ibm -COPY deps/$ACE_INSTALL . -COPY ./ApplyIFixes.sh /opt/ibm -RUN mkdir ace-12 -RUN tar -xzf $ACE_INSTALL --absolute-names --exclude ace-12.\*/tools --exclude ace-12.\*/server/bin/TADataCollector.sh --exclude ace-12.\*/server/transformationAdvisor/ta-plugin-ace.jar --strip-components 1 --directory /opt/ibm/ace-12 \ - && ./ApplyIFixes.sh $IFIX_LIST \ - && rm ./ApplyIFixes.sh \ - && rm -rf /opt/ibm/ace-12/fix-backups* - -# This is to delete any flash files which some customers consider a vulnerability - mostly used by googlelibs -RUN echo "Removing the following swf files" \ - && find . -name "*.swf" -type f \ - && find . -name "*.swf" -type f -delete - -FROM registry.access.redhat.com/ubi8/ubi-minimal - -ENV SUMMARY="Integration Server for App Connect Enterprise" \ - DESCRIPTION="Integration Server for App Connect Enterprise" \ - PRODNAME="AppConnectEnterprise" \ - COMPNAME="IntegrationServer" - -LABEL summary="$SUMMARY" \ - description="$DESCRIPTION" \ - io.k8s.description="$DESCRIPTION" \ - io.k8s.display-name="Integration Server for App Connect Enterprise" \ - io.openshift.tags="$PRODNAME,$COMPNAME" \ - com.redhat.component="$PRODNAME-$COMPNAME" \ - name="$PRODNAME/$COMPNAME" \ - vendor="IBM" \ - version="REPLACE_VERSION" \ - release="REPLACE_RELEASE" \ - license="IBM" \ - maintainer="Hybrid Integration Platform Cloud" \ - io.openshift.expose-services="" \ - usage="" - -# Add required license as text file in Liceses directory (GPL, MIT, APACHE, Partner End User Agreement, etc) -COPY /licenses/ /licenses/ - -RUN microdnf update && microdnf install findutils util-linux unzip tar procps openssl && microdnf clean all \ - && mkdir /etc/ACEOpenTracing /opt/ACEOpenTracing /var/log/ACEOpenTracing && chmod 777 /var/log/ACEOpenTracing /etc/ACEOpenTracing - -# Force reinstall tzdata package to get zoneinfo files -RUN microdnf reinstall tzdata -y - -# Create OpenTracing directories, update permissions and copy in any library or configuration files needed -COPY deps/OpenTracing/library/* ./opt/ACEOpenTracing/ -COPY deps/OpenTracing/config/* ./etc/ACEOpenTracing/ - -WORKDIR /opt/ibm - -COPY --from=builder /opt/ibm/ace-12 /opt/ibm/ace-12 - -# Copy in PID1 process -COPY --from=builder /go/src/github.com/ot4i/ace-docker/runaceserver /usr/local/bin/ -COPY --from=builder /go/src/github.com/ot4i/ace-docker/chkace* /usr/local/bin/ - -# Copy in script files -COPY *.sh /usr/local/bin/ - -COPY ubi/generic_invalid/invalid_license.msgflow /home/aceuser/temp/gen -COPY ubi/generic_invalid/InvalidLicenseJava.jar /home/aceuser/temp/gen -COPY ubi/generic_invalid/application.descriptor /home/aceuser/temp -COPY deps/CSAPI /home/aceuser/deps/CSAPI - -# Create a user to run as, create the ace workdir, and chmod script files -RUN /opt/ibm/ace-12/ace make registry global accept license silently \ - && useradd -u 1000 -d /home/aceuser -G mqbrkrs,wheel aceuser \ - && mkdir -p /var/mqsi \ - && mkdir -p /home/aceuser/initial-config \ - && su - -c '. /opt/ibm/ace-12/server/bin/mqsiprofile && mqsicreateworkdir /home/aceuser/ace-server' \ - && chmod -R 777 /home/aceuser \ - && chmod -R 777 /var/mqsi \ - && su - -c '. /opt/ibm/ace-12/server/bin/mqsiprofile && echo $MQSI_JREPATH && chmod g+w $MQSI_JREPATH/lib/security/cacerts' \ - && chmod -R 777 /home/aceuser/temp \ - && chmod 777 /opt/ibm/ace-12/server/ODBC/dsdriver/odbc_cli/clidriver/license - -COPY git.commit /home/aceuser/ - -# Set BASH_ENV to source mqsiprofile when using docker exec bash -c -ENV BASH_ENV=/usr/local/bin/ace_env.sh - -# Expose ports. 7600, 7800, 7843 for ACE; 9483 for ACE metrics -EXPOSE 7600 7800 7843 9483 - -WORKDIR /home/aceuser - -ENV LOG_FORMAT=basic - -# Set user to prevent container running as root by default -USER 1000 - -# Set entrypoint to run management script - -ENTRYPOINT ["runaceserver"] \ No newline at end of file diff --git a/ubi/Dockerfile.connectors b/ubi/Dockerfile.connectors deleted file mode 100644 index 6304726..0000000 --- a/ubi/Dockerfile.connectors +++ /dev/null @@ -1,17 +0,0 @@ -ARG BASE_IMAGE -FROM $BASE_IMAGE - -USER root -# Add in connectors to node_modules that are accessible from ace -RUN mkdir -p /opt/ibm/ace-12/node_modules -COPY deps/package-connectors.json /opt/ibm/ace-12/package.json -RUN export PATH=$PATH:/opt/ibm/ace-12/common/node/bin \ - && cd /opt/ibm/ace-12/node_modules \ - && npm install loopback-connector-mongodb loopback-connector-postgresql --save \ - && chown -R aceuser:mqbrkrs /opt/ibm/ace-12/node_modules \ - && echo "Removing the following swf files" \ - && find . -name "*.swf" -type f \ - && find . -name "*.swf" -type f -delete - - -USER 1000 \ No newline at end of file diff --git a/ubi/Dockerfile.ifix b/ubi/Dockerfile.ifix deleted file mode 100644 index 38c00d3..0000000 --- a/ubi/Dockerfile.ifix +++ /dev/null @@ -1,20 +0,0 @@ -ARG BASE_IMAGE -FROM ${BASE_IMAGE} - -USER root - -ARG IFIX_ID - -COPY ["${IFIX_ID}.tar.gz", "/tmp"] -RUN mkdir /tmp/fix && \ - cd /tmp/fix && \ - tar xzf /tmp/${IFIX_ID}.tar.gz && \ - ./mqsifixinst.sh /opt/ibm/ace-12 testinstall ${IFIX_ID} && \ - ./mqsifixinst.sh /opt/ibm/ace-12 install ${IFIX_ID} && \ - cd /tmp && \ - rm -rf /tmp/fix && \ - rm -rf /opt/ibm/ace-12/fix-backups* && \ - rm /opt/ibm/ace-12/mqsifixinst.log && \ - rm /opt/ibm/ace-12/mqsifixinst.sh - -USER 1000 diff --git a/ubi/Dockerfile.mqclient b/ubi/Dockerfile.mqclient deleted file mode 100644 index 5767966..0000000 --- a/ubi/Dockerfile.mqclient +++ /dev/null @@ -1,72 +0,0 @@ - -ARG BASE_IMAGE -FROM $BASE_IMAGE as truststore-builder - -USER root - -# The MQ packages to install - see install-mq.sh for default value -ARG MQ_URL -ARG MQ_URL_USER -ARG MQ_URL_PASS -ARG MQ_PACKAGES="MQSeriesRuntime*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesClient*.rpm" -ARG INSTALL_JRE=1 - -COPY ubi/install-mq.sh /usr/local/bin/ -COPY ubi/install-mq-client-prereqs.sh /usr/local/bin/ -COPY ubi/create-default-mq-kdb.sh /usr/local/bin/ -# Install MQ. To avoid a "text file busy" error here, we sleep before installing. -RUN chmod u+x /usr/local/bin/install-*.sh /usr/local/bin/create-*.sh \ - && sleep 1 \ - && install-mq-client-prereqs.sh \ - && install-mq.sh \ - && chown -R 1001:root /opt/mqm/* - -RUN . /opt/ibm/ace-12/server/bin/mqsiprofile \ - && echo $MQSI_JREPATH \ - && /usr/local/bin/create-default-mq-kdb.sh - -# This is to delete any flash files which some customers consider a vulnerability - mostly used by googlelibs -RUN echo "Removing the following swf files" \ - && find . -name "*.swf" -type f \ - && find . -name "*.swf" -type f -delete - -FROM $BASE_IMAGE as clientimage - -USER root - -# The MQ packages to install - see install-mq.sh for default value -ARG MQ_URL -ARG MQ_URL_USER -ARG MQ_URL_PASS -ARG MQ_PACKAGES="MQSeriesRuntime*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesClient*.rpm" -ARG INSTALL_JRE=0 - -ARG MQM_UID=888 - -COPY ubi/install-mq.sh /usr/local/bin/ -COPY ubi/install-mq-client-prereqs.sh /usr/local/bin/ -# Install MQ. To avoid a "text file busy" error here, we sleep before installing. -RUN chmod u+x /usr/local/bin/install-*.sh \ - && sleep 1 \ - && install-mq-client-prereqs.sh $MQM_UID \ - && install-mq.sh $MQM_UID \ - && chown -R 1001:root /opt/mqm/* \ - && chown 1001:root /usr/local/bin/*mq* \ - && mkdir -p /var/mqm/data \ - && chown -R 1001:root /var/mqm \ - && chmod -R 777 /var/mqm - -# Always use port 1414 for MQ & 9157 for the metrics -ENV MQ_OVERRIDE_DATA_PATH=/var/mqm/data MQ_OVERRIDE_INSTALLATION_NAME=Installation1 MQ_USER_NAME="mqm" PATH="${PATH}:/opt/mqm/bin" -ENV AMQ_DIAGNOSTIC_MSG_SEVERITY=1 AMQ_ADDITIONAL_JSON_LOG=1 - -# Set the integration server to use it by default. A user provided server.conf.yaml will override this behaviour if the mqKeyRepository property is set. -RUN mkdir /home/aceuser/truststores -COPY --from=truststore-builder /tmp/mqcacerts.kdb /home/aceuser/truststores/mqcacerts.kdb -COPY --from=truststore-builder /tmp/mqcacerts.sth /home/aceuser/truststores/mqcacerts.sth -RUN chmod -R 777 /home/aceuser/truststores \ - && sed -i 's/#.*mqKeyRepository:.*/mqKeyRepository: \/home\/aceuser\/truststores\/mqcacerts/g' /home/aceuser/ace-server/server.conf.yaml - -ENV MQCERTLABL=aceclient - -USER 1000 diff --git a/ubi/create-default-mq-kdb.sh b/ubi/create-default-mq-kdb.sh deleted file mode 100755 index 68ac10c..0000000 --- a/ubi/create-default-mq-kdb.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2022 -# -# -# 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. - -# Fail on any non-zero return code -set -ex - - -if [ -f "/opt/mqm/bin/runmqckm" ] -then - # - # Used if the downloaded package is the MQ client package from FixCentral. Example URL: - # - # https://ak-delivery04-mul.dhe.ibm.com/sdfdl/v2/sar/CM/WS/0a3ih/0/Xa.2/Xb.jusyLTSp44S0BnrSUlhcQXsmOX33PXiMu_opTWF4XkF7jFZV8UxrP0RFSE0/Xc.CM/WS/0a3ih/0/9.2.0.4-IBM-MQC-LinuxX64.tar.gz/Xd./Xf.LPR.D1VK/Xg.11634360/Xi.habanero/XY.habanero/XZ.m7uIgNXpo_VTCGzC-hylOC79m0eKS5pi/9.2.0.4-IBM-MQC-LinuxX64.tar.gz - # - # Also used if the downloaded package is the full MQ developer package. Example URL: - # - # https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev924_linux_x86-64.tar.gz - # - echo "Using runmqckm to create default MQ kdb from Java cacerts" - /opt/mqm/bin/runmqckm -keydb -convert -db $MQSI_JREPATH/lib/security/cacerts -old_format jks -new_format kdb -pw changeit -target /tmp/mqcacerts.kdb -stash -else - # - # Used if the downloaded package is the MQ redistributable client. Example URL: - # - # https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.2.0.4-IBM-MQC-Redist-LinuxX64.tar.gz - # - echo "Did not find runmqckm; using keytool and runmqakm to create default MQ kdb from Java cacerts" - $MQSI_JREPATH/bin/keytool -importkeystore -srckeystore $MQSI_JREPATH/lib/security/cacerts -srcstorepass changeit -destkeystore /tmp/java-cacerts.p12 -deststoretype pkcs12 -deststorepass changeit - /opt/mqm/bin/runmqakm -keydb -convert -db /tmp/java-cacerts.p12 -old_format p12 -new_format kdb -pw changeit -target /tmp/mqcacerts.kdb -stash -fi diff --git a/ubi/generic_invalid/ACE toolkit project interchange.zip b/ubi/generic_invalid/ACE toolkit project interchange.zip deleted file mode 100644 index ff08575..0000000 Binary files a/ubi/generic_invalid/ACE toolkit project interchange.zip and /dev/null differ diff --git a/ubi/generic_invalid/InvalidLicenseJava.jar b/ubi/generic_invalid/InvalidLicenseJava.jar deleted file mode 100644 index 337b3f8..0000000 Binary files a/ubi/generic_invalid/InvalidLicenseJava.jar and /dev/null differ diff --git a/ubi/generic_invalid/application.descriptor b/ubi/generic_invalid/application.descriptor deleted file mode 100644 index 166bf9e..0000000 --- a/ubi/generic_invalid/application.descriptor +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ubi/generic_invalid/invalid_license.msgflow b/ubi/generic_invalid/invalid_license.msgflow deleted file mode 100644 index bb02f87..0000000 --- a/ubi/generic_invalid/invalid_license.msgflow +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/ubi/install-mq-client-prereqs.sh b/ubi/install-mq-client-prereqs.sh deleted file mode 100755 index 5e748f7..0000000 --- a/ubi/install-mq-client-prereqs.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2015, 2019 -# -# -# 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. - -# Fail on any non-zero return code -set -ex - -test -f /usr/bin/microdnf && MICRODNF=true || MICRODNF=false -test -f /usr/bin/rpm && RPM=true || RPM=false - -if ($RPM); then - EXTRA_RPMS="bash bc ca-certificates file findutils gawk glibc-common grep ncurses-compat-libs passwd procps-ng sed shadow-utils tar util-linux which" - $MICRODNF && microdnf install ${EXTRA_RPMS} -else - $MICRODNF && microdnf install findutils -fi - -# Clean up cached files -$MICRODNF && microdnf clean all diff --git a/ubi/install-mq.sh b/ubi/install-mq.sh deleted file mode 100755 index cc8b077..0000000 --- a/ubi/install-mq.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- -# © Copyright IBM Corporation 2015, 2019 -# -# -# 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. - -# Fail on any non-zero return code -set -ex - -# Download and extract the MQ files -DIR_TMP=/tmp/mq -mkdir -p ${DIR_TMP} -cd ${DIR_TMP} -if [ -z "$MQ_URL_USER" ] -then - curl -LO $MQ_URL -else - curl -LO -u ${MQ_URL_USER}:${MQ_URL_PASS} $MQ_URL -fi -tar -xzf ./*.tar.gz -rm -f ./*.tar.gz -ls -la ${DIR_TMP} - -# Check what sort of MQ package was downloaded -if [ -f "${DIR_TMP}/bin/genmqpkg.sh" ] -then - # Generate MQ package in INSTALLATION_DIR - # - # Used if the downloaded package is the MQ redistributable client. Example URL: - # - # https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.2.0.4-IBM-MQC-Redist-LinuxX64.tar.gz - # - echo "Detected genmqpkg.sh; installing MQ client components" - export genmqpkg_inc32=0 - export genmqpkg_incadm=1 - export genmqpkg_incamqp=0 - export genmqpkg_incams=0 - export genmqpkg_inccbl=0 - export genmqpkg_inccics=0 - export genmqpkg_inccpp=1 - export genmqpkg_incdnet=0 - export genmqpkg_incjava=1 - export genmqpkg_incjre=${INSTALL_JRE} - export genmqpkg_incman=0 - export genmqpkg_incmqbc=0 - export genmqpkg_incmqft=0 - export genmqpkg_incmqsf=0 - export genmqpkg_incmqxr=0 - export genmqpkg_incnls=0 - export genmqpkg_incras=1 - export genmqpkg_incsamp=0 - export genmqpkg_incsdk=0 - export genmqpkg_incserver=0 - export genmqpkg_inctls=1 - export genmqpkg_incunthrd=0 - export genmqpkg_incweb=0 - export INSTALLATION_DIR=/opt/mqm - - # Install requested parts - ${DIR_TMP}/bin/genmqpkg.sh -b ${INSTALLATION_DIR} - ls -la ${INSTALLATION_DIR} - - # Accept the MQ license - ${INSTALLATION_DIR}/bin/mqlicense -accept -else - # Check if should try install using RPM - test -f /usr/bin/rpm && RPM=true || RPM=false - if [ ! $RPM ]; then - echo "Did not find the rpm command; cannot continue MQ client install without rpm" - exit 9 - fi - # - # Used if the downloaded package is the MQ client package from FixCentral. Example URL: - # - # https://ak-delivery04-mul.dhe.ibm.com/sdfdl/v2/sar/CM/WS/0a3ih/0/Xa.2/Xb.jusyLTSp44S0BnrSUlhcQXsmOX33PXiMu_opTWF4XkF7jFZV8UxrP0RFSE0/Xc.CM/WS/0a3ih/0/9.2.0.4-IBM-MQC-LinuxX64.tar.gz/Xd./Xf.LPR.D1VK/Xg.11634360/Xi.habanero/XY.habanero/XZ.m7uIgNXpo_VTCGzC-hylOC79m0eKS5pi/9.2.0.4-IBM-MQC-LinuxX64.tar.gz - # - # Also used if the downloaded package is the full MQ developer package. Example URL: - # - # https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev924_linux_x86-64.tar.gz - # - echo "Did not find genmqpkg.sh; installing MQ client components using rpm" - $RPM && DIR_RPM=$(find ${DIR_TMP} -name "*.rpm" -printf "%h\n" | sort -u | head -1) - - # Find location of mqlicense.sh - MQLICENSE=$(find ${DIR_TMP} -name "mqlicense.sh") - - # Accept the MQ license - ${MQLICENSE} -text_only -accept - - # Install MQ using the rpm packages - $RPM && cd $DIR_RPM && rpm -ivh $MQ_PACKAGES - - # Remove tar.gz files unpacked by RPM postinst scripts - find /opt/mqm -name '*.tar.gz' -delete -fi - -rm -rf ${DIR_TMP} - -# Create the directory for MQ configuration files -install --directory --mode 2775 --owner 1001 --group root /etc/mqm -