# the request is in pseudo-osm format... this is kind-of an
# abuse, maybe should change to some other format?
- doc = XML::Parser.string(request.raw_post).parse
+ doc = XML::Parser.string(request.raw_post, :options => XML::Parser::Options::NOERROR).parse
doc.find("//osm/node").each do |n|
lon << n["lon"].to_f * GeoRecord::SCALE
lat << n["lat"].to_f * GeoRecord::SCALE
new_preferences = {}
- doc = XML::Parser.string(request.raw_post).parse
+ doc = XML::Parser.string(request.raw_post, :options => XML::Parser::Options::NOERROR).parse
doc.find("//preferences/preference").each do |pt|
if preference = old_preferences.delete(pt["k"])
class Acl < ActiveRecord::Base
+ validates :k, :presence => true
+
def self.match(address, domain = nil)
if domain
Acl.where("address >>= ? OR domain = ?", address, domain)
# Read in xml as text and return it's Node object representation
def self.from_xml(xml, create = false)
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/node").each do |pt|
TYPES = %w(node way relation).freeze
def self.from_xml(xml, create = false)
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/relation").each do |pt|
# Read in xml as text and return it's Node object representation
def self.from_xml(xml, create = false)
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/gpx_file").each do |pt|
# Read in xml as text and return it's Way object representation
def self.from_xml(xml, create = false)
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/way").each do |pt|
--- /dev/null
+FactoryGirl.define do
+ factory :acl do
+ sequence(:k) { |n| "Key #{n}" }
+ end
+end
+++ /dev/null
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-
-one:
- address: 1
- netmask: 1
- k: MyText
- v: MyText
-
-two:
- address: 1
- netmask: 1
- k: MyText
- v: MyText
require "test_helper"
class AclTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- def test_truth
- assert true
+ def test_k_required
+ acl = create(:acl)
+ assert acl.valid?
+ acl.k = nil
+ assert !acl.valid?
+ end
+
+ def test_no_account_creation_by_subnet
+ assert !Acl.no_account_creation("192.168.1.1")
+ create(:acl, :address => "192.168.0.0/16", :k => "no_account_creation")
+ assert Acl.no_account_creation("192.168.1.1")
+ end
+
+ def test_no_account_creation_by_domain
+ assert !Acl.no_account_creation("192.168.1.1", "example.com")
+ create(:acl, :domain => "example.com", :k => "no_account_creation")
+ assert Acl.no_account_creation("192.168.1.1", "example.com")
end
end