This works fine for testing from my local machine. However, this is insecure for pushing the code to my git repo and also for deployment. I need to be able to provide both the username/password as a parameter or in another secure fashion, but can't determine how to do this, as it appears that @elastic/synthetics handles configuration of the browser object at startup from the playwrightOptions object.
browser.newContext: httpCredentials.username: expected string, got undefined
at Function.setupDriver (/Users/e14214/dev/ts/elastic-synthetics-test/projects/alip/node_modules/@elastic/synthetics/src/core/gatherer.ts:65:21)
at Function.createContext (/Users/e14214/dev/ts/elastic-synthetics-test/projects/alip/node_modules/@elastic/synthetics/src/core/runner.ts:77:20)
at Runner.runJourney (/Users/e14214/dev/ts/elastic-synthetics-test/projects/alip/node_modules/@elastic/synthetics/src/core/runner.ts:343:21)
at Runner.run (/Users/e14214/dev/ts/elastic-synthetics-test/projects/alip/node_modules/@elastic/synthetics/src/core/runner.ts:446:11)
at Command.<anonymous> (/Users/e14214/dev/ts/elastic-synthetics-test/projects/alip/node_modules/@elastic/synthetics/src/cli.ts:132:23)
It appears that the parameters specified from the command line are merged into the config object at a later point in the test, which means that the browser doesn't start with the additional options in the context.
anther solution that will require a pull request is we can apply params to config file just like we do for lightweight yaml with that you will be able to use params in config file like this
This would be ideal, if it weren't deprecated. Prior to submitting my original post, I did try to follow the suggestion from the docs to create a new browser context, but it appears that the @elastic/synthetics setup creates an initial browser context and runs in that context. In creating a new context, what happened was that it opened a new window that everything ran in, but nothing validated in. If you have a pattern for doing this, it would certainly be an acceptable item, especially if I could configure this in a beforeAll().
anther solution that will require a pull request is we can apply params to config file just like we do for lightweight yaml with that you will be able to use params in config file like this
If it were to be done like this, I would think that something similar to monitor.use({}); would be more helpful...like a playwrightOptions.use({}).
At the moment, setting the httpCredentials: {} from environment variables at startup is working for me. And it does resolve the issue where the params values as defined in Synthetics seem to be visible to ANYBODY with access to synthetics, which doesn't seem to be that secure to me.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.