Closed JyotiPMallick closed 2 weeks ago
Note: i4epact.pem and i4epact.crt are generated using openssl.
@JyotiPMallick The configuration requires .crt and .key files.
Try extracting .key from .pem https://stackoverflow.com/a/14484363
And an example of using mock server with cert/key - https://github.com/pactumjs/pactum/pull/293
@leelaprasadv thank you so much, I tried configuring with below configuration
const { mock } = require("pactum");
mock.addInteraction({
request: {
method: "GET",
path: "/api/v1/health/",
},
response: {
status: 200,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ message: "I am listening 👋" }),
},
});
mock.addInteraction({
request: {
method: "GET",
path: /.*/,
},
response: {
status: 404,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ error: "Broken link" }), // Response for invalid URLs
},
});
const mockOptions = {
port: 3009,
host: "localhost",
httpsOptions: {
key: "./certification/i4epact.key",
cert: "./certification/i4epact.crt",
},
};
mock.setDefaults(mockOptions);
mock.start(mockOptions);
I am getting
throw new PactumConfigurationError(`Invalid port number provided - ${port}`);
^
PactumConfigurationError: Invalid port number provided - [object Object]
@JyotiPMallick - mock.start() doesn't accept an object as parameter. Please check the signature here - https://pactumjs.github.io/api/mock/start.html
As you are already setting defaults, you could simply start the server mock.start()
Thank you @leelaprasadv
Describe the bug
I am trying to run the Pactum mock server on https with a self-signed certificate giving an error.
To Reproduce Steps to reproduce the behavior:
Used with following configuration:
Expected behavior I should access mock server with http on 3009 and https on 3010
Screenshots I am getting
Software (please complete the following information):