mwittrock / cpilint

Automating your SAP Cloud Integration governance since 2019.
MIT License
58 stars 20 forks source link

Bad tenant URI #15

Closed RalfZi closed 3 months ago

RalfZi commented 3 months ago

Hello I use CPILINT for the first time. Since I am working behind a firewall I had to add the following parameters to the cpilint.bat "%JAVACMD%"%ASSERTS% -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -classpath "%CPILINT_CP%" dk.mwittrock.cpilint.CliClient %*

Now wen I run it I get the error Bad tenant URI is the Command line parameter wrong? -host https://trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com see logs:

07:23:28.231 INFO  dk.mwittrock.cpilint.CliClient - CPILint version 1.0.4
07:23:28.264 INFO  dk.mwittrock.cpilint.CliClient - Launching CliClient
07:23:28.264 DEBUG dk.mwittrock.cpilint.CliClient - Command line arguments provided: '-rules' '../samples/naming.xml' '-host' 'https://trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com' '-user' 'ralf.zimmerningkat@svlfg.de' '-password' '*******' '-debug'
07:23:28.264 INFO  dk.mwittrock.cpilint.CliClient - Command line arguments parsed successfully
07:23:28.264 INFO  dk.mwittrock.cpilint.CliClient - Mode detected: TENANT_SUPPLIER_MULTI_MODE
07:23:28.512 INFO  dk.mwittrock.cpilint.RulesFile - Rules file XML is valid
07:23:29.112 DEBUG dk.mwittrock.cpilint.CliClient - Calling GitHub API at https://api.github.com/repos/mwittrock/cpilint/releases/latest
07:23:29.945 DEBUG dk.mwittrock.cpilint.CliClient - Parsing GitHub API response
07:23:29.945 DEBUG dk.mwittrock.cpilint.CliClient - Extracted tag 'v1.0.4' from GitHub API response
07:23:29.945 DEBUG dk.mwittrock.cpilint.CliClient - The latest version on GitHub is 1.0.4
07:23:29.945 INFO  dk.mwittrock.cpilint.CpiLint - Starting inspection of iflow artifacts
07:23:29.945 INFO  d.m.c.api.CloudIntegrationOdataApi - Retrieving package IDs from tenant
07:23:29.945 DEBUG d.m.c.api.CloudIntegrationOdataApi - SAP packages will be included
07:23:30.179 ERROR dk.mwittrock.cpilint.CliClient - Iflow artifact supplier error
dk.mwittrock.cpilint.suppliers.IflowArtifactSupplierError: API error when fetching package IDs
    at dk.mwittrock.cpilint.suppliers.TenantAllArtifactsSupplier.setup(Unknown Source)
    at dk.mwittrock.cpilint.CpiLint.run(Unknown Source)
    at dk.mwittrock.cpilint.CliClient.main(Unknown Source)
Caused by: dk.mwittrock.cpilint.api.CloudIntegrationApiError: Bad tenant URI error
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.tenantUriFromPath(Unknown Source)
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.integrationPackagesUri(Unknown Source)
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.getEditableIntegrationPackageIds(Unknown Source)
    ... 3 common frames omitted
Caused by: java.net.URISyntaxException: Expected closing bracket for IPv6 address at index 15: https://[https://trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com]/api/v1/IntegrationPackages
    at java.base/java.net.URI$Parser.fail(Unknown Source)
    at java.base/java.net.URI$Parser.failExpecting(Unknown Source)
    at java.base/java.net.URI$Parser.parseServer(Unknown Source)
    at java.base/java.net.URI$Parser.parseAuthority(Unknown Source)
    at java.base/java.net.URI$Parser.parseHierarchical(Unknown Source)
    at java.base/java.net.URI$Parser.parse(Unknown Source)
    at java.base/java.net.URI.<init>(Unknown Source)
    at java.base/java.net.URI.<init>(Unknown Source)
    ... 6 common frames omitted
07:23:30.179 INFO  dk.mwittrock.cpilint.CliClient - Exiting CliClient with error status 2 and message: There was an error while retrieving iflow artifacts: API error when fetching package IDs

regards Ralf

mwittrock commented 3 months ago

Hi Ralf

In addition to your question, you raise a good point about dealing with local HTTP proxies. This might be something that should at least be added to the documentation, if not supported directly by the tool.

About the -host parameter. First off, it excepts only the hostname, not a URL. so remove the "https://" bit. Second, what you need is not the hostname of the Integration Suite application, but rather the so-called service root of the Cloud Integration OData API. Where to find it is documented here. But basically you copy it from a service key created with the api plan.

This will be added to an FAQ in the wiki shortly.

Let me know how it works out!

Regards,

Morten

RalfZi commented 3 months ago

Hi Morton I update the host to -host trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com/api/v1 now the log shows the error The reference to entity "client_id" must end with the ';' delimiter

08:57:20.758 INFO  dk.mwittrock.cpilint.CliClient - CPILint version 1.0.4
08:57:20.784 INFO  dk.mwittrock.cpilint.CliClient - Launching CliClient
08:57:20.787 DEBUG dk.mwittrock.cpilint.CliClient - Command line arguments provided: '-rules' '../samples/naming.xml' '-host' 'trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com/api/v1' '-user' 'ralf.zimmerningkat@svlfg.de' '-password' '*******' '-debug'
08:57:20.793 INFO  dk.mwittrock.cpilint.CliClient - Command line arguments parsed successfully
08:57:20.794 INFO  dk.mwittrock.cpilint.CliClient - Mode detected: TENANT_SUPPLIER_MULTI_MODE
08:57:21.038 INFO  dk.mwittrock.cpilint.RulesFile - Rules file XML is valid
08:57:21.761 DEBUG dk.mwittrock.cpilint.CliClient - Calling GitHub API at https://api.github.com/repos/mwittrock/cpilint/releases/latest
08:57:22.426 DEBUG dk.mwittrock.cpilint.CliClient - Parsing GitHub API response
08:57:22.432 DEBUG dk.mwittrock.cpilint.CliClient - Extracted tag 'v1.0.4' from GitHub API response
08:57:22.432 DEBUG dk.mwittrock.cpilint.CliClient - The latest version on GitHub is 1.0.4
08:57:22.433 INFO  dk.mwittrock.cpilint.CpiLint - Starting inspection of iflow artifacts
08:57:22.433 INFO  d.m.c.api.CloudIntegrationOdataApi - Retrieving package IDs from tenant
08:57:22.433 DEBUG d.m.c.api.CloudIntegrationOdataApi - SAP packages will be included
08:57:22.652 DEBUG d.m.c.api.CloudIntegrationOdataApi - Integration packages URI generated: https://trial-3nudqf4g.integrationsuite-trial.cfapps.us10-001.hana.ondemand.com/api/v1/api/v1/IntegrationPackages
08:57:23.103 ERROR dk.mwittrock.cpilint.CliClient - Iflow artifact supplier error
dk.mwittrock.cpilint.suppliers.IflowArtifactSupplierError: API error when fetching package IDs
    at dk.mwittrock.cpilint.suppliers.TenantAllArtifactsSupplier.setup(Unknown Source)
    at dk.mwittrock.cpilint.CpiLint.run(Unknown Source)
    at dk.mwittrock.cpilint.CliClient.main(Unknown Source)
Caused by: dk.mwittrock.cpilint.api.CloudIntegrationApiError: Error evaluating XQuery
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.evaluateXquery(Unknown Source)
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.getApiResponseAndEvaluateXquery(Unknown Source)
    at dk.mwittrock.cpilint.api.CloudIntegrationOdataApi.getEditableIntegrationPackageIds(Unknown Source)
    ... 3 common frames omitted
Caused by: net.sf.saxon.s9api.SaxonApiException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 518; The reference to entity "client_id" must end with the ';' delimiter.
    at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:360)
    at net.sf.saxon.s9api.XQueryEvaluator.setSource(XQueryEvaluator.java:134)
    ... 6 common frames omitted
Caused by: net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 518; The reference to entity "client_id" must end with the ';' delimiter.
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:459)
    at net.sf.saxon.event.Sender.send(Sender.java:168)
    at net.sf.saxon.Configuration.buildDocumentTree(Configuration.java:4201)
    at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:357)
    ... 7 common frames omitted
Caused by: org.xml.sax.SAXParseException: The reference to entity "client_id" must end with the ';' delimiter.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:439)
    ... 10 common frames omitted
08:57:23.103 INFO  dk.mwittrock.cpilint.CliClient - Exiting CliClient with error status 2 and message: There was an error while retrieving iflow artifacts: API error when fetching package IDs

Regards, Ralf

mwittrock commented 3 months ago

Hi Ralf

Sorry, I was not entirely clear. The -host parameter should only contain a hostname, nothing else. CPILint uses that hostname to generate the service root. The hostname you copy from a service key (created with the api plan). Specifically from the "url" field. Do not copy the entire field! Just the hostname.

How to create a service key is described here.

Regards,

Morten

RalfZi commented 3 months ago

Hello Morton I am inconsolable, but I seem to be slow on the uptake today. My api key is as follows and I am using the url, but I am still getting the same error.

{
  "oauth": {
    "createdate": "2024-08-06T07:46:32.897Z",
    "clientid": "xxxxxx",
    "clientsecret": "xxxxx",
    "tokenurl": "https://trial-3nudqf4g.authentication.us10.hana.ondemand.com/oauth/token",
    "url": "https://trial-3nudqf4g.it-cpitrial05.cfapps.us10-001.hana.ondemand.com"
  }
}

Ralf

mwittrock commented 3 months ago

Hi Ralf

You should not add the whole URL; just the hostname. So your -host parameter should contain: trial-3nudqf4g.it-cpitrial05.cfapps.us10-001.hana.ondemand.com

Regards,

Morten

RalfZi commented 3 months ago

I try the generated URL from the log file in my local browser: https://[trial-3nudqf4g.it-cpitrial05.cfapps.us10-001.hana.ondemand.com/api/v1/IntegrationPackages](https://trial-3nudqf4g.it-cpitrial05.cfapps.us10-001.hana.ondemand.com/api/v1/IntegrationPackages) so the url seems to be correct I am unable to pass a password with special characters like % as a parameter whithout the parameter -password it works

In iflow 'IF_ERP_XI_RECEIVER' (ID 'IF_ERP_XI_RECEIVER'): The Sender participant 'ERP' (ID 'Participant_1') does not follow the naming scheme: Participant names must start with OP_, B2B_ or CP_
In iflow 'IF_ERP_XI_RECEIVER' (ID 'IF_ERP_XI_RECEIVER'): The Receiver participant 'Receiver' (ID 'Participant_2') does not follow the naming scheme: Participant names must start with OP_, B2B_ or CP_
In iflow 'IF_DAV4-2_copy' (ID 'IF_DAV4-2_copy'): The Receiver participant 'ELSTER' (ID 'Participant_2') does not follow the naming scheme: Participant names must start with OP_, B2B_ or CP_
In iflow 'IF_Demo_DAV5_8_Ein_200_TechPruef' (ID 'IF_Demo_DAV5_8_Ein_200_TechPruef'): The Sender participant 'Sender1' (ID 'Participant_109') does not follow the naming scheme: Participant names must start with OP_, B2B_ or CP_
I
mwittrock commented 3 months ago

Hi Ralf

If your password contains special characters, it probably should be wrapped in double quotes: -password "like this".

In the next version, you can directly use a service key to authenticate, which is a lot easier to manage. That also means you don't need to provide the hostname, since it's already in the key.

Closing the issue now. Have fun with CPILint!

Regards,

Morten

mwittrock commented 3 months ago

Aaaand forgot to close :-)