Open qzhou1607-zz opened 7 years ago
@qzhou1607 Can you also post some short code examples on how this would look like? Thanks!
So when creating a test server, we need to have two port numbers instead of one. Creating both http
and https
servers simultaneously is shown as below. We just need to make sure that both the http
and https
port numbers increment by 2 each time a new test server is created.
const startServer = async () => {
options = {
cert: await promisify(fs.readFile)(path.join(__dirname, 'fixture/server.crt'), 'utf8'),
key: await promisify(fs.readFile)(path.join(__dirname, 'fixture/server.key'), 'utf8')
};
http.createServer(app).listen(HTTP_PORT_NUMBER);
https.createServer(options, app).listen(HTTPS_PORT_NUMBER);
};
startServer();
@qzhou1607 I was referring to the tests.
Also I think the http and https option should be optional (http, https, or both).
@alrra If I remember right, this issue is for supporting http
and https
both when running a ruleTest. With https://github.com/sonarwhal/sonar/commit/173c5fc598914c4d6b08451d8fc24355b3371ffc we only have the option of http
OR https
, but not both
. Do we still want that option?
Ahh, ok.
In order to do this, the server needs to use 2 ports, 1 for http, and another 1 for https.
We could add another property httpsPort
and try to use that one.
The problem would be how to handle the redirects from one to another
Another problem we currently have with http vs https is that we cannot have http and https tests in the same file even if they are in different arrays. I have no clue why is that.
The current
test-server
after https://github.com/sonarwhal/sonar/pull/370 is merged supports creating a server that serves EITHERhttp
orhttps
pages ONLY, but doesn't have support for listening tohttp
andhttps
requests simultaneously in the same rule test, which is needed to add tests for rulestrict transport security
(https://github.com/sonarwhal/sonar/pull/370) if we want to support testinghttp
site first, and then test the same site withhttps
protocol if it doesn't redirect itself, as suggested by @alrra .