database_cleaner-ldap 0.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +40 -0
- data/README.md +52 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/database_cleaner-ldap.gemspec +32 -0
- data/lib/database_cleaner-ldap.rb +1 -0
- data/lib/database_cleaner/ldap.rb +14 -0
- data/lib/database_cleaner/ldap/deletion.rb +35 -0
- data/lib/database_cleaner/ldap/version.rb +5 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e3bf95bf018753b3ce51d8c1212f62cc17165aa9b437e831ff7979505d7360d
|
4
|
+
data.tar.gz: 339de7b3c63b4d8734a3f4a2919d54f81f70885fad5be1ab1de2db02e8be41e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d7f75f7fb0731571d7f0d60045cd0907f2a7042fe7efe7e7d40e2d5e409e6936df1148f83a08c6a08e782b763109d3541b376ba3bdb34b4e451ad7381349f5b
|
7
|
+
data.tar.gz: fd16babf5cfa69f5f68a45a73091e4379b1e8fe8a4006ff6c9f7935bd71831514601603fa4c668817be72a20abd8ef8526648b9d6ab7e613fbaf7bd59cbbbd09
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at thomas.scholz@swisscom.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
database_cleaner-ldap (0.1.0)
|
5
|
+
database_cleaner-core (~> 2.0.0.beta)
|
6
|
+
net-ldap (~> 0.16.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (11.1.3)
|
12
|
+
database_cleaner-core (2.0.0.beta2)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
net-ldap (0.16.3)
|
15
|
+
rake (12.3.3)
|
16
|
+
rspec (3.10.0)
|
17
|
+
rspec-core (~> 3.10.0)
|
18
|
+
rspec-expectations (~> 3.10.0)
|
19
|
+
rspec-mocks (~> 3.10.0)
|
20
|
+
rspec-core (3.10.0)
|
21
|
+
rspec-support (~> 3.10.0)
|
22
|
+
rspec-expectations (3.10.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-mocks (3.10.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-support (3.10.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
byebug
|
35
|
+
database_cleaner-ldap!
|
36
|
+
rake (~> 12.0)
|
37
|
+
rspec (~> 3.0)
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Database Cleaner Adapter for LDAP
|
2
|
+
|
3
|
+
Clean your LDAP Database with Database Cleaner.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# Gemfile
|
11
|
+
group :test do
|
12
|
+
gem 'database_cleaner-ldap', '~> 0.1.0'
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### RSpec Example
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
# spec/support/database_cleaner.rb
|
22
|
+
|
23
|
+
require 'database_cleaner/ldap'
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.before(:suite) do
|
27
|
+
DatabaseCleaner[:ldap, db: Net::LDAP.new].strategy = :deletion, {
|
28
|
+
# Clean posixGroups and posixAccounts only, don't touch other LDAP entries
|
29
|
+
filter: Net::LDAP::Filter.eq('objectClass', 'posixGroup') | Net::LDAP::Filter.eq('objectClass', 'posixAccount')
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
config.around(:each) do |example|
|
34
|
+
DatabaseCleaner.cleaning { example.run }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/database_cleaner-ldap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/database_cleaner-ldap/blob/master/CODE_OF_CONDUCT.md).
|
48
|
+
|
49
|
+
|
50
|
+
## Code of Conduct
|
51
|
+
|
52
|
+
Everyone interacting in the DatabaseCleaner::Ldap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/database_cleaner-ldap/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "database_cleaner/ldap"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'lib/database_cleaner/ldap/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "database_cleaner-ldap"
|
5
|
+
spec.version = DatabaseCleaner::Ldap::VERSION
|
6
|
+
spec.authors = ["Thomas Scholz"]
|
7
|
+
spec.email = ["thomas.scholz@swisscom.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Strategy for cleaning LDAP databases. Can be used to ensure a clean state for testing.}
|
10
|
+
spec.description = %q{Strategy for cleaning LDAP databases. Can be used to ensure a clean state for testing.}
|
11
|
+
spec.homepage = "https://github.com/tscholz/database_cleaner-ldap"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/tscholz/database_cleaner-ldap"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/tscholz/database_cleaner-ldap/CHANGELOG"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "database_cleaner-core", "~> 2.0.0.beta"
|
31
|
+
spec.add_dependency "net-ldap", '~> 0.16.0'
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'database_cleaner/ldap'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "net/ldap"
|
2
|
+
require "database_cleaner/core"
|
3
|
+
|
4
|
+
require "database_cleaner/ldap/version"
|
5
|
+
require "database_cleaner/ldap/deletion"
|
6
|
+
|
7
|
+
module DatabaseCleaner
|
8
|
+
module Ldap
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# This triggers the DATABASE_URL safeguard before it can be configured. :( TODO file an issue on the Database Cleaner project
|
14
|
+
# DatabaseCleaner[:ldap].strategy = :deletion
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "database_cleaner/strategy"
|
2
|
+
|
3
|
+
module DatabaseCleaner
|
4
|
+
module Ldap
|
5
|
+
class Deletion < Strategy
|
6
|
+
attr_reader :filter
|
7
|
+
|
8
|
+
def initialize(filter: nil)
|
9
|
+
raise ArgumentError,
|
10
|
+
"Option :filter must be a Net::LDAP::Filter" unless filter.nil? || filter.is_a?(Net::LDAP::Filter)
|
11
|
+
|
12
|
+
@filter = filter
|
13
|
+
end
|
14
|
+
|
15
|
+
def clean
|
16
|
+
entries.each { |ldap_entry| delete! ldap_entry.dn }
|
17
|
+
end
|
18
|
+
|
19
|
+
def db
|
20
|
+
@db ||= Net::LDAP.new
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def entries
|
26
|
+
Array db.search(filter: filter)
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete!(dn)
|
30
|
+
db.delete(dn: dn) or
|
31
|
+
raise "Could no delete #{dn}. Reason: #{db.get_operation_result}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: database_cleaner-ldap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Scholz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: database_cleaner-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0.beta
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.0.beta
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-ldap
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.16.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.16.0
|
41
|
+
description: Strategy for cleaning LDAP databases. Can be used to ensure a clean state
|
42
|
+
for testing.
|
43
|
+
email:
|
44
|
+
- thomas.scholz@swisscom.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- CODE_OF_CONDUCT.md
|
53
|
+
- Gemfile
|
54
|
+
- Gemfile.lock
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
59
|
+
- database_cleaner-ldap.gemspec
|
60
|
+
- lib/database_cleaner-ldap.rb
|
61
|
+
- lib/database_cleaner/ldap.rb
|
62
|
+
- lib/database_cleaner/ldap/deletion.rb
|
63
|
+
- lib/database_cleaner/ldap/version.rb
|
64
|
+
homepage: https://github.com/tscholz/database_cleaner-ldap
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
allowed_push_host: https://rubygems.org
|
69
|
+
homepage_uri: https://github.com/tscholz/database_cleaner-ldap
|
70
|
+
source_code_uri: https://github.com/tscholz/database_cleaner-ldap
|
71
|
+
changelog_uri: https://github.com/tscholz/database_cleaner-ldap/CHANGELOG
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.3.0
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.1
|
86
|
+
requirements: []
|
87
|
+
rubygems_version: 3.1.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Strategy for cleaning LDAP databases. Can be used to ensure a clean state
|
91
|
+
for testing.
|
92
|
+
test_files: []
|