Skip to content

Commit

Permalink
first unit test passes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Phillips committed Mar 9, 2012
1 parent f0b4c38 commit 66371d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
4 changes: 1 addition & 3 deletions lib/luvit/tls.lua
Expand Up @@ -28,7 +28,7 @@ local net = require('net')
local fmt = require('string').format
local END_OF_FILE = 42
local DEBUG = true
local DEBUG = false
local function dbg(format, ...)
if DEBUG == true then
Expand Down Expand Up @@ -520,7 +520,6 @@ function SecurePair:err()
dbg('SecurePair:err')
if self._secureEstablished == false then
local err = self.ssl:getError()
p(err)
if not err then
err = Error:new('socket hang up')
err.code = 'ECONNRESET'
Expand Down Expand Up @@ -672,7 +671,6 @@ function Server:setOptions(options)
if options.sessionIdContext then
self.sessionIdContext = options.sessionIdContext
end
p(self)
end
function createServer(options, listener)
Expand Down
1 change: 0 additions & 1 deletion src/luv_tls_conn.c
Expand Up @@ -57,7 +57,6 @@ static const int X509_NAME_FLAGS = ASN1_STRFLGS_ESC_CTRL

#define TLS_CONNECTION_HANDLE "ltls_connection"

#define SSL_DEBUG
#ifdef SSL_DEBUG
#define DBG(...) fprintf(stderr, __VA_ARGS__)
#else
Expand Down
45 changes: 19 additions & 26 deletions tests/test-tls-set-ciphers.lua
Expand Up @@ -7,43 +7,36 @@ local options = {
cert = fixture.certPem,
key = fixture.keyPem,
port = fixture.commonPort,
-- ciphers = 'NULL-MD5'
ciphers = 'NULL-MD5'
}

local reply = 'I AM'
local reply = 'I AM THE WALRUS'
local nconns = 0
local response = ''

--process:on('exit', function()
-- p('test' .. response)
--end)

local server = tls.createServer(options, function(conn)
conn:write(reply)
conn.socket:close()
nconns = nconns + 1
end)

server:listen(fixture.commonPort, '127.0.0.1', function()
-- local cmd = {
-- 's_client',
-- '-debug', '-cipher', 'NULL-MD5',
-- '-connect', '127.0.0.1:' .. fixture.commonPort
-- }
-- local child = childprocess.spawn('openssl', cmd, {})
-- child:on('error', function(err)
-- p(err)
-- end)
-- child:on('exit', function(exit_status)
-- p(response)
-- server:close()
-- end)
-- child.stderr:on('data', function(data)
-- p(data)
-- end)
-- child.stdout:on('data', function(data)
-- p(data)
-- response = response .. data
-- end)
local cmd = {
's_client',
'-cipher', 'NULL-MD5',
'-connect', '127.0.0.1:' .. fixture.commonPort
}
local child = childprocess.spawn('openssl', cmd, {})
child:on('error', function(err)
p(err)
end)
child:on('exit', function(exit_status)
assert(nconns == 1)
assert(response:find(reply) ~= -1)
server:close()
end)
child.stdout:on('data', function(data)
response = response .. data
end)
end)

0 comments on commit 66371d0

Please sign in to comment.