Permalink
Browse files

Added support for WEP connections to the settings hash

  • Loading branch information...
1 parent bc9284a commit 53a806101eb0c228ed9dc80a5cab91d295e97071 @ssteffen committed Feb 15, 2012
Showing with 25 additions and 5 deletions.
  1. +12 −3 lib/network_manager/settings_hash.rb
  2. +13 −2 spec/lib/network_manager/settings_hash_spec.rb
@@ -1,7 +1,7 @@
class NetworkManager::SettingsHash < Hash
# Generates a connection settings hash for a wifi connection.
- def self.create_wifi_settings(ssid, pass = nil)
+ def self.create_wifi_settings(ssid, pass = nil, wpa_flags = 0)
connection_settings = {
'id' => ssid,
'uuid' => ActiveSupport::SecureRandom.uuid,
@@ -21,10 +21,19 @@ def self.create_wifi_settings(ssid, pass = nil)
if security
wifi_settings["security"] = security
security_settings = {
- 'key-mgmt' => 'wpa-psk',
- 'psk' => pass,
'name' => '802-11-wireless-security'
}
+ if(wpa_flags != 0)
+ security_settings.merge!({
+ 'key-mgmt' => 'wpa-psk',
+ 'psk' => pass
+ })
+ else
+ security_settings.merge!({
+ 'key-mgmt' => 'none',
+ 'wep-key0' => pass
+ })
+ end
end
ipv4_settings = {
'method' => 'auto',
@@ -8,7 +8,7 @@
describe :create_wifi_settings do
context "should give settings for Test AP with password pass with string ssid" do
before(:each) do
- @hash = NetworkManager::SettingsHash.create_wifi_settings("Test", "pass")
+ @hash = NetworkManager::SettingsHash.create_wifi_settings("Test", "pass", 325)
end
specify {@hash.should be_a Hash}
specify {@hash['connection']['type'].should eql '802-11-wireless'}
@@ -18,7 +18,7 @@
context "should give settings for Test AP with password pass with byte array ssid" do
before(:each) do
- @hash = NetworkManager::SettingsHash.create_wifi_settings("Test", "pass")
+ @hash = NetworkManager::SettingsHash.create_wifi_settings("Test", "pass", 1)
end
specify {@hash.should be_a Hash}
specify {@hash['connection']['type'].should eql '802-11-wireless'}
@@ -34,6 +34,17 @@
specify {@hash['connection']['type'].should eql '802-11-wireless'}
specify {@hash['802-11-wireless-security'].should eql nil}
end
+
+ context "should give settings for Test AP a WEP connection with password" do
+ before(:each) do
+ @hash = NetworkManager::SettingsHash.create_wifi_settings("Test", "pass", 0)
+ end
+ specify{@hash.should be_a Hash}
+ specify {@hash['connection']['type'].should eql '802-11-wireless'}
+ specify {@hash['802-11-wireless']['ssid'][1].should eql([84, 101, 115, 116])}
+ specify {@hash['802-11-wireless-security']['key-mgmt'].should eql 'none'}
+ specify {@hash['802-11-wireless-security']['wep-key0'].should eql("pass")}
+ end
end
describe :create_ethernet_settings do

0 comments on commit 53a8061

Please sign in to comment.