Skip to content

Commit 940692a

Browse files
committed
Fixes building the plugin only for Ruby 2.7.
Updates the testing library. Set specific gem versions.
1 parent 7b4dc52 commit 940692a

10 files changed

+41
-25
lines changed

.github/workflows/ci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
ruby:
14-
- "2.5"
15-
- "2.6"
1614
- "2.7"
1715
name: Ruby ${{ matrix.ruby }}
1816
steps:

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ruby:2.7
2+
RUN apt update -y && apt install libkrb5-dev libldap-dev libsasl2-dev -y && \
3+
gem install bundler -v 2.4.22
4+
COPY . /src
5+
WORKDIR /src
6+
RUN bundle install

Gemfile

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ source 'https://rubygems.org'
22
gemspec
33

44
group :development do
5-
if RUBY_VERSION < '2.2.2'
6-
gem 'rack-test', '~> 0.7.0'
7-
else
8-
gem 'rack-test'
9-
end
10-
5+
gem 'rack-test'
6+
gem 'minitest'
7+
gem 'mocha'
118
gem 'smart_proxy', :git => 'https://github.com/theforeman/smart-proxy.git', :branch => 'develop'
9+
gem 'minitest-reporters', '~> 1.7.1'
1210
end

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ruby-2.7:
2+
docker build --no-cache=true -t dev:ruby-2.7 .
3+
docker run -it dev:ruby-2.7 /bin/bash
4+
5+
.PHONY: test
6+
test:
7+
bundle exec rake test

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Rake::TestTask.new(:test) do |t|
1111
t.libs << 'test'
1212
t.test_files = FileList['test/**/*_test.rb']
1313
t.verbose = true
14-
end
14+
end

lib/smart_proxy_realm_ad/provider.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def radcli_join(hostfqdn, computername, password)
103103
enroll = setup_enroll(hostfqdn, computername, password)
104104
begin
105105
enroll.join
106-
logger.info "Successfully joined computer #{computername} with FQDN #{hostfqdn}")
106+
logger.info "Successfully joined computer #{computername} with FQDN #{hostfqdn}"
107107
true
108108
rescue RuntimeError => ex
109109
handle_runtime_error(ex, enroll)

smart_proxy_realm_ad_plugin.gemspec

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Gem::Specification.new do |s|
66
s.version = Proxy::AdRealm::VERSION
77
s.date = Date.today.to_s
88
s.license = 'GPL-3.0'
9+
s.required_ruby_version = '>= 2.7'
10+
911
s.authors = ['Mårten Cassel']
1012
s.email = ['marten.cassel@gmail.com']
1113
s.homepage = 'https://github.com/theforeman/smart_proxy_realm_ad_plugin'
@@ -16,9 +18,10 @@ Gem::Specification.new do |s|
1618
s.files = Dir['{config,lib,bundler.d}/**/*'] + ['README.md', 'LICENSE']
1719
s.test_files = Dir['test/**/*']
1820

19-
s.add_development_dependency('rake')
20-
s.add_development_dependency('mocha')
21-
s.add_development_dependency('test-unit')
22-
s.add_dependency('rkerberos')
23-
s.add_dependency('radcli')
21+
s.add_development_dependency('rake', '~> 13.2.1')
22+
s.add_development_dependency('mocha', '~> 2.7.1')
23+
s.add_development_dependency('minitest', '~> 5.25.4')
24+
s.add_development_dependency('test-unit', '~> 3.6.7')
25+
s.add_dependency('rkerberos', '~> 0.1.5')
26+
s.add_dependency('radcli', '~> 1.1.0')
2427
end

test/ad_provider_test.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'smart_proxy_realm_ad/provider'
44
require 'radcli'
55

6-
class RealmAdTest < Test::Unit::TestCase
6+
class RealmAdTest < Minitest::Test
77
def setup
88
@realm = 'test_realm'
99
@provider = Proxy::AdRealm::Provider.new(
@@ -72,7 +72,7 @@ def test_rebuild_host_returns_password
7272
end
7373

7474
def test_generate_password_returns_random_passwords
75-
assert_not_equal @provider.generate_password, @provider.generate_password
75+
refute_equal @provider.generate_password, @provider.generate_password
7676
end
7777

7878
def test_generate_password_returns_20_char_long_password
@@ -81,22 +81,22 @@ def test_generate_password_returns_20_char_long_password
8181

8282
def test_apply_computername_prefix_should_return_false_when_prefix_is_nil
8383
provider = Proxy::AdRealm::Provider.new(computername_prefix: nil, realm: 'example.com')
84-
assert_false provider.apply_computername_prefix?('host.example.com')
84+
refute provider.apply_computername_prefix?('host.example.com')
8585
end
8686

8787
def test_apply_computername_prefix_should_return_false_when_prefix_is_empty
8888
provider = Proxy::AdRealm::Provider.new(computername_prefix: '', realm: 'example.com')
89-
assert_false provider.apply_computername_prefix?('host.example.com')
89+
refute provider.apply_computername_prefix?('host.example.com')
9090
end
9191

9292
def test_apply_computername_prefix_should_return_false_when_hostname_contains_prefix
9393
provider = Proxy::AdRealm::Provider.new(computername_prefix: 'PREFIX-', realm: 'example.com')
94-
assert_false provider.apply_computername_prefix?('prefix-host.example.com')
94+
refute provider.apply_computername_prefix?('prefix-host.example.com')
9595
end
9696

9797
def test_apply_computername_prefix_should_return_true_when_computername_hash_is_used
9898
provider = Proxy::AdRealm::Provider.new(computername_prefix: 'PREFIX-', computername_hash: true, realm: 'example.com')
99-
assert_true provider.apply_computername_prefix?('host.example.com')
99+
assert provider.apply_computername_prefix?('host.example.com')
100100
end
101101

102102
def test_hostfqdn_to_computername_uses_prefix
@@ -119,7 +119,7 @@ def test_unrecognized_realm_raises_exception
119119
end
120120

121121
def test_find
122-
assert_true @provider.find('a_host_fqdn')
122+
assert @provider.find('a_host_fqdn')
123123
end
124124

125125
def test_delete

test/internal_api_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def container_instance; end
1515

1616
require 'realm/realm_api'
1717

18-
class InternalApiTest < Test::Unit::TestCase
18+
class InternalApiTest < Minitest::Test
1919
include Rack::Test::Methods
2020

2121
def app

test/test_helper.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
require 'test/unit'
2-
require 'mocha/setup'
2+
require 'minitest/autorun'
3+
require 'mocha/minitest'
4+
require 'minitest/reporters'
5+
6+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
37

48
require 'smart_proxy_for_testing'
59

610
# create log directory in our (not smart-proxy) directory
7-
FileUtils.mkdir_p File.dirname(Proxy::SETTINGS.log_file)
11+
FileUtils.mkdir_p File.dirname(Proxy::SETTINGS.log_file)

0 commit comments

Comments
 (0)