Skip to content

Commit

Permalink
Minor refactoring of class names (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk authored Oct 5, 2024
1 parent ce0026e commit a5a824c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module WireGuard
# The class generates a config file for the client
class ConfigBuilder
class ClientConfigBuilder
attr_reader :config

def initialize(configs, params)
Expand Down
4 changes: 2 additions & 2 deletions lib/wire_guard/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def dump_json_config(config)
end

def dump_wireguard_config
ConfigUpdater.update
ServerConfigUpdater.update
end

def update_json_config(config)
Expand All @@ -134,7 +134,7 @@ def configs_empty?
end

def build_new_config(configs, params)
ConfigBuilder.new(configs, params).config
ClientConfigBuilder.new(configs, params).config
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module WireGuard
# and reboots the WireGuard server
# This class updates the config file of the server itself and not the clients.
# And it is needed mainly to reboot the server after adding new clients (or deleting them)
class ConfigUpdater
class ServerConfigUpdater
WG_CONF_PATH = "#{Settings.wg_path}/wg0.conf".freeze
WG_PORT = Settings.wg_port
WG_PRE_UP = Settings.wg_pre_up
Expand Down
2 changes: 1 addition & 1 deletion spec/app/clients_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:wg_conf_path) { "#{Settings.wg_path}/wg0.json" }

before do
allow(WireGuard::ConfigUpdater).to receive(:update)
allow(WireGuard::ServerConfigUpdater).to receive(:update)
allow(WireGuard::StatGenerator).to receive_messages(show: '')
allow(WireGuard::KeyGenerator).to receive_messages(wg_genkey: 'wg_genkey', wg_pubkey: 'wg_pubkey',
wg_genpsk: 'wg_genpsk')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe WireGuard::ConfigBuilder do
RSpec.describe WireGuard::ClientConfigBuilder do
subject(:build) { described_class.new(configs, params).config }

before do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe WireGuard::ConfigUpdater do
RSpec.describe WireGuard::ServerConfigUpdater do
subject(:update) { described_class.update }

before do
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/wire_guard/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe WireGuard::Server do
before do
allow(WireGuard::ConfigUpdater).to receive(:update)
allow(WireGuard::ServerConfigUpdater).to receive(:update)
allow(WireGuard::KeyGenerator).to receive_messages(wg_genkey: 'wg_genkey', wg_pubkey: 'wg_pubkey',
wg_genpsk: 'wg_genpsk')
end
Expand Down Expand Up @@ -130,7 +130,7 @@
it 'calls the configuration file update service WireGuard' do
new_config

expect(WireGuard::ConfigUpdater).to have_received(:update)
expect(WireGuard::ServerConfigUpdater).to have_received(:update)
end
end

Expand Down Expand Up @@ -294,7 +294,7 @@
it 'calls the configuration file update service WireGuard' do
delete_config

expect(WireGuard::ConfigUpdater).to have_received(:update)
expect(WireGuard::ServerConfigUpdater).to have_received(:update)
end
end

Expand All @@ -308,7 +308,7 @@
it 'no calls the configuration file update service WireGuard' do
delete_config

expect(WireGuard::ConfigUpdater).not_to have_received(:update)
expect(WireGuard::ServerConfigUpdater).not_to have_received(:update)
end
end
end
Expand Down Expand Up @@ -402,7 +402,7 @@
it 'calls the configuration file update service WireGuard' do
update_config

expect(WireGuard::ConfigUpdater).to have_received(:update)
expect(WireGuard::ServerConfigUpdater).to have_received(:update)
end
end

Expand All @@ -425,7 +425,7 @@
it 'no calls the configuration file update service WireGuard' do
update_config

expect(WireGuard::ConfigUpdater).not_to have_received(:update)
expect(WireGuard::ServerConfigUpdater).not_to have_received(:update)
end
end
end
Expand Down

0 comments on commit a5a824c

Please sign in to comment.