distinguished_name 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/distinguished_name/transform.rb +20 -0
- data/lib/distinguished_name/version.rb +1 -1
- data/test/transform_test.rb +12 -0
- metadata +9 -8
@@ -27,8 +27,28 @@ class DistinguishedName::Transform
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
# TODO: big_endian() and little_endian() are named poorly
|
31
|
+
# we didn't take into account DNs of the format
|
32
|
+
# "/CN=Welker.Wes.83/OU=people/OU=Patriots/O=NFL/C=US"
|
33
|
+
# and
|
34
|
+
# "C=US,O=NFL,OU=Patriots,OU=people,CN=Welker.Wes.83"
|
35
|
+
def little_endian_comma_separated(dn_string)
|
36
|
+
x509_parsed_dn = parse_dn(dn_string)
|
37
|
+
prefix = ''
|
38
|
+
separator = ','
|
39
|
+
if cn_is_first?(x509_parsed_dn)
|
40
|
+
big_endian(x509_parsed_dn, prefix, separator)
|
41
|
+
else
|
42
|
+
little_endian(x509_parsed_dn, prefix, separator)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
private
|
31
47
|
|
48
|
+
def cn_is_first?(x509_parsed_dn)
|
49
|
+
x509_parsed_dn.to_a.first.first.downcase == "cn"
|
50
|
+
end
|
51
|
+
|
32
52
|
def big_endian(x509_parsed_dn, prefix, separator)
|
33
53
|
x509_parsed_dn.to_a.map {|piece| "#{prefix}#{piece[0]}=#{piece[1]}" }.join(separator)
|
34
54
|
end
|
data/test/transform_test.rb
CHANGED
@@ -25,6 +25,18 @@ class TransformTest < Test::Unit::TestCase
|
|
25
25
|
assert_equal(@ldap_dn, DistinguishedName::Transform.ldapify(@slash_dn))
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_little_endian_comma_separated_always_outputs_little_endian_format_with_commas
|
29
|
+
formats_we_care_about = [ "C=US,O=NFL,OU=Patriots,OU=people,CN=Welker.Wes.83",
|
30
|
+
"/C=US/O=NFL/OU=Patriots/OU=people/CN=Welker.Wes.83",
|
31
|
+
"CN=Welker.Wes.83,OU=people,OU=Patriots,O=NFL,C=US",
|
32
|
+
"/CN=Welker.Wes.83/OU=people/OU=Patriots/O=NFL/C=US" ]
|
33
|
+
formats_we_care_about.each do |dn|
|
34
|
+
assert_equal("CN=Welker.Wes.83,OU=people,OU=Patriots,O=NFL,C=US",
|
35
|
+
DistinguishedName::Transform.little_endian_comma_separated(dn),
|
36
|
+
"was not equal for #{dn}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
28
40
|
def test_slashify_method_fails_gracefully_with_invalid_dn_string_that_has_no_equal_sign
|
29
41
|
bad_dn = 'foo'
|
30
42
|
assert_raise OpenSSL::X509::NameError do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distinguished_name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This is a gem for interacting with the string representation of distinguished names, per the RFC-1779 (http://www.ietf.org/rfc/rfc1779.txt)
|
15
15
|
email:
|
@@ -18,7 +18,7 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
21
|
+
- ".gitignore"
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
@@ -39,15 +39,17 @@ require_paths:
|
|
39
39
|
- lib
|
40
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: !binary |-
|
45
|
+
MA==
|
45
46
|
none: false
|
46
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
48
|
requirements:
|
48
|
-
- -
|
49
|
+
- - ">="
|
49
50
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
51
|
+
version: !binary |-
|
52
|
+
MA==
|
51
53
|
none: false
|
52
54
|
requirements: []
|
53
55
|
rubyforge_project:
|
@@ -59,4 +61,3 @@ test_files:
|
|
59
61
|
- test/canonicalize_test.rb
|
60
62
|
- test/test_helper.rb
|
61
63
|
- test/transform_test.rb
|
62
|
-
...
|