这个问题在这里已经有了答案:
[karate][standalone] Error : could not find or read file
(1 个回答)
9 个月前关闭。
我正在创建没有类路径的配置 SSL。我必须在外部安装证书。以下是我的代码。
'''
* def keyStoreFilePath = './certificates/clientcert.p12'
* def trustStoreFilePath = './certificates/truststore.jks'
* configure ssl = { keyStore: keyStoreFilePath, keyStorePassword: '123', keyStoreType: 'pkcs12', trustStore:trustStoreFilePath, trustStoreType:'pkcs12', trustStorePassword:'123' }
'''
但是我找不到文件,因为 Karate 正在目标文件夹中寻找证书。我的证书在根路径上。有没有办法在不使用类路径的情况下创建配置 SSL?'''
java.lang.RuntimeException: java.io.FileNotFoundException: /Users/kiranjaghni/work/javaworkspace/poc/karateDSL/transfer-case-grid-api-auto/transfercasegrid-api-automation/target/test-classes/examples/login/trustStoreFilePath (No such file or directory)
classpath:examples/login/login.feature:14 ==> expected: <0> but was: <2>
at examples.ExamplesTest.testParallel(ExamplesTest.java:15)
'''
最佳答案
我认为你应该使用 file:
可以从文件系统读取的前缀。所以这取决于你,你可以在任何地方拥有这些文件,只要它们是可访问的。
* def keyStoreFilePath = 'file:/any/absolute/path/certificates/clientcert.p12'
请阅读文档:https://github.com/intuit/karate#reading-files另请注意,您需要使用嵌入式表达式:https://github.com/intuit/karate#embedded-expressions
* configure ssl = { keyStore: '#(keyStoreFilePath)' }
关于ssl - Karate :我的服务 APi 需要客户端身份验证证书,证书在类路径中不可用。我必须将它们安装在 docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69331261/