11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst https = require('https');
91cb0ef41Sopenharmony_ciconst tls = require('tls');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst dftProtocol = {};
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci// Test for immutable `opts`
141cb0ef41Sopenharmony_ci{
151cb0ef41Sopenharmony_ci  const opts = common.mustNotMutateObjectDeep({
161cb0ef41Sopenharmony_ci    foo: 'bar',
171cb0ef41Sopenharmony_ci    ALPNProtocols: [ 'http/1.1' ],
181cb0ef41Sopenharmony_ci  });
191cb0ef41Sopenharmony_ci  const server = https.createServer(opts);
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
221cb0ef41Sopenharmony_ci  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
231cb0ef41Sopenharmony_ci                     0);
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci// Validate that `createServer` can work with the only argument requestListener
281cb0ef41Sopenharmony_ci{
291cb0ef41Sopenharmony_ci  const mustNotCall = common.mustNotCall();
301cb0ef41Sopenharmony_ci  const server = https.createServer(mustNotCall);
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci  tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
331cb0ef41Sopenharmony_ci  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
341cb0ef41Sopenharmony_ci                     0);
351cb0ef41Sopenharmony_ci  assert.strictEqual(server.listeners('request').length, 1);
361cb0ef41Sopenharmony_ci  assert.strictEqual(server.listeners('request')[0], mustNotCall);
371cb0ef41Sopenharmony_ci}
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci// Validate that `createServer` can work with no arguments
411cb0ef41Sopenharmony_ci{
421cb0ef41Sopenharmony_ci  const server = https.createServer();
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
451cb0ef41Sopenharmony_ci                     0);
461cb0ef41Sopenharmony_ci  assert.strictEqual(server.listeners('request').length, 0);
471cb0ef41Sopenharmony_ci}
48