string-crypt 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
2
+ gem 'minitest'
3
+ require 'minitest/autorun'
4
+ require_relative '../lib/string/crypt'
5
+
6
+ class TestString < Minitest::Test
7
+ def initialize(*args)
8
+ super
9
+ @cls = String
10
+ end
11
+
12
+ def S(arg)
13
+ @cls.new(arg)
14
+ end
15
+
16
+ def test_crypt
17
+ assert_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("aa")))
18
+ refute_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("ab")))
19
+ assert_raises(ArgumentError) {S("mypassword").crypt(S(""))}
20
+ assert_raises(ArgumentError) {S("mypassword").crypt(S("\0a"))}
21
+ assert_raises(ArgumentError) {S("mypassword").crypt(S("a\0"))}
22
+ assert_raises(ArgumentError) {S("poison\u0000null").crypt(S("aa"))}
23
+ [Encoding::UTF_16BE, Encoding::UTF_16LE,
24
+ Encoding::UTF_32BE, Encoding::UTF_32LE].each do |enc|
25
+ assert_raises(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
26
+ assert_raises(ArgumentError) {S("mypassword".encode(enc)).crypt(S("aa"))}
27
+ end
28
+ end
29
+ end
30
+
31
+ class TestString2 < TestString
32
+ class S2 < String
33
+ end
34
+
35
+ def initialize(*args)
36
+ super
37
+ @cls = S2
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string-crypt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Ruby Contributors, Jeremy Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ This provides a backwards-compatible String#crypt method that will
15
+ work when String#crypt is deprecated or removed from Ruby.
16
+ email: code@jeremyevans.net
17
+ executables: []
18
+ extensions:
19
+ - ext/string/crypt/extconf.rb
20
+ extra_rdoc_files: []
21
+ files:
22
+ - BSDL
23
+ - CHANGELOG
24
+ - README.rdoc
25
+ - Rakefile
26
+ - ext/string/crypt/crypt.c
27
+ - ext/string/crypt/extconf.rb
28
+ - ext/string/crypt/missing/crypt.c
29
+ - ext/string/crypt/missing/crypt.h
30
+ - ext/string/crypt/missing/des_tables.c
31
+ - test/test_string_crypt.rb
32
+ homepage: http://github.com/jeremyevans/ruby-string-crypt
33
+ licenses:
34
+ - BSD-2-Clause
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '2.1'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.7.6
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Backward compatible implementation of String#crypt
56
+ test_files: []