Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added travis CI, updated rake tasks, and fixed an issue related to ruby 1.9.3 #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: ruby
rvm:
- 1.9.3
- 1.9.2
- jruby-18mode
- jruby-19mode
- rbx-18mode
- rbx-19mode
- ruby-head
- jruby-head
- 1.8.7
- ree

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
61 changes: 8 additions & 53 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,66 +1,21 @@
# Rakefile for rubyntlm -*- ruby -*-
# $Id: Rakefile,v 1.2 2006/10/05 01:36:52 koheik Exp $

require 'rake/rdoctask'
require 'rubygems'
require 'bundler/gem_tasks'
require 'rdoc/task'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require File.join(File.dirname(__FILE__), 'lib', 'net', 'ntlm')

PKG_NAME = 'rubyntlm'
PKG_VERSION = Net::NTLM::VERSION::STRING

task :default => [:test]

Rake::TestTask.new(:test) do |t|
t.test_files = FileList[ "test/*.rb" ]
t.warning = true
t.verbose = true
end

# Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
# p.need_tar_gz = true
# p.package_dir = 'build'
# p.package_files.include("README", "Rakefile")
# p.package_files.include("lib/net/**/*.rb", "test/**/*.rb", "examples/**/*.rb")
# end

Rake::RDocTask.new do |rd|
RDoc::Task.new do |rd|
rd.rdoc_dir = 'doc'
rd.title = 'Ruby/NTLM library'
rd.main = "README"
rd.rdoc_files.include("README", "lib/**/*.rb")
end

dist_dirs = ["lib", "test", "examples"]
spec = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.summary = %q{Ruby/NTLM library.}
s.description = %q{Ruby/NTLM provides message creator and parser for the NTLM authentication.}
s.authors = ["Kohei Kajimoto"]
s.email = %q{[email protected]}
s.homepage = %q{http://rubyforge.org/projects/rubyntlm}
s.rubyforge_project = %q{rubyntlm}

s.files = ["Rakefile", "README"]
dist_dirs.each do |dir|
s.files = s.files + Dir.glob("#{dir}/**/*.rb")
end

s.has_rdoc = true
s.extra_rdoc_files = %w( README )
s.rdoc_options.concat ['--main', 'README']

s.autorequire = 'net/ntlm'
end

Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
p.package_dir = 'build'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end



10 changes: 6 additions & 4 deletions lib/net/ntlm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def encode_utf16le(str)
end

def pack_int64le(val)
[val & 0x00000000ffffffff, val >> 32].pack("V2")
[val & 0x00000000ffffffff, val >> 32].pack("V2")
end

def swap16(str)
Expand Down Expand Up @@ -444,6 +444,10 @@ def size
@alist.inject(0){|sum, a| sum += a[1].size}
end

def head_size
@alist.inject(0){|sum, a| sum += a[1].size}
end

def [](name)
a = @alist.assoc(name.to_s.intern)
raise ArgumentError, "no such field: #{name}" unless a
Expand Down Expand Up @@ -515,7 +519,7 @@ def value=(val)
end

def data_size
@active ? @value.size : 0
(@active && @value) ? @value.size : 0
end
end

Expand Down Expand Up @@ -567,8 +571,6 @@ def decode64(str)
parse(Base64.decode64(str))
end

alias head_size size

def data_size
security_buffers.inject(0){|sum, a| sum += a[1].data_size}
end
Expand Down
6 changes: 5 additions & 1 deletion rubyntlm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.summary = 'Ruby/NTLM library.'
s.description = 'Ruby/NTLM provides message creator and parser for the NTLM authentication.'

s.author = 'Kohei Kajimoto'
s.authors = ['Kohei Kajimoto', 'John Cant']
s.email = '[email protected]'
s.homepage = 'http://rubyforge.org/projects/rubyntlm'
s.rubyforge_project = 'rubyntlm'
Expand All @@ -17,4 +17,8 @@ Gem::Specification.new do |s|
s.has_rdoc = true
s.extra_rdoc_files = %w( README )
s.rdoc_options.concat ['--main', 'README']

s.add_development_dependency "rake"
s.add_development_dependency "rdoc"
end

5 changes: 5 additions & 0 deletions test/function_test.rb → test/unit/rubyntlm_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def setup
].pack("H*")
end

def test_utf16le_roundtrip
str = "Test string roflmao"
assert_equal str, Net::NTLM.decode_utf16le(Net::NTLM.encode_utf16le(str))
end

def test_lm_hash
ahash = ["ff3750bcc2b22412c2265b23734e0dac"].pack("H*")
assert_equal ahash, Net::NTLM::lm_hash(@passwd)
Expand Down