net-ldap 0.16.0 → 0.17.0

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.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +47 -0
  3. data/README.rdoc +18 -6
  4. data/lib/net/ber/core_ext.rb +6 -6
  5. data/lib/net/ber.rb +2 -2
  6. data/lib/net/ldap/auth_adapter/gss_spnego.rb +2 -2
  7. data/lib/net/ldap/auth_adapter/sasl.rb +1 -1
  8. data/lib/net/ldap/auth_adapter/simple.rb +1 -1
  9. data/lib/net/ldap/connection.rb +14 -10
  10. data/lib/net/ldap/dataset.rb +3 -3
  11. data/lib/net/ldap/dn.rb +10 -10
  12. data/lib/net/ldap/entry.rb +13 -2
  13. data/lib/net/ldap/error.rb +2 -26
  14. data/lib/net/ldap/filter.rb +10 -3
  15. data/lib/net/ldap/instrumentation.rb +2 -2
  16. data/lib/net/ldap/password.rb +7 -5
  17. data/lib/net/ldap/pdu.rb +1 -1
  18. data/lib/net/ldap/version.rb +1 -1
  19. data/lib/net/ldap.rb +39 -16
  20. data/lib/net/snmp.rb +1 -1
  21. data/lib/net-ldap.rb +1 -1
  22. metadata +19 -109
  23. data/.gitignore +0 -9
  24. data/.rubocop.yml +0 -20
  25. data/.rubocop_todo.yml +0 -753
  26. data/.travis.yml +0 -33
  27. data/CONTRIBUTING.md +0 -54
  28. data/Gemfile +0 -2
  29. data/Rakefile +0 -23
  30. data/net-ldap.gemspec +0 -37
  31. data/script/changelog +0 -47
  32. data/script/generate-fixture-ca +0 -48
  33. data/script/install-openldap +0 -134
  34. data/script/package +0 -7
  35. data/script/release +0 -16
  36. data/test/ber/core_ext/test_array.rb +0 -22
  37. data/test/ber/core_ext/test_string.rb +0 -25
  38. data/test/ber/test_ber.rb +0 -153
  39. data/test/fixtures/ca/ca.info +0 -4
  40. data/test/fixtures/ca/cacert.pem +0 -24
  41. data/test/fixtures/ca/cakey.pem +0 -190
  42. data/test/fixtures/openldap/memberof.ldif +0 -33
  43. data/test/fixtures/openldap/retcode.ldif +0 -76
  44. data/test/fixtures/openldap/slapd.conf.ldif +0 -67
  45. data/test/fixtures/seed.ldif +0 -374
  46. data/test/integration/test_add.rb +0 -28
  47. data/test/integration/test_ber.rb +0 -30
  48. data/test/integration/test_bind.rb +0 -244
  49. data/test/integration/test_delete.rb +0 -31
  50. data/test/integration/test_open.rb +0 -88
  51. data/test/integration/test_password_modify.rb +0 -80
  52. data/test/integration/test_return_codes.rb +0 -38
  53. data/test/integration/test_search.rb +0 -77
  54. data/test/support/vm/openldap/.gitignore +0 -1
  55. data/test/support/vm/openldap/README.md +0 -64
  56. data/test/support/vm/openldap/Vagrantfile +0 -34
  57. data/test/test_auth_adapter.rb +0 -15
  58. data/test/test_dn.rb +0 -44
  59. data/test/test_entry.rb +0 -65
  60. data/test/test_filter.rb +0 -223
  61. data/test/test_filter_parser.rb +0 -24
  62. data/test/test_helper.rb +0 -74
  63. data/test/test_ldap.rb +0 -114
  64. data/test/test_ldap_connection.rb +0 -491
  65. data/test/test_ldif.rb +0 -104
  66. data/test/test_password.rb +0 -10
  67. data/test/test_rename.rb +0 -77
  68. data/test/test_search.rb +0 -39
  69. data/test/test_snmp.rb +0 -119
  70. data/test/test_ssl_ber.rb +0 -40
  71. data/test/testdata.ldif +0 -101
  72. data/testserver/ldapserver.rb +0 -209
  73. data/testserver/testdata.ldif +0 -101
data/.travis.yml DELETED
@@ -1,33 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1
5
- - 2.2
6
- # optional
7
- - ruby-head
8
- - jruby-19mode
9
- - jruby-head
10
- - rbx-2
11
-
12
- env:
13
- - INTEGRATION=openldap
14
-
15
- before_install:
16
- - gem update bundler
17
-
18
- install:
19
- - if [ "$INTEGRATION" = "openldap" ]; then sudo script/install-openldap; fi
20
- - bundle install
21
-
22
- script: bundle exec rake ci
23
-
24
- matrix:
25
- allow_failures:
26
- - rvm: ruby-head
27
- - rvm: jruby-19mode
28
- - rvm: jruby-head
29
- - rvm: rbx-2
30
- fast_finish: true
31
-
32
- notifications:
33
- email: false
data/CONTRIBUTING.md DELETED
@@ -1,54 +0,0 @@
1
- # Contribution guide
2
-
3
- Thank you for using net-ldap. If you'd like to help, keep these guidelines in
4
- mind.
5
-
6
- ## Submitting a New Issue
7
-
8
- If you find a bug, or would like to propose an idea, file a [new issue][issues].
9
- Include as many details as possible:
10
-
11
- - Version of net-ldap gem
12
- - LDAP server version
13
- - Queries, connection information, any other input
14
- - output or error messages
15
-
16
- ## Sending a Pull Request
17
-
18
- [Pull requests][pr] are always welcome!
19
-
20
- Check out [the project's issues list][issues] for ideas on what could be improved.
21
-
22
- Before sending, please add tests and ensure the test suite passes.
23
-
24
- To run the full suite:
25
-
26
- `bundle exec rake`
27
-
28
- To run a specific test file:
29
-
30
- `bundle exec ruby test/test_ldap.rb`
31
-
32
- To run a specific test:
33
-
34
- `bundle exec ruby test/test_ldap.rb -n test_instrument_bind`
35
-
36
- Pull requests will trigger automatic continuous integration builds on
37
- [TravisCI][travis]. To run integration tests locally, see the `test/support`
38
- folder.
39
-
40
- ## Styleguide
41
-
42
- ```ruby
43
- # 1.9+ style hashes
44
- {key: "value"}
45
-
46
- # Multi-line arguments with `\`
47
- MyClass.new \
48
- foo: 'bar',
49
- baz: 'garply'
50
- ```
51
-
52
- [issues]: https://github.com/ruby-net-ldap/ruby-net-ldap/issues
53
- [pr]: https://help.github.com/articles/using-pull-requests
54
- [travis]: https://travis-ci.org/ruby-ldap/ruby-net-ldap
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- # -*- ruby encoding: utf-8 -*-
2
- # vim: syntax=ruby
3
-
4
- require 'rake/testtask'
5
- require 'rubocop/rake_task'
6
- require 'bundler'
7
-
8
- RuboCop::RakeTask.new
9
-
10
- Rake::TestTask.new do |t|
11
- t.libs << 'test'
12
- t.test_files = FileList['test/**/test_*.rb']
13
- t.verbose = true
14
- t.description = 'Run tests, set INTEGRATION=openldap to run integration tests, INTEGRATION_HOST and INTEGRATION_PORT are also supported'
15
- end
16
-
17
- desc 'Run tests and RuboCop (RuboCop runs on mri only)'
18
- task ci: [:test]
19
-
20
- desc 'Run tests and RuboCop'
21
- task rubotest: [:test, :rubocop]
22
-
23
- task default: Bundler.current_ruby.mri? ? [:test, :rubocop] : [:test]
data/net-ldap.gemspec DELETED
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'net/ldap/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{net-ldap}
8
- s.version = Net::LDAP::VERSION
9
- s.license = "MIT"
10
- s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Rory O'Connell", "Kaspar Schiess", "Austin Ziegler", "Michael Schaarschmidt"]
11
- s.description = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the
12
- Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
13
- accessing distributed directory services. Net::LDAP is written completely in
14
- Ruby with no external dependencies. It supports most LDAP client features and a
15
- subset of server features as well.
16
-
17
- Net::LDAP has been tested against modern popular LDAP servers including
18
- OpenLDAP and Active Directory. The current release is mostly compliant with
19
- earlier versions of the IETF LDAP RFCs (2251-2256, 2829-2830, 3377, and 3771).
20
- Our roadmap for Net::LDAP 1.0 is to gain full <em>client</em> compliance with
21
- the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).}
22
- s.email = ["blackhedd@rubyforge.org", "gemiel@gmail.com", "rory.ocon@gmail.com", "kaspar.schiess@absurd.li", "austin@rubyforge.org"]
23
- s.extra_rdoc_files = ["Contributors.rdoc", "Hacking.rdoc", "History.rdoc", "License.rdoc", "README.rdoc"]
24
- s.files = `git ls-files`.split $/
25
- s.test_files = s.files.grep(%r{^test})
26
- s.homepage = %q{http://github.com/ruby-ldap/ruby-net-ldap}
27
- s.rdoc_options = ["--main", "README.rdoc"]
28
- s.require_paths = ["lib"]
29
- s.required_ruby_version = ">= 2.0.0"
30
- s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services}
31
-
32
- s.add_development_dependency("flexmock", "~> 1.3")
33
- s.add_development_dependency("rake", "~> 10.0")
34
- s.add_development_dependency("rubocop", "~> 0.42.0")
35
- s.add_development_dependency("test-unit")
36
- s.add_development_dependency("byebug")
37
- end
data/script/changelog DELETED
@@ -1,47 +0,0 @@
1
- #!/bin/bash
2
- # Usage: script/changelog [-r <repo>] [-b <base>] [-h <head>]
3
- #
4
- # repo: BASE string of GitHub REPOsitory url. e.g. "user_or_org/REPOsitory". Defaults to git remote url.
5
- # base: git ref to compare from. e.g. "v1.3.1". Defaults to latest git tag.
6
- # head: git ref to compare to. Defaults to "HEAD".
7
- #
8
- # Generate a changelog preview from pull requests merged between `base` and
9
- # `head`.
10
- #
11
- # https://github.com/jch/release-scripts/blob/master/changelog
12
- set -e
13
-
14
- [ $# -eq 0 ] && set -- --help
15
- while [[ $# > 1 ]]
16
- do
17
- key="$1"
18
- case $key in
19
- -r|--repo)
20
- repo="$2"
21
- shift
22
- ;;
23
- -b|--base)
24
- base="$2"
25
- shift
26
- ;;
27
- -h|--head)
28
- head="$2"
29
- shift
30
- ;;
31
- *)
32
- ;;
33
- esac
34
- shift
35
- done
36
-
37
- repo="${repo:-$(git remote -v | grep push | awk '{print $2}' | cut -d'/' -f4- | sed 's/\.git//')}"
38
- base="${base:-$(git tag -l | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -n 1)}"
39
- head="${head:-HEAD}"
40
- api_url="https://api.github.com"
41
-
42
- # get merged PR's. Better way is to query the API for these, but this is easier
43
- for pr in $(git log --oneline $base..$head | grep "Merge pull request" | awk '{gsub("#",""); print $5}')
44
- do
45
- # frustrated with trying to pull out the right values, fell back to ruby
46
- curl -s "$api_url/repos/$repo/pulls/$pr" | ruby -rjson -e 'pr=JSON.parse(STDIN.read); puts "* #{pr[%q(title)]} {##{pr[%q(number)]}}[#{pr[%q(html_url)]}]"'
47
- done
@@ -1,48 +0,0 @@
1
- #!/bin/bash
2
-
3
- BASE_PATH=$( cd "`dirname $0`/../test/fixtures/ca" && pwd )
4
- cd "${BASE_PATH}" || exit 4
5
-
6
- USAGE=$( cat << EOS
7
- Usage:
8
- $0 --regenerate
9
-
10
- Generates a new self-signed CA, for integration testing. This should only need
11
- to be run if you are writing new TLS/SSL tests, and need to generate
12
- additional fixtuer CAs.
13
-
14
- This script uses the GnuTLS certtool CLI. If you are on macOS,
15
- 'brew install gnutls', and it will be installed as 'gnutls-certtool'.
16
- Apple unfortunately ships with an incompatible /usr/bin/certtool that does
17
- different things.
18
- EOS
19
- )
20
-
21
- if [ "x$1" != 'x--regenerate' ]; then
22
- echo "${USAGE}"
23
- exit 1
24
- fi
25
-
26
- TOOL=`type -p certtool`
27
- if [ "$(uname)" = "Darwin" ]; then
28
- TOOL=`type -p gnutls-certtool`
29
- if [ ! -x "${TOOL}" ]; then
30
- echo "Sorry, Darwin requires gnutls-certtool; try `brew install gnutls`"
31
- exit 2
32
- fi
33
- fi
34
-
35
- if [ ! -x "${TOOL}" ]; then
36
- echo "Sorry, no certtool found!"
37
- exit 3
38
- fi
39
- export TOOL
40
-
41
-
42
- ${TOOL} --generate-privkey > ./cakey.pem
43
- ${TOOL} --generate-self-signed \
44
- --load-privkey ./cakey.pem \
45
- --template ./ca.info \
46
- --outfile ./cacert.pem
47
-
48
- echo "cert and private key generated! Don't forget to check them in"
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
- set -x
4
-
5
- BASE_PATH=$( cd "`dirname $0`/../test/fixtures/openldap" && pwd )
6
- SEED_PATH=$( cd "`dirname $0`/../test/fixtures" && pwd )
7
-
8
- dpkg -s slapd time ldap-utils gnutls-bin ssl-cert > /dev/null ||\
9
- DEBIAN_FRONTEND=noninteractive apt-get update -y --force-yes && \
10
- DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes slapd time ldap-utils gnutls-bin ssl-cert
11
-
12
- /etc/init.d/slapd stop
13
-
14
- TMPDIR=$(mktemp -d)
15
- cd $TMPDIR
16
-
17
- # Delete data and reconfigure.
18
- cp -v /var/lib/ldap/DB_CONFIG ./DB_CONFIG
19
- rm -rf /etc/ldap/slapd.d/*
20
- rm -rf /var/lib/ldap/*
21
- cp -v ./DB_CONFIG /var/lib/ldap/DB_CONFIG
22
- slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/slapd.conf.ldif
23
- # Load memberof and ref-int overlays and configure them.
24
- slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/memberof.ldif
25
- # Load retcode overlay and configure
26
- slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/retcode.ldif
27
-
28
- # Add base domain.
29
- slapadd -F /etc/ldap/slapd.d <<EOM
30
- dn: dc=rubyldap,dc=com
31
- objectClass: top
32
- objectClass: domain
33
- dc: rubyldap
34
- EOM
35
-
36
- chown -R openldap.openldap /etc/ldap/slapd.d
37
- chown -R openldap.openldap /var/lib/ldap
38
-
39
- /etc/init.d/slapd start
40
-
41
- # Import seed data.
42
- # NOTE: use ldapadd in order for memberOf and refint to apply, instead of:
43
- # cat $SEED_PATH/seed.ldif | slapadd -F /etc/ldap/slapd.d
44
- /usr/bin/time ldapadd -x -D "cn=admin,dc=rubyldap,dc=com" -w passworD1 \
45
- -h localhost -p 389 \
46
- -f $SEED_PATH/seed.ldif
47
-
48
- rm -rf $TMPDIR
49
-
50
- # SSL
51
- export CA_CERT="/usr/local/share/ca-certificates/rubyldap-ca.crt"
52
- export CA_KEY="/etc/ssl/private/rubyldap-ca.key"
53
-
54
- # The self-signed fixture CA cert & key are generated by
55
- # `script/generate-fiuxture-ca` and checked into version control.
56
- # You shouldn't need to muck with these unless you're writing more
57
- # TLS/SSL integration tests, and need special magic values in the cert.
58
-
59
- cp "${SEED_PATH}/ca/cacert.pem" "${CA_CERT}"
60
- cp "${SEED_PATH}/ca/cakey.pem" "${CA_KEY}"
61
-
62
- # actually add the fixture CA to the system store
63
- update-ca-certificates
64
-
65
- # Make a private key for the server:
66
- certtool --generate-privkey \
67
- --bits 1024 \
68
- --outfile /etc/ssl/private/ldap01_slapd_key.pem
69
-
70
- sh -c "cat > /etc/ssl/ldap01.info <<EOF
71
- organization = Example Company
72
- cn = ldap01.example.com
73
- dns_name = ldap01.example.com
74
- dns_name = ldap02.example.com
75
- dns_name = localhost
76
- tls_www_server
77
- encryption_key
78
- signing_key
79
- expiration_days = 3650
80
- EOF"
81
-
82
- # The integration server may be accessed by IP address, in which case
83
- # we want some of the IPs included in the cert. We skip loopback (127.0.0.1)
84
- # because that's the IP we use in the integration test for cert name mismatches.
85
- ADDRS=$(ifconfig -a | grep 'inet addr:' | cut -f 2 -d : | cut -f 1 -d ' ')
86
- for ip in $ADDRS; do
87
- if [ "x$ip" = 'x127.0.0.1' ]; then continue; fi
88
- echo "ip_address = $ip" >> /etc/ssl/ldap01.info
89
- done
90
-
91
- # Create the server certificate
92
- certtool --generate-certificate \
93
- --load-privkey /etc/ssl/private/ldap01_slapd_key.pem \
94
- --load-ca-certificate "${CA_CERT}" \
95
- --load-ca-privkey "${CA_KEY}" \
96
- --template /etc/ssl/ldap01.info \
97
- --outfile /etc/ssl/certs/ldap01_slapd_cert.pem
98
-
99
- ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF | true
100
- dn: cn=config
101
- add: olcTLSCACertificateFile
102
- olcTLSCACertificateFile: ${CA_CERT}
103
- -
104
- add: olcTLSCertificateFile
105
- olcTLSCertificateFile: /etc/ssl/certs/ldap01_slapd_cert.pem
106
- -
107
- add: olcTLSCertificateKeyFile
108
- olcTLSCertificateKeyFile: /etc/ssl/private/ldap01_slapd_key.pem
109
- EOF
110
-
111
- # LDAP over TLS/SSL (ldaps://) is deprecated in favour of StartTLS. The latter
112
- # refers to an existing LDAP session (listening on TCP port 389) becoming
113
- # protected by TLS/SSL whereas LDAPS, like HTTPS, is a distinct
114
- # encrypted-from-the-start protocol that operates over TCP port 636. But we
115
- # enable it for testing here.
116
- sed -i -e 's|^SLAPD_SERVICES="\(.*\)"|SLAPD_SERVICES="ldap:/// ldapi:/// ldaps:///"|' /etc/default/slapd
117
-
118
- adduser openldap ssl-cert
119
- chgrp ssl-cert /etc/ssl/private/ldap01_slapd_key.pem
120
- chmod g+r /etc/ssl/private/ldap01_slapd_key.pem
121
- chmod o-r /etc/ssl/private/ldap01_slapd_key.pem
122
-
123
- # Drop packets on a secondary port used to specific timeout tests
124
- iptables -A INPUT -p tcp -j DROP --dport 8389
125
-
126
- # Forward a port for Vagrant
127
- iptables -t nat -A PREROUTING -p tcp --dport 9389 -j REDIRECT --to-port 389
128
-
129
- # fix up /etc/hosts for cert validation
130
- grep ldap01 /etc/hosts || echo "127.0.0.1 ldap01.example.com" >> /etc/hosts
131
- grep ldap02 /etc/hosts || echo "127.0.0.1 ldap02.example.com" >> /etc/hosts
132
- grep bogus /etc/hosts || echo "127.0.0.1 bogus.example.com" >> /etc/hosts
133
-
134
- service slapd restart
data/script/package DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Usage: script/package
3
- # Updates the gemspec and builds a new gem in the pkg directory.
4
-
5
- mkdir -p pkg
6
- gem build *.gemspec
7
- mv *.gem pkg
data/script/release DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Usage: script/release
3
- # Build the package, tag a commit, push it to origin, and then release the
4
- # package publicly.
5
-
6
- set -e
7
-
8
- version="$(script/package | grep Version: | awk '{print $2}')"
9
- [ -n "$version" ] || exit 1
10
-
11
- echo $version
12
- git commit --allow-empty -a -m "Release $version"
13
- git tag "v$version"
14
- git push origin
15
- git push origin "v$version"
16
- gem push pkg/*-${version}.gem
@@ -1,22 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- class TestBERArrayExtension < Test::Unit::TestCase
4
- def test_control_code_array
5
- control_codes = []
6
- control_codes << ['1.2.3'.to_ber, true.to_ber].to_ber_sequence
7
- control_codes << ['1.7.9'.to_ber, false.to_ber].to_ber_sequence
8
- control_codes = control_codes.to_ber_sequence
9
- res = [['1.2.3', true], ['1.7.9', false]].to_ber_control
10
- assert_equal control_codes, res
11
- end
12
-
13
- def test_wrap_array_if_not_nested
14
- result1 = ['1.2.3', true].to_ber_control
15
- result2 = [['1.2.3', true]].to_ber_control
16
- assert_equal result2, result1
17
- end
18
-
19
- def test_empty_string_if_empty_array
20
- assert_equal "", [].to_ber_control
21
- end
22
- end
@@ -1,25 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- class TestBERStringExtension < Test::Unit::TestCase
4
- def setup
5
- @bind_request = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus UNCONSUMED".b
6
- @result = @bind_request.read_ber!(Net::LDAP::AsnSyntax)
7
- end
8
-
9
- def test_parse_ber
10
- assert_equal [1, [3, "Administrator", "ad_is_bogus"]], @result
11
- end
12
-
13
- def test_unconsumed_message
14
- assert_equal " UNCONSUMED", @bind_request
15
- end
16
-
17
- def test_exception_does_not_modify_string
18
- original = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus".b
19
- duplicate = original.dup
20
- flexmock(StringIO).new_instances.should_receive(:read_ber).and_raise(Net::BER::BerError)
21
- duplicate.read_ber!(Net::LDAP::AsnSyntax) rescue Net::BER::BerError
22
-
23
- assert_equal original, duplicate
24
- end
25
- end
data/test/ber/test_ber.rb DELETED
@@ -1,153 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- class TestBEREncoding < Test::Unit::TestCase
4
- def test_empty_array
5
- assert_equal [], [].to_ber.read_ber
6
- end
7
-
8
- def test_array
9
- ary = [1, 2, 3]
10
- encoded_ary = ary.map(&:to_ber).to_ber
11
-
12
- assert_equal ary, encoded_ary.read_ber
13
- end
14
-
15
- # http://tools.ietf.org/html/rfc4511#section-5.1
16
- def test_true
17
- assert_equal "\x01\x01\xFF".b, true.to_ber
18
- end
19
-
20
- def test_false
21
- assert_equal "\x01\x01\x00", false.to_ber
22
- end
23
-
24
- # Sample based
25
- {
26
- 0 => "\x02\x01\x00",
27
- 1 => "\x02\x01\x01",
28
- 127 => "\x02\x01\x7F",
29
- 128 => "\x02\x02\x00\x80",
30
- 255 => "\x02\x02\x00\xFF",
31
- 256 => "\x02\x02\x01\x00",
32
- 65535 => "\x02\x03\x00\xFF\xFF",
33
- 65536 => "\x02\x03\x01\x00\x00",
34
- 8388607 => "\x02\x03\x7F\xFF\xFF",
35
- 8388608 => "\x02\x04\x00\x80\x00\x00",
36
- 16_777_215 => "\x02\x04\x00\xFF\xFF\xFF",
37
- 0x01000000 => "\x02\x04\x01\x00\x00\x00",
38
- 0x3FFFFFFF => "\x02\x04\x3F\xFF\xFF\xFF",
39
- 0x4FFFFFFF => "\x02\x04\x4F\xFF\xFF\xFF",
40
-
41
- # Some odd samples...
42
- 5 => "\x02\x01\x05",
43
- 500 => "\x02\x02\x01\xf4",
44
- 50_000 => "\x02\x03\x00\xC3\x50",
45
- 5_000_000_000 => "\x02\x05\x01\x2a\x05\xF2\x00",
46
-
47
- # negatives
48
- -1 => "\x02\x01\xFF",
49
- -127 => "\x02\x01\x81",
50
- -128 => "\x02\x01\x80",
51
- -255 => "\x02\x02\xFF\x01",
52
- -256 => "\x02\x02\xFF\x00",
53
- -65535 => "\x02\x03\xFF\x00\x01",
54
- -65536 => "\x02\x03\xFF\x00\x00",
55
- -65537 => "\x02\x03\xFE\xFF\xFF",
56
- -8388607 => "\x02\x03\x80\x00\x01",
57
- -8388608 => "\x02\x03\x80\x00\x00",
58
- -16_777_215 => "\x02\x04\xFF\x00\x00\x01",
59
- }.each do |number, expected_encoding|
60
- define_method "test_encode_#{number}" do
61
- assert_equal expected_encoding.b, number.to_ber
62
- end
63
-
64
- define_method "test_decode_encoded_#{number}" do
65
- assert_equal number, expected_encoding.b.read_ber
66
- end
67
- end
68
-
69
- # Round-trip encoding: This is mostly to be sure to cover Bignums well.
70
- def test_powers_of_two
71
- 100.times do |p|
72
- n = 2 << p
73
-
74
- assert_equal n, n.to_ber.read_ber
75
- end
76
- end
77
-
78
- def test_powers_of_ten
79
- 100.times do |p|
80
- n = 5 * 10**p
81
-
82
- assert_equal n, n.to_ber.read_ber
83
- end
84
- end
85
-
86
- if "Ruby 1.9".respond_to?(:encoding)
87
- def test_encode_utf8_strings
88
- assert_equal "\x04\x02\xC3\xA5".b, "\u00e5".force_encoding("UTF-8").to_ber
89
- end
90
-
91
- def test_utf8_encodable_strings
92
- assert_equal "\x04\nteststring", "teststring".encode("US-ASCII").to_ber
93
- end
94
-
95
- def test_encode_binary_data
96
- # This is used for searching for GUIDs in Active Directory
97
- assert_equal "\x04\x10" + "j1\xB4\xA1*\xA2zA\xAC\xA9`?'\xDDQ\x16".b,
98
- ["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin
99
- end
100
-
101
- def test_non_utf8_encodable_strings
102
- assert_equal "\x04\x01\x81".b, "\x81".to_ber
103
- end
104
- end
105
- end
106
-
107
- class TestBERDecoding < Test::Unit::TestCase
108
- def test_decode_number
109
- assert_equal 6, "\002\001\006".read_ber(Net::LDAP::AsnSyntax)
110
- end
111
-
112
- def test_decode_string
113
- assert_equal "testing", "\004\007testing".read_ber(Net::LDAP::AsnSyntax)
114
- end
115
-
116
- def test_decode_ldap_bind_request
117
- assert_equal [1, [3, "Administrator", "ad_is_bogus"]], "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus".read_ber(Net::LDAP::AsnSyntax)
118
- end
119
- end
120
-
121
- class TestBERIdentifiedString < Test::Unit::TestCase
122
- def test_binary_data
123
- data = ["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").force_encoding("ASCII-8BIT")
124
- bis = Net::BER::BerIdentifiedString.new(data)
125
-
126
- assert bis.valid_encoding?, "should be a valid encoding"
127
- assert_equal "ASCII-8BIT", bis.encoding.name
128
- end
129
-
130
- def test_ascii_data_in_utf8
131
- data = "some text".force_encoding("UTF-8")
132
- bis = Net::BER::BerIdentifiedString.new(data)
133
-
134
- assert bis.valid_encoding?, "should be a valid encoding"
135
- assert_equal "UTF-8", bis.encoding.name
136
- end
137
-
138
- def test_umlaut_data_in_utf8
139
- data = "Müller".force_encoding("UTF-8")
140
- bis = Net::BER::BerIdentifiedString.new(data)
141
-
142
- assert bis.valid_encoding?, "should be a valid encoding"
143
- assert_equal "UTF-8", bis.encoding.name
144
- end
145
-
146
- def test_utf8_data_in_utf8
147
- data = ["e4b8ad"].pack("H*").force_encoding("UTF-8")
148
- bis = Net::BER::BerIdentifiedString.new(data)
149
-
150
- assert bis.valid_encoding?, "should be a valid encoding"
151
- assert_equal "UTF-8", bis.encoding.name
152
- end
153
- end
@@ -1,4 +0,0 @@
1
- cn = rubyldap
2
- ca
3
- cert_signing_key
4
- expiration_days = 7200
@@ -1,24 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIID7zCCAlegAwIBAgIMV7zWei6SNfABx6jMMA0GCSqGSIb3DQEBCwUAMBMxETAP
3
- BgNVBAMTCHJ1YnlsZGFwMB4XDTE2MDgyMzIzMDQyNloXDTM2MDUxMDIzMDQyNlow
4
- EzERMA8GA1UEAxMIcnVieWxkYXAwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGK
5
- AoIBgQDGe9wziGHZJhIf+IEKSk1tpT9Mu7YgsUwjrlutvkoO1Q6K+amTAVDXizPf
6
- 1DVSDpZP5+CfBOznhgLMsPvrQ02w4qx5/6X9L+zJcMk8jTNYSKj5uIKpK52E7Uok
7
- aygMXeaqroPONGkoJIZiVGgdbWfTvcffTm8FOhztXUbMrMXJNinFsocGHEoMNN8b
8
- vqgAyG4+DFHoK4L0c6eQjE4nZBChieZdShUhaBpV7r2qSNbPw67cvAKuEzml58mV
9
- 1ZF1F73Ua8gPWXHEfUe2GEfG0NnRq6sGbsDYe/DIKxC7AZ89udZF3WZXNrPhvXKj
10
- ZT7njwcMQemns4dNPQ0k2V4vAQ8pD8r8Qvb65FiSopUhVaGQswAnIMS1DnFq88AQ
11
- KJTKIXbBuMwuaNNSs6R/qTS2RDk1w+CGpRXAg7+1SX5NKdrEsu1IaABA/tQ/zKKk
12
- OLLJaD0giX1weBVmNeFcKxIoT34VS59eEt5APmPcguJnx+aBrA9TLzSO788apBN0
13
- 4lGAmR0CAwEAAaNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQA
14
- MB0GA1UdDgQWBBRTvXSkge03oqLu7UUjFI+oLYwnujANBgkqhkiG9w0BAQsFAAOC
15
- AYEATSZQWH+uSN5GvOUvJ8LHWkeVovn0UhboK0K7GzmMeGz+dp/Xrj6eQ4ONK0zI
16
- RCJyoo/nCR7CfQ5ujVXr03XD2SUgyD565ulXuhw336DasL5//fucmQYDeqhwbKML
17
- FTzsF9H9dO4J5TjxJs7e5dRJ0wrP/XEY+WFhXXdSHTl8vGCI6QqWc7TvDpmbS4iX
18
- uTzjJswu9Murt9JUJNMN2DlDi/vBBeruaj4c2cMMnKMvkfj14kd8wMocmzj+gVQl
19
- r+fRQbKAJNec65lA4/Zeb6sD9SAi0ZIVgxA4a7g8/sdNWHIAxPicpJkIJf30TsyY
20
- F+8+Hd5mBtCbvFfAVkT6bHBP1OiAgNke+Rh/j/sQbyWbKCKw0+jpFJgO9KUNGfC0
21
- O/CqX+J4G7HqL8VJqrLnBvOdhfetAvNQtf1gcw5ZwpeEFM+Kvx/lsILaIYdAUSjX
22
- ePOc5gI2Bi9WXq+T9AuhSf+TWUR874m/rdTWe5fM8mXCNl7C4I5zCqLltEDkSoMP
23
- jDj/
24
- -----END CERTIFICATE-----