repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/rrsig.rb | app/models/rrsig.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = DNSSEC signature Record (RRSIG)
#
# The RRSIG RR is part of the DNSSEC (DNSSEC.bis) standard. Each RRset in a
# signed zone will have an RRSIG RR containing a digest of the RRset created
# using a DNSKEY RR Zone Signing Key (ZSK). RRSIG RRs are unique in that they do
# not form RRsets - were this not so recursive signing would occur! RRSIG RRs
# are automatically created using the dnssec-signzone utility supplied with
# BIND.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/rrsig.html
class RRSIG < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::RRSIG
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/ds.rb | app/models/ds.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = DS Record (DS)
#
# The Delegated Signer RR is part of the DNSSEC (DNSSEC.bis) standard. It
# appears at the point of delegation in the parent zone and contains a digest of
# the DNSKEY RR used as either a Zone Signing Key (ZSK) or a Key Signing Key
# (KSK). It is used to authenticate the chain of trust from the parent to the
# child zone. The DS RR is optionally created using the dnssec-signzone utility
# supplied with BIND.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/ds.html
class DS < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::DS
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/auth_token.rb | app/models/auth_token.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Authentication tokens are used to give someone temporary access to a single
# domain for editing. An authentication token controls the permissions the token
# holder has.
#
# A token has a default permission, either allow or deny, and then specifies
# additional restrictions/relaxations towards specific RR's in the domain.
#
# TODO: Document this
#
class AuthToken < ActiveRecord::Base
class Denied < ::Exception
end
belongs_to :domain
belongs_to :user
validates_presence_of :domain_id, :user_id, :token, :expires_at, :permissions
validate :ensure_future_expiry!
serialize :permissions
after_initialize :set_defaults
class << self
# Generate a random 16 character token
def token
chars = ("a".."z").to_a + ("1".."9").to_a
Array.new( 16, '' ).collect{ chars[ rand(chars.size) ] }.join
end
def authenticate( token )
t = find_by_token( token )
unless t.nil? || t.expires_at < Time.now
return t
end
end
end
def set_defaults #:nodoc:
# Ensure uniqueness
t = self.class.token
while self.class.count( :conditions => ['token = ?', t] ) > 1
t = self.class.token
end
self.token = t
# Default policies
self.permissions = {
'policy' => 'deny',
'new' => false,
'remove' => false,
'allowed' => [],
'protected' => [],
'protected_types' => []
} if self.permissions.blank?
end
# Set the default policy of the token
def policy=( val )
val = val.to_s
raise "Invalid policy" unless val == "allow" || val == "deny"
self.permissions['policy'] = val
end
# Return the default policy
def policy
self.permissions['policy'].to_sym
end
# Are new RR's allowed (defaults to +false+)
def allow_new_records?
self.permissions['new']
end
def allow_new_records=( bool )
self.permissions['new'] = bool
end
# Can RR's be removed (defaults to +false+)
def remove_records?
self.permissions['remove']
end
def remove_records=( bool )
self.permissions['remove'] = bool
end
# Allow the change of the specific RR. Can take an instance of #Record or just
# the name of the RR (with/without the domain name)
def can_change( record, type = '*' )
name, type = get_name_and_type_from_param( record, type )
self.permissions['allowed'] << [ name, type ]
end
# Protect the RR from change. Can take an instance of #Record or just the name
# of the RR (with/without the domain name)
def protect( record, type = '*' )
name, type = get_name_and_type_from_param( record, type )
self.permissions['protected'] << [ name, type ]
end
# Protect all RR's of the provided type
def protect_type( type )
self.permissions['protected_types'] << type.to_s
end
# Walk the permission tree to see if the record can be changed. Can take an
# instance of #Record, or just the name of the RR (with/without the domain
# name)
def can_change?( record, type = '*' )
name, type = get_name_and_type_from_param( record, type )
# NS records?
return false if type == 'NS' || type == 'SOA'
# Type protected?
return false if self.permissions['protected_types'].include?( type )
# RR protected?
return false if self.permissions['protected'].detect do |r|
r[0] == name && (r[1] == type || r[1] == '*' || type == '*')
end
# Allowed?
return true if self.permissions['allowed'].detect do |r|
r[0] == name && (r[1] == type || r[1] == '*' || type == '*')
end
# Default policy
return self.permissions['policy'] == 'allow'
end
# Walk the permission tree to see if the record can be removed. Can take an
# instance of #Record, or just the name of the RR (with/without the domain
# name)
def can_remove?( record, type = '*' )
return false unless can_change?( record, type )
return false if !remove_records?
true
end
# Can this record be added?
def can_add?( record, type = '*' )
return false unless can_change?( record, type )
return false if !allow_new_records?
true
end
# If the user can add new records, this will return a string array of the new
# RR types the user can add
def new_types
return [] unless allow_new_records?
# build our list
Record.record_types - %w{ SOA NS } - self.permissions['protected_types']
end
# Force the token to expire
def expire
update_attribute :expires_at, 1.minute.ago
end
def expired?
self.expires_at <= Time.now
end
# A token can only have the token role...
def has_role?( role_in_question )
role_in_question == 'token'
end
private
def get_name_and_type_from_param( record, type = nil )
name, type =
case record
when Record
[ record.name, record.class.to_s ]
else
type = type.nil? ? '*' : type
[ record, type ]
end
name += '.' + self.domain.name unless self.domain.nil? || name =~ /#{self.domain.name}$/
name.gsub!(/^\./,'') # Strip leading dots off
return name, type
end
def ensure_future_expiry! #:nodoc:
if self.expires_at && self.expires_at <= Time.now
errors.add(:expires_at, I18n.t(:message_domain_expiry_error))
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/ta.rb | app/models/ta.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = DNS Trust Authorities Record (TA)
#
# Part of a deployment proposal for DNSSEC without a signed DNS root. See
# the IANA database and Weiler Spec for details. Uses the same format as the DS
# record.
class TA < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::TA
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/cname.rb | app/models/cname.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = Canonical Name Record (CNAME)
#
# A CNAME record maps an alias or nickname to the real or Canonical name which
# may lie outside the current zone. Canonical means expected or real name.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/cname.html
class CNAME < Record
include RecordPatterns
validates_with HostnameValidator, :attributes => :content
def resolv_resource_class
Resolv::DNS::Resource::IN::CNAME
end
def match_resolv_resource(resource)
resource.name.to_s == self.content.chomp('.') ||
resource.name.to_s == (self.content + '.' + self.domain.name)
end
def validate_name_format
unless self.generate? || self.name.blank? || self.name == '@' || hostname?(self.name.gsub(/(^[*]\.)/,"")) || reverse_ipv4_fragment?(self.name) || reverse_ipv6_fragment?(self.name)
self.errors.add(:name, I18n.t('invalid', :scope => 'activerecord.errors.messages'))
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/tsig.rb | app/models/tsig.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = Transaction Signature Record (TSIG)
#
# Can be used to authenticate dynamic updates as coming from an approved client,
# or to authenticate responses as coming from an approved recursive name
# server[10] similar to DNSSEC.
class TSIG < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::TSIG
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/nsec.rb | app/models/nsec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = Next-secure Record (NSEC)
#
# The NSEC RR is part of the DNSSEC (DNSSEC.bis) standard. The NSEC RR points to
# the next valid name in the zone file and is used to provide proof of
# non-existense of any name within a zone. The last NSEC in a zone will point
# back to the zone root or apex. NSEC RRs are created using the dnssec-signzone
# utility supplied with BIND.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/nsec.html
class NSEC < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::NSEC
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/mx.rb | app/models/mx.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# See #MX
# = Mail Exchange Record (MX)
# Defined in RFC 1035. Specifies the name and relative preference of mail
# servers (mail exchangers in the DNS jargon) for the zone.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/mx.html
#
class MX < Record
validates_numericality_of :prio, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 65535, :only_integer => true
validates_with HostnameValidator, :attributes => :content
validation_scope :warnings do |scope|
scope.validate :validate_same_name_and_type # validation_scopes doesn't support inheritance; we have to redefine this validation
scope.validate :validate_indirect_local_cname
end
def supports_prio?
true
end
def resolv_resource_class
Resolv::DNS::Resource::IN::MX
end
def match_resolv_resource(resource)
resource.preference == self.prio &&
(resource.exchange.to_s == self.content.chomp('.') ||
resource.exchange.to_s == (self.content + '.' + self.domain.name))
end
def validate_indirect_local_cname
return if self.fqdn_content?
cname = CNAME.where('domain_id' => self.domain_id, 'name' => self.content).first
unless cname.nil? || cname.fqdn_content?
self.warnings.add(:base, I18n.t('indirect_local_cname_mx', :scope => 'activerecord.errors.messages', :name => self.content, :replacement => cname.content))
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/loc.rb | app/models/loc.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# See #LOC
# = Name Server Record (LOC)
#
# In the Domain Name System, a LOC record (RFC 1876) is a means for expressing
# geographic location information for a domain name.
# It contains WGS84 Latitude, Longitude and Altitude information together with
# host/subnet physical size and location accuracy. This information can be
# queried by other computers connected to the Internet.
#
# Obtained from http://en.wikipedia.org/wiki/LOC_record
#
class LOC < Record
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/schedule.rb | app/models/schedule.rb | class Schedule < ActiveRecord::Base
attr_accessible :name, :date
def self.get name
Schedule.where(:name => name).first_or_create
end
def self.run_exclusive name
s = Schedule.where(:name => name).first_or_create
s.with_lock do
ret = yield s
s.save
return ret
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/cert.rb | app/models/cert.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# = Certificate Record (CERT)
#
# Stores PKIX, SPKI, PGP, etc.
class CERT < Record
def resolv_resource_class
Resolv::DNS::Resource::IN::CERT
end
def match_resolv_resource(resource)
resource.strings.join(' ') == self.content.chomp('.')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/models/user.rb | app/models/user.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'bcrypt'
require 'digest/sha1'
class User < ActiveRecord::Base
if GloboDns::Application.config.omniauth
validates :email, presence: true, uniqueness: true
devise :omniauthable, :omniauth_providers => [:oauth_provider]
else
before_save :ensure_authentication_token
devise :database_authenticatable, :rememberable, :validatable, :encryptable, :encryptor => :restful_authentication_sha1
end
attr_accessible :login, :email, :role, :active, :password, :password_confirmation, :oauth_token, :oauth_expires_at, :uid, :password_salt, :provider
ROLES = define_enum(:role, [:ADMIN, :OPERATOR, :VIEWER])
def self.from_api(auth)
user = User.where(uid: auth['id']).first
if user.nil?
user = User.new({
active: false,
uid: auth['id'],
email: 'api@example.com',
login: auth['name'],
password: Devise.friendly_token[0,20],
provider: :oauth_provider,
oauth_token: auth['token'],
oauth_expires_at: Time.now + 5.minutes,
role: "O"
})
user.save!
else
user.update_attributes({
login: auth['name'],
password: Devise.friendly_token[0,20],
oauth_token: auth['token'],
oauth_expires_at: Time.now + 5.minutes
})
end
user
end
def self.from_omniauth(auth)
user = User.where(email: auth.info.email).first
if user.nil? # Doesnt exist yet. Lets create it
user = User.new({
active: false,
uid: auth.uid,
email: auth.info.email,
login: auth.info.name,
password: Devise.friendly_token[0,20],
provider: :oauth_provider,
oauth_token: auth.credentials.token,
oauth_expires_at: Time.at(auth.credentials.expires_at),
role: "O"
})
user.save!
else # Already created. lets update it
user.update_attributes({
uid: auth.uid,
email: auth.info.email,
login: auth.info.name,
password: Devise.friendly_token[0,20],
oauth_token: auth.credentials.token,
oauth_expires_at: Time.at(auth.credentials.expires_at)
})
end
user
end
def ensure_authentication_token
if authentication_token.blank?
self.authentication_token = generate_authentication_token
end
end
def auth_json
self.to_json(:root => false, :only => [:id, :authentication_token])
end
def valid_password?(password, pepper = Devise.pepper, salt = self.password_salt)
digest = pepper
valid = false
for i in 0..Devise.stretches-1
digest = Digest::SHA1.hexdigest([digest, salt, password, pepper].flatten.join('--'))
valid = true if digest == self.encrypted_password
# puts digest
end
return valid
end
protected
def persist_audits
quoted_login = ActiveRecord::Base.connection.quote(self.login)
Audit.update_all(
"username = #{quoted_login}",
[ 'user_type = ? AND user_id = ?', self.class.name, self.id ]
)
end
private
def generate_authentication_token
loop do
token = Devise.friendly_token
break token unless User.where(authentication_token: token).first
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/app/mailers/notifier.rb | app/mailers/notifier.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Notifier < ActionMailer::Base
default :from => "GloboDNS <globodns@globodns.com>",
:to => GloboDns::Config::MAIL_RECIPIENTS
def import_successful(message_body)
@message_body = message_body
mail(:subject => I18n.t(:mail_subject_import_successful, :dns_group => GloboDns::Config::DNS_GROUP ,:env => Rails.env ))
end
def import_failed(message_body)
@message_body = message_body
mail(:subject => I18n.t(:mail_subject_import_failed, :dns_group => GloboDns::Config::DNS_GROUP ,:env => Rails.env ))
end
def export_successful(message_body)
@message_body = message_body
mail(:subject => I18n.t(:mail_subject_export_successful, :dns_group => GloboDns::Config::DNS_GROUP ,:env => Rails.env ))
end
def export_failed(message_body)
@message_body = message_body
mail(:subject => I18n.t(:mail_subject_export_failed, :dns_group => GloboDns::Config::DNS_GROUP ,:env => Rails.env ))
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/stories/helper.rb | stories/helper.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter' | ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/stories/all.rb | stories/all.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end | ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/seeds.rb | db/seeds.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if GloboDns::Application.config.omniauth
# configure default user admin from the oauth provider
ADMIN_USER = 'api@example.com'
user = User.find_by_email(ADMIN_USER) || User.new(:email => ADMIN_USER)
user.role = "A"
user.save
puts <<-EOF
-------------------------------------------------------------------------------
Congratulations on setting up your GloboDns on Rails database.
If '#{ADMIN_USER}' isn't your admin's email for omniauth provider, please change it ('ADMIN_USER') at file 'db/seeds.rb'.
Thanks for trying out GloboDns
-------------------------------------------------------------------------------
EOF
else
# default user admin
FIRST_USER = 'admin@example.com'
FIRST_PASS = 'password'
# Create our admin user
user = User.find_by_email(FIRST_USER) || User.new(:email => FIRST_USER)
user.name = 'admin' # not used anymore
user.password = FIRST_PASS
user.password_confirmation = FIRST_PASS
user.role = User::ADMIN
user.save!
puts <<-EOF
-------------------------------------------------------------------------------
Congratulations on setting up your GloboDns on Rails database. You can now
start the server by running the command below, and then pointing your browser
to http://localhost:3000/
$ ./script/rails s
You can then login with "#{FIRST_USER}" using the password "#{FIRST_PASS}".
Thanks for trying out GloboDns
-------------------------------------------------------------------------------
EOF
end
if Rails.env == "development"
# Create an example doman template
domain_template = DomainTemplate.find_by_name('Example Template') || DomainTemplate.new(:name => 'Example Template')
domain_template.ttl = '86400'
domain_template.soa_record_template.primary_ns = 'ns1.%ZONE%'
domain_template.soa_record_template.contact = 'globodns.globoi.com'
domain_template.soa_record_template.refresh = '10800'
domain_template.soa_record_template.retry = '7200'
domain_template.soa_record_template.expire = '604800'
domain_template.soa_record_template.minimum = '10800'
domain_template.soa_record_template.ttl = '86400'
domain_template.save!
# Clean and re-populate the domain template
domain_template.record_templates.where('type != ?', 'SOA').destroy_all
# NS records
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'NS',
:name => '@',
:content => 'ns1.%ZONE%',
:ttl => 86400
})
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'NS',
:name => '@',
:content => 'ns2.%ZONE%',
:ttl => 86400
})
# Assorted A records
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'A',
:name => 'ns1',
:content => '10.0.0.1',
:ttl => 86400
})
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'A',
:name => 'ns2',
:content => '10.0.0.2',
:ttl => 86400
})
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'A',
:name => 'host1',
:content => '10.0.0.3',
:ttl => 86400
})
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'A',
:name => 'mail',
:content => '10.0.0.4',
:ttl => 86400
})
RecordTemplate.create!({
:domain_template => domain_template,
:type => 'MX',
:name => '@',
:content => 'mail',
:prio => 10,
:ttl => 86400
})
# And add our example.com records
# domain = Domain.find_by_name('example.com') || Domain.new(:name => 'example.com')
# domain.ttl = 84600
# domain.type = 'MASTER'
# domain.primary_ns = 'ns1.example.com'
# domain.contact = 'admin@example.com'
# domain.refresh = 10800
# domain.retry = 7200
# domain.expire = 604800
# domain.minimum = 10800
# domain.save!
#
# # Clear the records and start fresh
# domain.records_without_soa.each(&:destroy)
#
# # NS records
# NS.create!({
# :domain => domain,
# :name => '@',
# :content => 'ns1.%ZONE%'
# })
# NS.create!({
# :domain => domain,
# :name => '@',
# :content => 'ns2.%ZONE%'
# })
#
# # Assorted A records
# A.create!({
# :domain => domain,
# :name => 'ns1',
# :content => '10.0.0.1'
# })
# A.create!({
# :domain => domain,
# :name => 'ns2',
# :content => '10.0.0.2'
# })
# A.create!({
# :domain => domain,
# :name => '@',
# :content => '10.0.0.3'
# })
# A.create!({
# :domain => domain,
# :name => 'mail',
# :content => '10.0.0.4'
# })
# MX.create!({
# :domain => domain,
# :name => '@',
# :type => 'MX',
# :content => 'mail',
# :prio => 10
# })
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/schema.rb | db/schema.rb | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180619122648) do
create_table "audits", force: :cascade do |t|
t.integer "auditable_id", limit: 4
t.string "auditable_type", limit: 255
t.integer "associated_id", limit: 4
t.string "associated_type", limit: 255
t.integer "user_id", limit: 4
t.string "user_type", limit: 255
t.string "username", limit: 255
t.string "action", limit: 255
t.text "audited_changes", limit: 65535
t.integer "version", limit: 4, default: 0
t.string "comment", limit: 255
t.string "remote_address", limit: 255
t.datetime "created_at"
t.string "request_uuid", limit: 255
end
add_index "audits", ["associated_id", "associated_type"], name: "associated_index", using: :btree
add_index "audits", ["auditable_id", "auditable_type"], name: "auditable_index", using: :btree
add_index "audits", ["created_at"], name: "index_audits_on_created_at", using: :btree
add_index "audits", ["request_uuid"], name: "index_audits_on_request_uuid", using: :btree
add_index "audits", ["user_id", "user_type"], name: "user_index", using: :btree
add_index "audits", ["user_id"], name: "fk_audits_users1", using: :btree
create_table "caas", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "domain_templates", force: :cascade do |t|
t.string "name", limit: 255
t.string "ttl", limit: 255, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "view_id", limit: 4
end
add_index "domain_templates", ["view_id"], name: "fk_domain_templates_views2", using: :btree
create_table "domains", force: :cascade do |t|
t.integer "user_id", limit: 4
t.string "name", limit: 255
t.string "master", limit: 255
t.integer "last_check", limit: 4
t.integer "notified_serial", limit: 4
t.string "account", limit: 255
t.string "ttl", limit: 255
t.text "notes", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
t.string "authority_type", limit: 1, null: false
t.string "addressing_type", limit: 1, null: false
t.integer "view_id", limit: 4
t.integer "sibling_id", limit: 4
t.string "export_to", limit: 255
end
add_index "domains", ["name"], name: "index_domains_on_name", using: :btree
add_index "domains", ["user_id"], name: "fk_domains_users2", using: :btree
add_index "domains", ["view_id"], name: "fk_domains_views2", using: :btree
create_table "record_templates", force: :cascade do |t|
t.integer "domain_template_id", limit: 4
t.string "name", limit: 255
t.string "type", limit: 255, null: false
t.string "content", limit: 4096, null: false
t.string "ttl", limit: 255
t.integer "prio", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
t.integer "weight", limit: 4
t.integer "port", limit: 4
t.string "tag", limit: 255
end
add_index "record_templates", ["domain_template_id"], name: "fk_record_templates_domain_templates2", using: :btree
create_table "records", force: :cascade do |t|
t.integer "domain_id", limit: 4, null: false
t.string "name", limit: 255, null: false
t.string "type", limit: 255, null: false
t.string "content", limit: 4096, null: false
t.string "ttl", limit: 255
t.integer "prio", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
t.integer "weight", limit: 4
t.integer "port", limit: 4
t.string "tag", limit: 255
t.boolean "generate"
t.string "range", limit: 255
end
add_index "records", ["domain_id"], name: "fk_records_domains2", using: :btree
add_index "records", ["domain_id"], name: "index_records_on_domain_id", using: :btree
add_index "records", ["name", "type"], name: "index_records_on_name_and_type", using: :btree
add_index "records", ["name"], name: "index_records_on_name", using: :btree
create_table "schedules", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.datetime "date"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "schedules", ["name"], name: "index_schedules_on_name", unique: true, using: :btree
create_table "users", force: :cascade do |t|
t.string "login", limit: 255
t.string "email", limit: 255
t.string "encrypted_password", limit: 255
t.string "password_salt", limit: 255
t.string "role", limit: 1
t.string "authentication_token", limit: 255
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "active", default: true
t.string "name", limit: 255
t.string "oauth_token", limit: 255
t.datetime "oauth_expires_at"
t.string "uid", limit: 255
t.string "password", limit: 255, default: "password"
t.string "provider", limit: 255
end
create_table "views", force: :cascade do |t|
t.string "name", limit: 32, null: false
t.string "clients", limit: 1024
t.string "destinations", limit: 1024
t.datetime "created_at"
t.datetime "updated_at"
t.string "key", limit: 64
end
add_foreign_key "domain_templates", "views", name: "fk_domain_templates_views1"
add_foreign_key "domains", "users", name: "fk_domains_users"
add_foreign_key "domains", "views", name: "fk_domains_views1"
add_foreign_key "record_templates", "domain_templates", name: "fk_record_templates_domain_templates1"
add_foreign_key "records", "domains", name: "fk_records_domains1"
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20180830191058_create_acls.rb | db/migrate/20180830191058_create_acls.rb | class CreateAcls < ActiveRecord::Migration
def change
create_table :acls do |t|
t.timestamps null: false
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20130219183739_fix_record_templates_attributes.rb | db/migrate/20130219183739_fix_record_templates_attributes.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class FixRecordTemplatesAttributes < ActiveRecord::Migration
def up
change_table 'record_templates' do |t|
t.rename 'record_type', 'type'
t.change 'content', :string, :limit => 4096, :null => false
t.change 'ttl', :string, :null => true
end
end
def down
change_table 'record_templates' do |t|
t.rename 'type', 'record_type'
t.change 'content', :string, :limit => 255, :null => false
t.change 'ttl', :string, :null => false
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20150105051755_add_sibling_id_to_domains.rb | db/migrate/20150105051755_add_sibling_id_to_domains.rb | class AddSiblingIdToDomains < ActiveRecord::Migration
def change
add_column :domains, :sibling_id, :integer, index: true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120405120000_create_audits.rb | db/migrate/20120405120000_create_audits.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateAudits < ActiveRecord::Migration
def self.up
create_table :audits, :force => true do |t|
t.integer :auditable_id
t.string :auditable_type
t.integer :associated_id
t.string :associated_type
t.integer :user_id
t.string :user_type
t.string :username
t.string :action
t.text :audited_changes
t.integer :version, :default => 0
t.string :comment
t.string :remote_address
t.datetime :created_at
end
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
add_index :audits, [:user_id, :user_type], :name => 'user_index'
add_index :audits, :created_at
end
def self.down
drop_table :audits
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160609132503_add_name_to_users.rb | db/migrate/20160609132503_add_name_to_users.rb | class AddNameToUsers < ActiveRecord::Migration
def change
add_column :users, :name, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20180619122648_add_export_to_to_domain.rb | db/migrate/20180619122648_add_export_to_to_domain.rb | class AddExportToToDomain < ActiveRecord::Migration
def change
add_column :domains, :export_to, :string, array: true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20190130182510_change_token.rb | db/migrate/20190130182510_change_token.rb | class ChangeToken < ActiveRecord::Migration
def change
change_column :users, :oauth_token, :text
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160609143554_add_oauth_expires_at_to_users.rb | db/migrate/20160609143554_add_oauth_expires_at_to_users.rb | class AddOauthExpiresAtToUsers < ActiveRecord::Migration
def change
add_column :users, :oauth_expires_at, :datetime
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120619223235_increase_length_records_content.rb | db/migrate/20120619223235_increase_length_records_content.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class IncreaseLengthRecordsContent < ActiveRecord::Migration
def up
change_table 'records' do |t|
t.change :content, :string, :null => false, :limit => 4096
end
end
def down
change_table 'records' do |t|
t.change :content, :string, :null => false
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20180522210929_add_range_to_record.rb | db/migrate/20180522210929_add_range_to_record.rb | class AddRangeToRecord < ActiveRecord::Migration
def change
add_column :records, :range, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120402120000_create_records.rb | db/migrate/20120402120000_create_records.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateRecords < ActiveRecord::Migration
def self.up
create_table :records, :force => true do |t|
t.integer :domain_id, :null => false
t.string :name, :null => false
t.string :type, :null => false
t.string :content, :null => false
t.integer :ttl, :null => true
t.integer :prio
t.timestamps
end
add_index :records, :domain_id
add_index :records, :name
add_index :records, [ :name, :type ]
end
def self.down
drop_table :records
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120420202106_set_domain_ttl_as_nullable.rb | db/migrate/20120420202106_set_domain_ttl_as_nullable.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class SetDomainTtlAsNullable < ActiveRecord::Migration
def change
change_table :domains do |t|
t.change :ttl, :integer, :null => true
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120424170903_create_views.rb | db/migrate/20120424170903_create_views.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateViews < ActiveRecord::Migration
def change
create_table :views do |t|
t.string :name, :limit => 32, :null => false
t.string :clients, :limit => 1024
t.string :destinations, :limit => 1024
t.timestamps
end
change_table :domains do |t|
t.integer :view_id, :null => true
end
change_table :domain_templates do |t|
t.integer :view_id, :null => true
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120401120000_create_domains.rb | db/migrate/20120401120000_create_domains.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateDomains < ActiveRecord::Migration
def self.up
create_table :domains, :force => true do |t|
t.integer :user_id
t.string :name
t.string :master
t.integer :last_check
t.string :type, :null => false
t.integer :notified_serial
t.string :account
t.integer :ttl, :null => false
t.text :notes
t.timestamps
end
add_index :domains, :name
end
def self.down
drop_table :domains
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170519182716_add_disabled_to_domain.rb | db/migrate/20170519182716_add_disabled_to_domain.rb | class AddDisabledToDomain < ActiveRecord::Migration
def change
add_column :domains, :disabled, :boolean, :default => false
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20141003232635_create_schedules.rb | db/migrate/20141003232635_create_schedules.rb | class CreateSchedules < ActiveRecord::Migration
def change
create_table :schedules do |t|
t.string :name, :null => false
t.datetime :date
t.timestamps
end
add_index :schedules, :name, unique: true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120913150000_add_foreign_keys.rb | db/migrate/20120913150000_add_foreign_keys.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class AddForeignKeys < ActiveRecord::Migration
def up
execute "ALTER TABLE `audits` ADD
CONSTRAINT `fk_audits_users1`
FOREIGN KEY (`user_id` )
REFERENCES `users` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "CREATE INDEX `fk_audits_users1` ON `audits` (`user_id` ASC)"
execute "ALTER TABLE `domain_templates` ADD
CONSTRAINT `fk_domain_templates_views1`
FOREIGN KEY (`view_id` )
REFERENCES `views` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "CREATE INDEX `fk_domain_templates_views2` ON `domain_templates` (`view_id` ASC)"
execute "ALTER TABLE `domains` ADD
CONSTRAINT `fk_domains_users`
FOREIGN KEY (`user_id` )
REFERENCES `users` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "ALTER TABLE `domains` ADD
CONSTRAINT `fk_domains_views1`
FOREIGN KEY (`view_id` )
REFERENCES `views` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "CREATE INDEX `fk_domains_users2` ON `domains` (`user_id` ASC)"
execute "CREATE INDEX `fk_domains_views2` ON `domains` (`view_id` ASC)"
execute "ALTER TABLE `record_templates` ADD
CONSTRAINT `fk_record_templates_domain_templates1`
FOREIGN KEY (`domain_template_id` )
REFERENCES `domain_templates` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "CREATE INDEX `fk_record_templates_domain_templates2` ON `record_templates` (`domain_template_id` ASC)"
execute "ALTER TABLE `records` ADD
CONSTRAINT `fk_records_domains1`
FOREIGN KEY (`domain_id` )
REFERENCES `domains` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION"
execute "CREATE INDEX `fk_records_domains2` ON `records` (`domain_id` ASC)"
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120404120000_create_users.rb | db/migrate/20120404120000_create_users.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users, :force => true do |t|
t.string :login
t.string :email
t.string :encrypted_password, :limit => 128
t.string :password_salt, :limit => 128
t.string :role, :limit => 1
t.string :authentication_token
t.datetime :remember_created_at
t.timestamps
end
end
def self.down
drop_table :users
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160613182355_add_provider_to_users.rb | db/migrate/20160613182355_add_provider_to_users.rb | class AddProviderToUsers < ActiveRecord::Migration
def change
add_column :users, :provider, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120523202405_add_query_ip_address_to_views.rb | db/migrate/20120523202405_add_query_ip_address_to_views.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class AddQueryIpAddressToViews < ActiveRecord::Migration
def change
add_column 'views', 'query_ip_address', :string, :limit => 256
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20180522210447_add_generate_to_record.rb | db/migrate/20180522210447_add_generate_to_record.rb | class AddGenerateToRecord < ActiveRecord::Migration
def change
add_column :records, :generate, :boolean
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170207113243_add_weight_and_port_to_record_template.rb | db/migrate/20170207113243_add_weight_and_port_to_record_template.rb | class AddWeightAndPortToRecordTemplate < ActiveRecord::Migration
def change
add_column :record_templates, :weight, :integer
add_column :record_templates, :port, :integer
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170206161214_add_weight_and_port_to_records.rb | db/migrate/20170206161214_add_weight_and_port_to_records.rb | class AddWeightAndPortToRecords < ActiveRecord::Migration
def change
add_column :records, :weight, :integer
add_column :records, :port, :integer
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120403120000_create_templates.rb | db/migrate/20120403120000_create_templates.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CreateTemplates < ActiveRecord::Migration
def self.up
create_table :domain_templates do |t|
t.string :name
t.integer :ttl, :null => false
t.timestamps
end
create_table :record_templates do |t|
t.integer :domain_template_id
t.string :name
t.string :record_type, :null => false
t.string :content, :null => false
t.integer :ttl, :null => false
t.integer :prio
t.timestamps
end
end
def self.down
drop_table :domain_templates
drop_table :record_templates
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160613182510_change_password_salt_null.rb | db/migrate/20160613182510_change_password_salt_null.rb | class ChangePasswordSaltNull < ActiveRecord::Migration
def change
change_column :users, :password_salt, :string, :null => true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160609162420_add_uid_to_users.rb | db/migrate/20160609162420_add_uid_to_users.rb | class AddUidToUsers < ActiveRecord::Migration
def change
add_column :users, :uid, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160613181936_add_password_to_users.rb | db/migrate/20160613181936_add_password_to_users.rb | class AddPasswordToUsers < ActiveRecord::Migration
def change
add_column :users, :password, :string, :default => "password"
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160413212730_add_request_uuid_to_audits.rb | db/migrate/20160413212730_add_request_uuid_to_audits.rb | class AddRequestUuidToAudits < ActiveRecord::Migration
def self.up
add_column :audits, :request_uuid, :string
add_index :audits, :request_uuid
end
def self.down
remove_column :audits, :request_uuid
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160609143530_add_oauth_token_to_users.rb | db/migrate/20160609143530_add_oauth_token_to_users.rb | class AddOauthTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :oauth_token, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170622175729_remove_disabled_from_domain.rb | db/migrate/20170622175729_remove_disabled_from_domain.rb | class RemoveDisabledFromDomain < ActiveRecord::Migration
def change
remove_column :domains, :disabled
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120525183452_convert_bind_time_values_to_string.rb | db/migrate/20120525183452_convert_bind_time_values_to_string.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class ConvertBindTimeValuesToString < ActiveRecord::Migration
def up
change_column 'domains', 'ttl', :string, :length => 64
change_column 'records', 'ttl', :string, :length => 64
change_column 'domain_templates', 'ttl', :string, :length => 64
change_column 'record_templates', 'ttl', :string, :length => 64
end
def down
change_column 'domains', 'ttl', :integer
change_column 'records', 'ttl', :integer
change_column 'domain_templates', 'ttl', :integer
change_column 'record_templates', 'ttl', :integer
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120528162942_rename_query_ip_address_to_key.rb | db/migrate/20120528162942_rename_query_ip_address_to_key.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class RenameQueryIpAddressToKey < ActiveRecord::Migration
def up
remove_column 'views', 'query_ip_address'
add_column 'views', 'key', :string, :limit => 64
end
def down
remove_column 'views', 'key'
add_column 'views', 'query_ip_address', :string, :limit => 256
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160608205545_add_active_to_user.rb | db/migrate/20160608205545_add_active_to_user.rb | class AddActiveToUser < ActiveRecord::Migration
def change
add_column :users, :active, :boolean, default: true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20120420171552_add_addressing_type_to_domains.rb | db/migrate/20120420171552_add_addressing_type_to_domains.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class AddAddressingTypeToDomains < ActiveRecord::Migration
def change
change_table :domains do |t|
t.remove :type
t.column :authority_type, 'CHAR(1)', :null => false
t.column :addressing_type, 'CHAR(1)', :null => false
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20160613182452_change_encrypted_password_null.rb | db/migrate/20160613182452_change_encrypted_password_null.rb | class ChangeEncryptedPasswordNull < ActiveRecord::Migration
def change
change_column :users, :encrypted_password, :string, :null => true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170509142358_create_caas.rb | db/migrate/20170509142358_create_caas.rb | class CreateCaas < ActiveRecord::Migration
def change
create_table :caas do |t|
t.timestamps null: false
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170509195431_add_tag_to_record.rb | db/migrate/20170509195431_add_tag_to_record.rb | class AddTagToRecord < ActiveRecord::Migration
def change
add_column :records, :tag, :string
add_column :record_templates, :tag, :string
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/db/migrate/20170207122634_fix_srv_record_attributes.rb | db/migrate/20170207122634_fix_srv_record_attributes.rb | class FixSrvRecordAttributes < ActiveRecord::Migration
def change
records = Record.where(type: "SRV")
records.each do |record|
if record.prio.nil? or record.weight.nil? or record.port.nil? and !record.content.nil?
puts record
srv_attr = record.content.split
record.prio = srv_attr[0]
record.weight = srv_attr[1]
record.port = srv_attr[2]
record.content = srv_attr[3]
record.save
end
end
recordtemplates = RecordTemplate.where(type: "SRV")
recordtemplates.each do |recordtemplate|
if recordtemplate.prio.nil? or recordtemplate.weight.nil? or recordtemplate.port.nil? and !recordtemplate.content.nil?
puts recordtemplate
srv_attr = recordtemplate.content.split
recordtemplate.prio = srv_attr[0]
recordtemplate.weight = srv_attr[1]
recordtemplate.port = srv_attr[2]
recordtemplate.content = srv_attr[3]
recordtemplate.save
end
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/autotest/discover.rb | autotest/discover.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/test_helper.rb | test/test_helper.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
# tconsole requires the 'minitest' gem, which in turn, prints an anoying
# warning due to this constant being deprecated (but it is referenced by
# Ruby's version of minitest)
MiniTest::MINI_DIR = 'bad value'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/controllers/access_denied_controller_test.rb | test/controllers/access_denied_controller_test.rb | require 'test_helper'
class AccessDeniedControllerTest < ActionController::TestCase
test "should get new" do
get :new
assert_response :success
end
test "should get create" do
get :create
assert_response :success
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/models/acl_test.rb | test/models/acl_test.rb | require 'test_helper'
class AclTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/performance/browsing_test.rb | test/performance/browsing_test.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'test_helper'
require 'rails/performance_test_help'
# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionDispatch::PerformanceTest
def test_homepage
get '/'
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/unit/schedule_test.rb | test/unit/schedule_test.rb | require 'test_helper'
class ScheduleTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/unit/exporter_test.rb | test/unit/exporter_test.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'test_helper'
class ExporterTest < ActiveSupport::TestCase
include GloboDns::Config
include GloboDns::Util
def setup
Dir.chdir(Rails.root.join('test'))
@exporter = GloboDns::Exporter.new
@options = { :logger => Logger.new(@log_io = StringIO.new('')), :keep_tmp_dir => true, :lock_tables => false }
set_now Time.local(2012, 3, 1, 12, 0, 0)
# manually set timestamps of existing records to 'before' the initial export date
yesterday = Time.now - 1.day
assert View.update_all({'created_at' => yesterday, 'updated_at' => yesterday}).is_a?(Numeric)
assert Domain.update_all({'created_at' => yesterday, 'updated_at' => yesterday}).is_a?(Numeric)
assert Record.update_all({'created_at' => yesterday, 'updated_at' => yesterday}).is_a?(Numeric)
create_mock_repository
end
def teardown(*args)
unless self.passed?
puts "[DEBUG] exporter log:"
puts @log_io.string
puts
end
end
test 'initial' do
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'initial'))
end
test 'serial' do
export
# update a few records and domains
set_now Time.local(2012, 3, 2, 12, 0, 0)
assert records(:dom1_ns).touch
assert records(:dom1_cname2).touch
assert records(:dom2_soa).update_attribute('minimum', 7212)
assert domains(:dom5).update_attribute('ttl', 86415)
assert views(:view1).touch
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'serial1'))
# update the time stamp to a few hours later so that we're still in the same day;
set_now Time.local(2012, 3, 2, 18, 0, 0)
assert records(:dom1_a1).touch
assert records(:dom1_cname1).update_attribute('name', 'host1cname')
assert records(:dom3_ns).update_attribute('content', 'updated-ns3.example.com.')
assert domains(:dom4).touch
assert domains(:view1_dom2).update_attribute('ttl', 86422)
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'serial2'))
end
test 'create domain' do
export
set_now Time.local(2012, 3, 2, 12, 0, 0)
# master
assert (master = Domain.new(:name => 'domain7.example.com', :authority_type => Domain::MASTER, :ttl => 86407, :primary_ns => 'ns7.example.com.', :contact => 'root7.example.com.', :refresh => 10807, :retry => 3607, :expire => 604807, :minimum => 7207)).save
assert master.ns_records.new(:name => '@', :content => 'ns').save
assert master.mx_records.new(:name => '@', :content => 'mail', :prio => 17).save
assert master.a_records.new(:name => 'ns', :content => '10.0.7.1').save
assert master.a_records.new(:name => 'mail', :content => '10.0.7.2').save
assert master.a_records.new(:name => 'host1', :content => '10.0.7.3').save
assert master.a_records.new(:name => 'host2', :content => '10.0.7.4').save
assert master.a_records.new(:name => 'host2other', :content => '10.0.7.4').save
assert master.cname_records.new(:name => 'host1alias', :content => 'host1').save
assert master.cname_records.new(:name => 'host2alias', :content => 'host2.domain7.example.com.').save
assert master.txt_records.new(:name => 'txt', :ttl => 86417, :content => 'sample content for txt record').save
# slave
assert Domain.new(:name => 'domain8.example.com', :authority_type => Domain::SLAVE, :master => '10.0.8.1', :ttl => 86408).save
# reverse
assert (new_reverse = Domain.new(:name => '7.0.10.in-addr.arpa', :authority_type => Domain::MASTER, :ttl => 86407, :primary_ns => 'ns7.example.com.', :contact => 'root7.example.com.', :refresh => 10807, :retry => 3607, :expire => 604807, :minimum => 7207)).save
assert new_reverse.ns_records.new(:name => '@', :content => 'ns7.example.com.').save
assert new_reverse.ptr_records.new(:name => '1', :content => 'ns.domain7.example.com.').save
assert new_reverse.ptr_records.new(:name => '2', :content => 'mail.domain7.example.com.').save
assert new_reverse.ptr_records.new(:name => '3', :content => 'host1.domain7.example.com.').save
assert new_reverse.ptr_records.new(:name => '4', :content => 'host2.domain7.example.com.').save
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'create_domain'))
end
test 'delete domain' do
export
set_now Time.local(2012, 3, 2, 12, 0, 0)
set_now Time.local(2012, 3, 2, 12, 0, 0)
assert domains(:dom1).destroy
assert domains(:dom6).destroy
assert domains(:rev1).destroy
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'delete_domain'))
end
test 'update_domain' do
export
set_now Time.local(2012, 3, 2, 12, 0, 0)
# create records
assert domains(:dom1).a_records.new(:name => 'new-host3', :ttl => 86411, :content => '10.0.1.5').save
assert domains(:dom3).a_records.new(:name => 'new-host1', :ttl => 86413, :content => '10.0.3.1').save
assert domains(:dom3).cname_records.new(:name => 'new-host1alias', :content => 'new-host1').save
assert domains(:dom3).txt_records.new(:name => 'new-txt', :content => 'meaningless content').save
assert domains(:rev1).ptr_records.new(:name => '5', :content => 'new-host3.domain1.example.com.').save
assert domains(:rev1).ptr_records.new(:name => '6', :content => 'nohost.nowhere.com.').save
# delete records
assert records(:dom1_a2).destroy
assert records(:dom2_mx).destroy
assert records(:dom2_a1).destroy
assert records(:dom2_a2).destroy
# update records
assert records(:dom1_ns).update_attributes(:content => 'new-ns')
assert records(:dom1_mx).update_attributes(:content => 'new-mx', :prio => 21)
assert records(:dom1_a_ns).update_attributes(:name => 'new-ns')
assert records(:dom1_a1).update_attributes(:name => 'new-host1', :ttl => 86421)
assert records(:dom1_cname1).update_attributes(:name => 'new-cname1', :content => 'new-host1')
assert records(:rev1_a_ns).update_attributes(:content => 'new-ns.domain1.example.com.')
assert records(:rev1_a1).update_attributes(:content => 'new-host1.domain1.example.com.')
assert records(:rev1_a2).update_attributes(:content => 'invalid2.domain1.example.com.')
# update domain attributes
assert domains(:dom4).update_attributes(:name => 'new-domain4.example.com')
assert domains(:dom5).update_attributes(:ttl => 86415)
assert domains(:dom6).update_attributes(:master => '10.0.6.2')
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'update_domain'))
end
test 'create view' do
assert (view = View.new(:name => 'viewthree', :clients => '10.0.3.0/24')).save
assert (master = Domain.new(:name => 'domain1.view3.example.com', :view_id => view.id, :authority_type => Domain::MASTER, :ttl => 86413, :primary_ns => 'ns3.example.com.', :contact => 'root3.example.com.', :refresh => 10813, :retry => 3613, :expire => 604813, :minimum => 7213)).save
assert master.ns_records.new(:name => '@', :content => 'ns3.example.com.').save
assert master.a_records.new(:name => 'host1', :content => '10.1.3.1').save
assert master.a_records.new(:name => 'host2', :content => '10.1.3.2').save
assert (reverse = Domain.new(:name => '3.1.10.in-addr.arpa', :view_id => view.id, :authority_type => Domain::MASTER, :ttl => 86414, :primary_ns => 'ns4.example.com.', :contact => 'root4.example.com.', :refresh => 10814, :retry => 3614, :expire => 604814, :minimum => 7214)).save
assert reverse.ns_records.new(:name => '@', :content => 'ns4.example.com.').save
assert reverse.ptr_records.new(:name => '1', :content => 'host1.domain1.view3.example.com.').save
assert reverse.ptr_records.new(:name => '2', :content => 'host2.domain1.view3.example.com.').save
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'create_view'))
end
test 'delete view' do
assert views(:view1).destroy
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'delete_view'))
end
test 'update view' do
view = views(:view1)
assert view.update_attribute('name', 'newviewone')
assert (domain3 = view.domains.new(:name => 'domain3.view1.example.com', :authority_type => Domain::MASTER, :ttl => 86413, :primary_ns => 'ns3.example.com.', :contact => 'root3.example.com.', :refresh => 10813, :retry => 3613, :expire => 604813, :minimum => 7213)).save
assert domain3.ns_records.new(:name => '@', :content => 'ns3.example.com.').save
assert domain3.a_records.new(:name => 'host1', :content => '10.1.3.1').save
assert domain3.a_records.new(:name => 'host2', :content => '10.1.3.2').save
assert (slave4 = view.domains.new(:name => 'domain4.view1.example.com', :authority_type => Domain::SLAVE, :master => '10.1.4.1')).save
assert (reverse3 = view.domains.new(:name => '3.1.10.in-addr.arpa', :authority_type => Domain::MASTER, :ttl => 86413, :primary_ns => 'ns3.example.com.', :contact => 'root3.example.com.', :refresh => 10813, :retry => 3613, :expire => 604813, :minimum => 7213)).save
assert reverse3.ns_records.new(:name => '@', :content => 'ns3.example.com.').save
assert reverse3.ptr_records.new(:name => '1', :content => 'host1.domain3.view1.example.com.').save
assert reverse3.ptr_records.new(:name => '2', :content => 'host2.domain3.view1.example.com.').save
assert domains(:view1_dom2).destroy
domain1 = domains(:view1_dom1)
assert domain1.update_attributes({:name => 'new-domain1.view1.example.com', :ttl => 86421})
assert domain1.a_records.find{|rec| rec.name == 'host2'}.destroy
assert domain1.a_records.find{|rec| rec.name == 'host3'}.update_attributes('name' => 'new-host3')
assert domain1.a_records.new(:name => 'host4', :content => '10.1.1.4').save
assert domain1.mx_records.new(:name => '@', :content => 'host4', :prio => 10).save
export
compare_named_files(File.join(Rails.root, 'test', 'mock', 'named_expected', 'update_view'))
end
private
def export
begin
spawn_named
@exporter.export_all(mock_named_conf_content, @options.merge(:set_timestamp => Time.now))
rescue Exception => e
STDERR.puts "[ERROR] #{e}", e.backtrace.join("\n")
STDERR.puts "[ERROR] named output:", @named_output.read if @named_output
ensure
@named_output.close
@named_input.close
kill_named
end
end
def mock_named_conf_file
@mock_named_conf_file ||= File.join(Rails.root, 'test', 'mock', 'named.conf')
end
def mock_named_conf_content
@mock_named_conf_content ||= IO::read(mock_named_conf_file)
end
def spawn_named
@named_output, @named_input = IO::pipe
@named_pid = spawn(Binaries::SUDO, Binaries::NAMED, '-g', '-p', BIND_PORT, '-f', '-c', BIND_CONFIG_FILE, '-t', BIND_CHROOT_DIR, '-u', BIND_USER, [:out, :err] => @named_input)
end
def kill_named
exec('kill named', Binaries::SUDO, 'kill', @named_pid.to_s)
Process.wait(@named_pid, Process::WNOHANG)
end
def create_mock_repository
named_dir = File.join(BIND_CHROOT_DIR, BIND_CONFIG_DIR)
FileUtils.rm_r(named_dir, :force => true, :secure => true)
FileUtils.mkdir(named_dir)
FileUtils.cp(mock_named_conf_file, named_dir)
Dir.chdir(named_dir) do
timestamp = Time.utc(2012, 1, 1, 0, 0, 0)
exec('git init', Binaries::GIT, 'init')
FileUtils.touch('.keep')
exec('git add .keep', Binaries::GIT, 'add', '.keep')
exec('git status', Binaries::GIT, 'status')
exec('git initial commit', Binaries::GIT, 'commit', "--date=#{timestamp}", '-m', 'Initial commit')
File.utime(timestamp, timestamp, *(Dir.glob('**/*', File::FNM_DOTMATCH).reject{|file| file == '..' || file[-3, 3] == '/..' || file[-2, 2] == '/.' }))
end
end
def compare_named_files(reference_dir)
export_dir = File.join(BIND_CHROOT_DIR, BIND_CONFIG_DIR)
diff_output = exec('diff -r', 'diff', '-r', '-x', '.keep', '-x', '.git', reference_dir, export_dir)
assert diff_output.blank?
end
def change_named_conf
@mock_named_conf_content =
"# starting test comment\n" +
@mock_named_conf_content.sub(/^(logging {)/, "# internal test comment\n\\1").
gsub(/^\s*#.*\n/, '') +
"# ending test comment\n"
end
def set_now(now)
Time.instance_variable_set('@__now', now)
def Time.now
Time.instance_variable_get('@__now')
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/functional/domains_controller_test.rb | test/functional/domains_controller_test.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'test_helper'
class DomainsControllerTest < ActionController::TestCase
include Devise::TestHelpers
def setup
sign_in users(:admin)
end
test 'index' do
get :index
assert_response :success
assert_not_nil assigns(:domains)
end
test 'show' do
get :show, { :id => domains(:dom1).id }
assert_response :success
assert_not_nil assigns(:domain)
assigns(:domain).id == 1
assigns(:domain).name == domains(:dom1).name
assigns(:domain).ttl == domains(:dom1).ttl
end
test 'create' do
params = {
:name => 'created.example.com',
:ttl => 86411,
:authority_type => Domain::MASTER,
:primary_ns => 'nscreated.example.com.',
:contact => 'root.created.example.com.',
:refresh => 10801,
:retry => 3601,
:expire => 604801,
:minimum => 7201
}
xhr :post, :create, { :domain => params }
assert_response :success
assert_not_nil assigns(:domain)
assert_empty assigns(:domain).errors
assert domain = Domain.where('name' => params[:name]).first
assert domain.ttl == params[:ttl].to_s
assert domain.soa_record.primary_ns == params[:primary_ns]
assert domain.soa_record.contact == params[:contact]
assert domain.soa_record.refresh == params[:refresh].to_s
assert domain.soa_record.retry == params[:retry].to_s
assert domain.soa_record.expire == params[:expire].to_s
assert domain.soa_record.minimum == params[:minimum].to_s
assert domain.soa_record.content =~ /#{params[:primary_ns]} #{params[:contact]} 0 #{params[:refresh]} #{params[:retry]} #{params[:expire]} #{params[:minimum]}/
end
test 'update' do
params = {
:name => 'updatedname.example.com',
:ttl => 86402,
:primary_ns => 'updatedns.example.com.',
:contact => 'updatedcontact.created.example.com.',
:refresh => 10802,
:retry => 3602,
:expire => 604802,
:minimum => 7202
}
xhr :put, :update, { :id => domains(:dom1).id, :domain => params }
assert_response :success
assert_not_nil assigns(:domain)
assert_empty assigns(:domain).errors
assert domain = Domain.find(domains(:dom1).id)
assert domain.name == params[:name]
assert domain.ttl == params[:ttl].to_s
assert domain.soa_record.primary_ns == params[:primary_ns]
assert domain.soa_record.contact == params[:contact]
assert domain.soa_record.refresh == params[:refresh].to_s
assert domain.soa_record.retry == params[:retry].to_s
assert domain.soa_record.expire == params[:expire].to_s
assert domain.soa_record.minimum == params[:minimum].to_s
assert domain.soa_record.content =~ /#{params[:primary_ns]} #{params[:contact]} 0 #{params[:refresh]} #{params[:retry]} #{params[:expire]} #{params[:minimum]}/
end
test 'destroy' do
n_domains = Domain.count
delete :destroy, { :id => domains(:dom1).id }
assert_response :redirect
assert_not_nil assigns(:domain)
assert assigns(:domain).id == domains(:dom1).id
assert_raises ActiveRecord::RecordNotFound do Domain.find(domains(:dom1).id); end
assert Domain.count == (n_domains - 1)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/test/functional/records_controller_test.rb | test/functional/records_controller_test.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'test_helper'
class RecordsControllerTest < ActionController::TestCase
include Devise::TestHelpers
def setup
sign_in users(:admin)
end
test 'index' do
n_domains = Domain.find(domains(:dom1)).records.where('type != ?', 'SOA').count
assert n_domains == 8 # with soa
xhr :get, :index, {:domain_id => domains(:dom1).id, :per_page => 99999}
assert_response :success
assert_not_nil assigns(:records)
assert assigns(:records).size == 8
assert_select 'table#record-table tbody tr.show-record', 8
xhr :get, :index, {:domain_id => domains(:dom1).id, :per_page => 5}
assert_response :success
assert_not_nil assigns(:records)
assert assigns(:records).size == 5
assert_select 'table#record-table tbody tr.show-record', 5
xhr :get, :index, {:domain_id => domains(:dom1).id, :per_page => 5, :page => 2}
assert_response :success
assert_not_nil assigns(:records)
assert assigns(:records).size == 3
assert_select 'table#record-table tbody tr.show-record', 3
xhr :get, :index, {:domain_id => domains(:dom1).id, :per_page => 5, :page => 3}
assert_response :success
assert_not_nil assigns(:records)
assert_empty assigns(:records)
assert_select 'table#record-table tbody tr.show-record', 0
end
# test 'show' do
# xhr :get, :show, {:id => records(:dom1).id, :per_page => 99999}
# end
test 'create A' do
n_records = Record.count
params = {
:name => '',
:type => 'A',
:content => '10.0.1.100'
}
xhr :post, :create, { :record => params , :domain_id => domains(:dom1) }
assert_response :unprocessable_entity # no name
assert assigns(:record).errors.keys.include?(:name)
xhr :post, :create, { :record => params.merge!(:name => 'new-a-name'), :domain_id => domains(:dom1) }
assert_response :success
assert_not_nil assigns(:record)
assert_empty assigns(:record).errors
assert_not_nil record = Record.where(:domain_id => domains(:dom1).id, :name => params[:name]).first
assert record.is_a?(A)
assert record.domain == domains(:dom1)
assert record.name == params[:name]
assert record.type == params[:type]
assert record.content == params[:content]
assert_nil record.ttl
assert record.prio.blank?
assert Record.count == (n_records + 1)
end
test 'create MX' do
params = {
:name => 'new-mx',
:type => 'MX',
:content => records(:dom1_a1).name,
:ttl => 86402
}
xhr :post, :create, { :record => params , :domain_id => domains(:dom1) }
assert_response :unprocessable_entity # no prio
assert assigns(:record).errors.keys.include?(:prio)
xhr :post, :create, { :record => params.merge!({:prio => 10}), :domain_id => domains(:dom1) }
assert_response :success
assert_not_nil assigns(:record)
assert_empty assigns(:record).errors
assert_not_nil record = Record.where(:domain_id => domains(:dom1).id, :name => params[:name]).first
assert record.is_a?(MX)
assert record.domain == domains(:dom1)
assert record.name == params[:name]
assert record.type == params[:type]
assert record.content == params[:content]
assert record.ttl == params[:ttl].to_s
assert record.prio == params[:prio]
end
test 'update A' do
params = {
:name => '',
:type => 'A',
:content => '10.0.1.101',
:ttl => 86411
}
xhr :put, :update, { :record => params , :id => records(:dom1_a1) }
assert_response :unprocessable_entity # no name
assert assigns(:record).errors.keys.include?(:name)
xhr :put, :update, { :record => params.merge!(:name => 'new-a-name') , :id => records(:dom1_a1) }
assert_response :success
assert_not_nil assigns(:record)
assert_empty assigns(:record).errors
assert_not_nil record = Record.find(records(:dom1_a1))
assert record.is_a?(A)
assert record.domain == domains(:dom1)
assert record.name == params[:name]
assert record.type == params[:type]
assert record.content == params[:content]
assert record.ttl == params[:ttl].to_s
assert record.prio.blank?
end
test 'destroy' do
n_records = Record.count
xhr :delete, :destroy, { :id => records(:dom1_a1) }
assert_response :success
assert_not_nil assigns(:record)
assert assigns(:record).id == records(:dom1_a1).id
assert_raises ActiveRecord::RecordNotFound do; Record.find(records(:dom1_a1)); end;
assert Record.count == (n_records - 1)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/public/dispatch.rb | public/dispatch.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/ruby18
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch | ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/support/env.rb | features/support/env.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'cucumber/rails'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/support/paths.rb | features/support/paths.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case page_name
when /^the home\s?page$/
'/'
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
# when /^(.*)'s profile page$/i
# user_profile_path(User.find_by_login($1))
else
begin
page_name =~ /^the (.*) page$/
path_components = $1.split(/\s+/)
self.send(path_components.push('path').join('_').to_sym)
rescue NoMethodError, ArgumentError
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
end
end
World(NavigationHelpers)
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/support/selectors.rb | features/support/selectors.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module HtmlSelectorsHelpers
# Maps a name to a selector. Used primarily by the
#
# When /^(.+) within (.+)$/ do |step, scope|
#
# step definitions in web_steps.rb
#
def selector_for(locator)
case locator
when "the page"
"html > body"
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
# when /^the (notice|error|info) flash$/
# ".flash.#{$1}"
# You can also return an array to use a different selector
# type, like:
#
# when /the header/
# [:xpath, "//header"]
# This allows you to provide a quoted selector as the scope
# for "within" steps as was previously the default for the
# web steps:
when /^"(.+)"$/
$1
else
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
end
World(HtmlSelectorsHelpers)
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/step_definitions/web_steps.rb | features/step_definitions/web_steps.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file was generated by Cucumber-Rails and is only here to get you a head start
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
# visit pages, interact with widgets and make assertions about page content.
#
# If you use these step definitions as basis for your features you will quickly end up
# with features that are:
#
# * Hard to maintain
# * Verbose to read
#
# A much better approach is to write your own higher level step definitions, following
# the advice in the following blog posts:
#
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
#
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
module WithinHelpers
def with_scope(locator)
locator ? within(*selector_for(locator)) { yield } : yield
end
end
World(WithinHelpers)
# Single-line step scoper
When /^(.*) within (.*[^:])$/ do |step, parent|
with_scope(parent) { When step }
end
# Multi-line step scoper
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
with_scope(parent) { When "#{step}:", table_or_string }
end
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^(?:|I )go to (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^(?:|I )press "([^"]*)"$/ do |button|
click_button(button)
end
When /^(?:|I )follow "([^"]*)"$/ do |link|
click_link(link)
end
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
fill_in(field, :with => value)
end
# Use this to fill in an entire form with data from a table. Example:
#
# When I fill in the following:
# | Account Number | 5002 |
# | Expiry date | 2009-11-01 |
# | Note | Nice guy |
# | Wants Email? | |
#
# TODO: Add support for checkbox, select og option
# based on naming conventions.
#
When /^(?:|I )fill in the following:$/ do |fields|
fields.rows_hash.each do |name, value|
When %{I fill in "#{name}" with "#{value}"}
end
end
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
select(value, :from => field)
end
When /^(?:|I )check "([^"]*)"$/ do |field|
check(field)
end
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
uncheck(field)
end
When /^(?:|I )choose "([^"]*)"$/ do |field|
choose(field)
end
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
attach_file(field, File.expand_path(path))
end
Then /^(?:|I )should see "([^"]*)"$/ do |text|
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
end
end
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
if page.respond_to? :should
page.should have_xpath('//*', :text => regexp)
else
assert page.has_xpath?('//*', :text => regexp)
end
end
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
if page.respond_to? :should
page.should have_no_content(text)
else
assert page.has_no_content?(text)
end
end
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
if page.respond_to? :should
page.should have_no_xpath('//*', :text => regexp)
else
assert page.has_no_xpath?('//*', :text => regexp)
end
end
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
with_scope(parent) do
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should
field_value.should =~ /#{value}/
else
assert_match(/#{value}/, field_value)
end
end
end
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
with_scope(parent) do
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should_not
field_value.should_not =~ /#{value}/
else
assert_no_match(/#{value}/, field_value)
end
end
end
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
with_scope(parent) do
field_checked = find_field(label)['checked']
if field_checked.respond_to? :should
field_checked.should be_true
else
assert field_checked
end
end
end
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
with_scope(parent) do
field_checked = find_field(label)['checked']
if field_checked.respond_to? :should
field_checked.should be_false
else
assert !field_checked
end
end
end
Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
current_path.should == path_to(page_name)
else
assert_equal path_to(page_name), current_path
end
end
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
query = URI.parse(current_url).query
actual_params = query ? CGI.parse(query) : {}
expected_params = {}
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
if actual_params.respond_to? :should
actual_params.should == expected_params
else
assert_equal expected_params, actual_params
end
end
Then /^show me the page$/ do
save_and_open_page
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/step_definitions/webrat_steps.rb | features/step_definitions/webrat_steps.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
# Commonly used webrat steps
# http://github.com/brynary/webrat
Given /^I am on (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I press "([^\"]*)"$/ do |button|
click_button(button)
end
When /^I follow "([^\"]*)"$/ do |link|
click_link(link)
end
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
select(value, :from => field)
end
# Use this step in conjunction with Rail's datetime_select helper. For example:
# When I select "December 25, 2008 10:00" as the date and time
When /^I select "([^\"]*)" as the date and time$/ do |time|
select_datetime(time)
end
# Use this step when using multiple datetime_select helpers on a page or
# you want to specify which datetime to select. Given the following view:
# <%= f.label :preferred %><br />
# <%= f.datetime_select :preferred %>
# <%= f.label :alternative %><br />
# <%= f.datetime_select :alternative %>
# The following steps would fill out the form:
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
select_datetime(datetime, :from => datetime_label)
end
# Use this step in conjunction with Rail's time_select helper. For example:
# When I select "2:20PM" as the time
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
# will convert the 2:20PM to 14:20 and then select it.
When /^I select "([^\"]*)" as the time$/ do |time|
select_time(time)
end
# Use this step when using multiple time_select helpers on a page or you want to
# specify the name of the time on the form. For example:
# When I select "7:30AM" as the "Gym" time
When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
select_time(time, :from => time_label)
end
# Use this step in conjunction with Rail's date_select helper. For example:
# When I select "February 20, 1981" as the date
When /^I select "([^\"]*)" as the date$/ do |date|
select_date(date)
end
# Use this step when using multiple date_select helpers on one page or
# you want to specify the name of the date on the form. For example:
# When I select "April 26, 1982" as the "Date of Birth" date
When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
select_date(date, :from => date_label)
end
When /^I check "([^\"]*)"$/ do |field|
check(field)
end
When /^I uncheck "([^\"]*)"$/ do |field|
uncheck(field)
end
When /^I choose "([^\"]*)"$/ do |field|
choose(field)
end
When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
attach_file(field, path)
end
Then /^I should see "([^\"]*)"$/ do |text|
response.should contain(text)
end
Then /^I should not see "([^\"]*)"$/ do |text|
response.should_not contain(text)
end
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
field_labeled(field).value.should =~ /#{value}/
end
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
field_labeled(field).value.should_not =~ /#{value}/
end
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
field_labeled(label).should be_checked
end
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
field_labeled(label).should_not be_checked
end
Then /^I should be on (.+)$/ do |page_name|
URI.parse(current_url).path.should == path_to(page_name)
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/features/step_definitions/macro_definition_steps.rb | features/step_definitions/macro_definition_steps.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Given /^I have a domain$/ do
@domain = Factory(:domain)
end
Given /^I have a domain named "([^\"]*)"$/ do |name|
@domain = Factory(:domain, :name => name)
end
Given /^I have a macro$/ do
@macro = Factory(:macro)
end
When /^I apply the macro$/ do
@macro.apply_to( @domain )
@domain.reload
end
Given /^the macro "([^\"]*)" an? "([^\"]*)" record for "([^\"]*)" with "([^\"]*)"$/ do |action, type, name, content|
# clean up the action by singularizing the components
action.gsub!(/s$/,'').gsub!('s_', '_')
MacroStep.create!(:macro => @macro, :action => action, :record_type => type, :name => name, :content => content)
end
Given /^the macro "([^\"]*)" an "([^\"]*)" record for "([^\"]*)"$/ do |action, type, name|
# clean up the action by singularizing the components
action.gsub!(/s$/,'').gsub!(/s_/, '')
MacroStep.create!(:macro => @macro, :action => action, :record_type => type, :name => name)
end
Given /^the macro "([^\"]*)" an "([^\"]*)" record with "([^\"]*)" with priority "([^\"]*)"$/ do |action, type, content, prio|
# clean up the action by singularizing the components
action.gsub!(/s$/,'').gsub!(/s_/, '')
MacroStep.create!(:macro => @macro, :action => action, :record_type => type, :content => content, :prio => prio)
end
Given /^the domain has an? "([^\"]*)" record for "([^\"]*)" with "([^\"]*)"$/ do |type, name, content|
type.constantize.create!( :domain => @domain, :name => name, :content => content )
end
Then /^the domain should have an? "([^\"]*)" record for "([^\"]*)" with "([^\"]*)"$/ do |type, name, content|
records = @domain.send("#{type.downcase}_records", true)
records.should_not be_empty
records.detect { |r| r.name =~ /^#{name}\./ && r.content == content }.should_not be_nil
end
Then /^the domain should have an? "([^\"]*)" record with priority "([^\"]*)"$/ do |type, prio|
records = @domain.send("#{type.downcase}_records", true)
records.should_not be_empty
records.detect { |r| r.prio == prio.to_i }.should_not be_nil
end
Then /^the domain should not have an? "([^\"]*)" record for "([^\"]*)" with "([^\"]*)"$/ do |type, name, content|
records = @domain.send("#{type.downcase}_records", true)
records.detect { |r| r.name =~ /^#{name}\./ && r.content == content }.should be_nil
end
Then /^the domain should not have an "([^\"]*)" record for "([^\"]*)"$/ do |type, name|
records = @domain.send("#{type.downcase}_records", true)
records.detect { |r| r.name =~ /^#{name}\./ }.should be_nil
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/spec_helper.rb | spec/spec_helper.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
config.include Devise::TestHelpers, :type => :controller
config.include SignInHelpers, :type => :controller
config.include Webrat::HaveTagMatcher
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/sign_in_helpers.rb | spec/support/sign_in_helpers.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module SignInHelpers
def tokenize_as( token )
@request.session[:token_id] = token ? token.id : nil
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/users_factory.rb | spec/support/users_factory.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Factory.define :admin, :class => User do |f|
f.login 'admin'
f.email 'admin@example.com'
f.password 'secret'
f.password_confirmation 'secret'
f.confirmation_token nil
f.confirmed_at Time.now
f.admin true
end
Factory.define(:quentin, :class => User) do |f|
f.login 'quentin'
f.email 'quentin@example.com'
f.password 'secret'
f.password_confirmation 'secret'
f.confirmation_token nil
f.confirmed_at Time.now
end
Factory.define(:aaron, :class => User) do |f|
f.login 'aaron'
f.email 'aaron@example.com'
f.password 'secret'
f.password_confirmation 'secret'
f.confirmation_token nil
f.confirmed_at Time.now
end
Factory.define(:token_user, :class => User) do |f|
f.login 'token'
f.email 'token@example.com'
f.password 'secret'
f.password_confirmation 'secret'
f.admin true
f.auth_tokens true
f.confirmation_token nil
f.confirmed_at Time.now
end
Factory.define(:api_client, :class => User) do |f|
f.login 'api'
f.email 'api@example.com'
f.password 'secret'
f.password_confirmation 'secret'
f.admin true
f.confirmation_token nil
f.confirmed_at Time.now
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/zone_template_factory.rb | spec/support/zone_template_factory.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Factory.define(:zone_template, :class => ZoneTemplate) do |f|
f.name 'East Coast Data Center'
f.ttl 86400
end
Factory.define(:template_soa, :class => RecordTemplate) do |f|
f.ttl 86400
f.record_type 'SOA'
#f.content 'ns1.%ZONE% admin@%ZONE% 0 10800 7200 604800 3600'
f.primary_ns 'ns1.%ZONE%'
f.contact 'admin@example.com'
f.refresh 10800
f.retry 7200
f.expire 604800
f.minimum 3600
end
Factory.define(:template_ns, :class => RecordTemplate) do |f|
f.ttl 86400
f.record_type 'NS'
f.content 'ns1.%ZONE%'
end
Factory.define(:template_ns_a, :class => RecordTemplate) do |f|
f.ttl 86400
f.record_type 'A'
f.name 'ns1.%ZONE%'
f.content '10.0.0.1'
end
Factory.define(:template_cname, :class => RecordTemplate) do |f|
f.ttl 86400
f.record_type 'CNAME'
f.name '%ZONE%'
f.content 'some.cname.org'
end
Factory.define(:template_mx, :class => RecordTemplate) do |f|
f.ttl 86400
f.record_type 'MX'
f.content 'mail.%ZONE%'
f.prio 10
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/domain_factory.rb | spec/support/domain_factory.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Factory.define( :domain, :class => 'Domain' ) do |f|
f.name 'example.com'
f.add_attribute :type, 'NATIVE'
f.ttl 86400
# soa
f.primary_ns { |d| "ns1.#{d.name}" }
f.contact { |d| "admin@#{d.name}" }
f.refresh 10800
f.retry 7200
f.expire 604800
f.minimum 10800
end
#Factory.define(:soa, :class => 'SOA') do |f|
# f.name { |r| r.domain.name }
# f.ttl 86400
# #f.content { |r| "ns1.#{r.domain.name} admin@#{r.domain.name} 2008040101 10800 7200 604800 10800" }
# f.primary_ns { |r| "ns1.#{r.domain.name}" }
# f.contact { |r| "admin@#{r.domain.name}" }
# f.refresh 10700
# f.retry 7200
# f.expire 604800
# f.minimum 10800
#end
Factory.define(:ns, :class => NS) do |f|
f.ttl 86400
f.name { |r| r.domain.name }
f.content { |r| "ns1.#{r.domain.name}" }
end
Factory.define(:ns_a, :class => A) do |f|
f.ttl 86400
f.name { |r| "ns1.#{r.domain.name}" }
f.content "10.0.0.1"
end
Factory.define(:a, :class => A) do |f|
f.ttl 86400
f.name { |r| r.domain.name }
f.content '10.0.0.3'
end
Factory.define(:www, :class => A) do |f|
f.ttl 86400
f.name { |r| "www.#{r.domain.name}" }
f.content '10.0.0.3'
end
Factory.define(:mx, :class => MX) do |f|
f.ttl 86400
f.name { |r| r.domain.name }
f.content { |r| "mail.#{r.domain.name}" }
f.prio 10
end
Factory.define(:mx_a, :class => A) do |f|
f.ttl 86400
f.name { |r| "mail.#{r.domain.name}" }
f.content '10.0.0.4'
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/auth_token_factory.rb | spec/support/auth_token_factory.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Factory.define(:auth_token) do |f|
f.token '5zuld3g9dv76yosy'
f.permissions({
'policy' => 'deny',
'new' => false,
'remove' => false,
'protected' => [],
'protected_types' => [],
'allowed' => [
['example.com', '*'],
['www.example.com', '*']
]
})
f.expires_at 3.hours.since
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/support/macro_factory.rb | spec/support/macro_factory.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Factory.define(:macro) do |f|
f.name 'Move to West Coast'
f.active true
end
Factory.define(:macro_step_create, :class => MacroStep) do |f|
f.action 'create'
f.record_type 'A'
f.name 'auto'
f.content '127.0.0.1'
end
Factory.define(:macro_step_change, :class => MacroStep) do |f|
f.action 'update'
f.record_type 'A'
f.name 'www'
f.content '127.1.1.1'
end
Factory.define(:macro_step_remove, :class => MacroStep) do |f|
f.action 'remove'
f.record_type 'A'
f.name 'ftp'
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/helpers/macro_steps_helper_spec.rb | spec/helpers/macro_steps_helper_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe MacroStepsHelper do
#Delete this example and add some real ones or delete this file
it "should be included in the object returned by #helper" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(MacroStepsHelper)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/helpers/audits_helper_spec.rb | spec/helpers/audits_helper_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe AuditsHelper, "display_hash" do
it "should handle a blank changes hash" do
helper.display_hash( nil ).should eql('')
end
it "should have a way to display the changes hash with blank stipped" do
result = helper.display_hash( 'key' => 'value', :blank => nil )
result.should eql("<em>key</em>: value")
end
it "should seperate items in the change hash with breaks" do
result = helper.display_hash( 'one' => 'one', 'two' => 'two' )
result.should match(/<br \/>/)
end
end
describe AuditsHelper, "link_to_domain_audit" do
it "should handle an existing domain & existing user" do
Audit.as_user( Factory(:admin) ) do
domain = Factory(:domain)
audit = domain.audits.first
results = helper.link_to_domain_audit( audit )
results.should match(/1 create by admin/)
end
end
it "should handle existing domains & removed users" do
Audit.as_user('admin') do
audit = Factory(:domain).audits.first
results = helper.link_to_domain_audit( audit )
results.should match(/1 create by admin/)
end
end
it "should handle removed domains & existing users" do
Audit.as_user( Factory(:admin) ) do
domain = Factory(:domain)
domain.destroy
audit = domain.audits.last
results = helper.link_to_domain_audit( audit )
results.should match(/2 destroy by admin/)
end
end
it "should handle removed domains & removed users" do
Audit.as_user('admin') do
domain = Factory(:domain)
domain.destroy
audit = domain.audits.last
results = helper.link_to_domain_audit( audit )
results.should match(/2 destroy by admin/)
end
end
end
describe AuditsHelper, "link_to_record_audit" do
it "should handle an existing record & existing user" do
Audit.as_user( Factory(:admin) ) do
domain = Factory(:domain)
record = Factory(:a, :domain => domain)
audit = record.audits.first
result = helper.link_to_record_audit( audit )
result.should match(/A \(example\.com\) 1 create by admin/)
end
end
it "should handle existing records & removed users" do
Audit.as_user( 'admin' ) do
domain = Factory(:domain)
record = Factory(:a, :domain => domain)
audit = record.audits.first
result = helper.link_to_record_audit( audit )
result.should match(/A \(example\.com\) 1 create by admin/)
end
end
it "should handle removed records & existing users" do
Audit.as_user( Factory(:admin) ) do
domain = Factory(:domain)
record = Factory(:a, :domain => domain)
record.destroy
audit = record.audits.last
result = helper.link_to_record_audit( audit )
result.should match(/A \(example\.com\) 2 destroy by admin/)
end
end
it "should handle removed records & removed users" do
Audit.as_user( 'admin' ) do
domain = Factory(:domain)
record = Factory(:a, :domain => domain)
record.destroy
audit = record.audits.last
result = helper.link_to_record_audit( audit )
result.should match(/A \(example\.com\) 2 destroy by admin/)
end
end
it "should handle records without a 'type' key in the changes hash" do
domain = Factory(:domain)
audit = Audit.new(
:auditable => Factory(:a, :domain => domain),
:association => domain,
:action => 'create',
:version => 1,
:user => Factory(:admin),
:audited_changes => { 'name' => 'example.com' }
)
result = helper.link_to_record_audit( audit )
result.should match(/A \(example\.com\) 1 create by admin/)
end
it "should handle removed records without a 'type' key in the changes hash" do
audit = Audit.new(
:auditable => nil,
:association => Factory(:domain),
:action => 'destroy',
:version => 1,
:user => Factory(:admin),
:audited_changes => { 'name' => 'local.example.com' }
)
result = helper.link_to_record_audit( audit )
result.should match(/\[UNKNOWN\] \(local\.example\.com\) 1 destroy by admin/)
end
end
describe AuditsHelper, "audit_user" do
it "should display user logins if present" do
audit = Audit.new(
:auditable => nil,
:association => Factory(:domain),
:action => 'destroy',
:version => 1,
:user => Factory(:admin),
:audited_changes => { 'name' => 'local.example.com' }
)
helper.audit_user( audit ).should == 'admin'
end
it "should display usernames if present" do
audit = Audit.new(
:auditable => nil,
:association => Factory(:domain),
:action => 'destroy',
:version => 1,
:username => 'foo',
:audited_changes => { 'name' => 'local.example.com' }
)
helper.audit_user( audit ).should == 'foo'
end
it "should not bork on missing user information" do
audit = Audit.new(
:auditable => nil,
:association => Factory(:domain),
:action => 'destroy',
:version => 1,
:audited_changes => { 'name' => 'local.example.com' }
)
helper.audit_user( audit ).should == 'UNKNOWN'
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/helpers/macros_helper_spec.rb | spec/helpers/macros_helper_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe MacrosHelper do
#Delete this example and add some real ones or delete this file
it "should be included in the object returned by #helper" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(MacrosHelper)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/helpers/application_helper_spec.rb | spec/helpers/application_helper_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe ApplicationHelper do
describe "link_to_cancel" do
it "on new records should link to index" do
html = helper.link_to_cancel( Macro.new )
html.should have_tag('a[href="/macros"]', :content => 'Cancel')
end
it "on existing records should link to show" do
macro = Factory(:macro)
html = helper.link_to_cancel( macro )
html.should have_tag("a[href='/macros/#{macro.id}']", :content => 'Cancel')
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/search_controller_spec.rb | spec/controllers/search_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe SearchController, "for admins" do
before(:each) do
#session[:user_id] = Factory(:admin).id
sign_in Factory(:admin)
Factory(:domain, :name => 'example.com')
Factory(:domain, :name => 'example.net')
end
it "should return results when searched legally" do
get :results, :q => 'exa'
assigns(:results).should_not be_nil
response.should render_template('search/results')
end
it "should handle whitespace in the query" do
get :results, :q => ' exa '
assigns(:results).should_not be_nil
response.should render_template('results')
end
it "should redirect to the index page when nothing has been searched for" do
get :results, :q => ''
response.should be_redirect
response.should redirect_to( root_path )
end
it "should redirect to the domain page if only one result is found" do
domain = Factory(:domain, :name => 'slave-example.com')
get :results, :q => 'slave-example.com'
response.should be_redirect
response.should redirect_to( domain_path( domain ) )
end
end
describe SearchController, "for api clients" do
before(:each) do
sign_in(Factory(:api_client))
Factory(:domain, :name => 'example.com')
Factory(:domain, :name => 'example.net')
end
it "should return an empty JSON response for no results" do
get :results, :q => 'amazon', :format => 'json'
assigns(:results).should be_empty
response.body.should == "[]"
end
it "should return a JSON set of results" do
get :results, :q => 'example', :format => 'json'
assigns(:results).should_not be_empty
json = ActiveSupport::JSON.decode( response.body )
json.size.should be(2)
json.first["domain"].keys.should include('id', 'name')
json.first["domain"]["name"].should match(/example/)
json.first["domain"]["id"].to_s.should match(/\d+/)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/audits_controller_spec.rb | spec/controllers/audits_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe AuditsController do
before(:each) do
sign_in(Factory(:admin))
end
it "should have a search form" do
get :index
response.should render_template('audits/index')
end
it "should have a domain details page" do
get :domain, :id => Factory(:domain).id
assigns(:domain).should_not be_nil
response.should render_template('audits/domain')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/auth_tokens_controller_spec.rb | spec/controllers/auth_tokens_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe AuthTokensController do
it "should not allow access to admins or owners" do
sign_in( Factory(:admin) )
post :create
response.code.should eql("302")
sign_in(Factory(:quentin))
post :create
response.code.should eql("302")
end
it "should bail cleanly on missing auth_token" do
sign_in(Factory(:token_user))
post :create
response.code.should eql("422")
end
it "should bail cleanly on missing domains" do
sign_in(Factory(:token_user))
post :create, :auth_token => { :domain => 'example.org' }
response.code.should eql("404")
end
it "bail cleanly on invalid requests" do
Factory(:domain)
sign_in(Factory(:token_user))
post :create, :auth_token => { :domain => 'example.com' }
response.should have_selector('error')
end
describe "generating tokens" do
before(:each) do
sign_in(Factory(:token_user))
@domain = Factory(:domain)
@params = { :domain => @domain.name, :expires_at => 1.hour.since.to_s(:rfc822) }
end
it "with allow_new set" do
post :create, :auth_token => @params.merge(:allow_new => 'true')
response.should have_selector('token > expires')
response.should have_selector('token > auth_token')
response.should have_selector('token > url')
assigns(:auth_token).should_not be_nil
assigns(:auth_token).domain.should eql( @domain )
assigns(:auth_token).should be_allow_new_records
end
it "with remove set" do
a = Factory(:www, :domain => @domain)
post :create, :auth_token => @params.merge(:remove => 'true', :record => ['www.example.com'])
response.should have_selector('token > expires')
response.should have_selector('token > auth_token')
response.should have_selector('token > url')
assigns(:auth_token).remove_records?.should be_true
assigns(:auth_token).can_remove?( a ).should be_true
end
it "with policy set" do
post :create, :auth_token => @params.merge(:policy => 'allow')
response.should have_selector('token > expires')
response.should have_selector('token > auth_token')
response.should have_selector('token > url')
assigns(:auth_token).policy.should eql(:allow)
end
it "with protected records" do
a = Factory(:a, :domain => @domain)
www = Factory(:www, :domain => @domain)
mx = Factory(:mx, :domain => @domain)
post :create, :auth_token => @params.merge(
:protect => ['example.com:A', 'www.example.com'],
:policy => 'allow'
)
response.should have_selector('token > expires')
response.should have_selector('token > auth_token')
response.should have_selector('token > url')
assigns(:auth_token).should_not be_nil
assigns(:auth_token).can_change?( a ).should be_false
assigns(:auth_token).can_change?( mx ).should be_true
assigns(:auth_token).can_change?( www ).should be_false
end
it "with protected record types" do
mx = Factory(:mx, :domain => @domain)
post :create, :auth_token => @params.merge(:policy => 'allow', :protect_type => ['MX'])
assigns(:auth_token).can_change?( mx ).should be_false
end
it "with allowed records" do
a = Factory(:a, :domain => @domain)
www = Factory(:www, :domain => @domain)
mx = Factory(:mx, :domain => @domain)
post :create, :auth_token => @params.merge(:record => ['example.com'])
assigns(:auth_token).can_change?( www ).should be_false
assigns(:auth_token).can_change?( a ).should be_true
assigns(:auth_token).can_change?( mx ).should be_true
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/macros_controller_spec.rb | spec/controllers/macros_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe MacrosController, "for admins" do
before(:each) do
sign_in( Factory(:admin) )
@macro = Factory(:macro)
Factory(:quentin)
end
it "should have a list of macros" do
get :index
assigns(:macros).should_not be_nil
response.should render_template('macros/index')
end
it "should have a detailed view of a macro" do
get :show, :id => @macro.id
assigns(:macro).should == @macro
response.should render_template('macros/show')
end
it "should have a form for creating new macros" do
get :new
assigns(:macro).should be_a_new_record
response.should render_template('macros/edit')
end
it "should create valid macros" do
expect {
post :create, :macro => {
:name => 'Test Macro',
:active => '0'
}
}.to change(Macro, :count).by(1)
flash[:notice].should_not be_nil
response.should be_redirect
response.should redirect_to( macro_path(assigns(:macro) ) )
end
it "should render the form on invalid macros" do
post :create, :macro => {
:name => ''
}
flash[:info].should be_nil
response.should_not be_redirect
response.should render_template('macros/edit')
end
it "should have an edit form for macros" do
get :edit, :id => @macro.id
assigns(:macro).should == @macro
response.should render_template('macros/edit')
end
it "should accept valid updates to macros" do
expect {
put :update, :id => @macro.id, :macro => { :name => 'Foo Macro' }
@macro.reload
}.to change(@macro, :name)
flash[:notice].should_not be_nil
response.should be_redirect
response.should redirect_to( macro_path( @macro ) )
end
it "should reject invalid updates" do
expect {
put :update, :id => @macro.id, :macro => { :name => '' }
@macro.reload
}.to_not change(@macro, :name)
flash[:notice].should be_blank
response.should_not be_redirect
response.should render_template('macros/edit')
end
it "should remove a macro if asked to" do
delete :destroy, :id => @macro.id
assigns(:macro).should be_frozen
flash[:notice].should_not be_nil
response.should be_redirect
response.should redirect_to( macros_path )
end
end
describe MacrosController, "for owners" do
before(:each) do
quentin = Factory(:quentin)
sign_in(quentin)
@macro = Factory(:macro, :user => quentin)
end
it "should have a form to create a new macro" do
get :new
assigns(:users).should be_nil
assigns(:macro).should be_a_new_record
response.should render_template('macros/edit')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/macro_steps_controller_spec.rb | spec/controllers/macro_steps_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe MacroStepsController do
before(:each) do
sign_in(Factory(:admin))
@macro = Factory(:macro)
@step = Factory(:macro_step_create,
:macro => @macro,
:name => 'localhost',
:content => '127.0.0.1')
end
it "should create a valid step" do
expect {
post :create, :macro_id => @macro.id,
:macro_step => {
:action => 'create',
:record_type => 'A',
:name => 'www',
:content => '127.0.0.1'
}, :format => 'js'
}.to change(@macro.macro_steps(true), :count)
response.should render_template('macro_steps/create')
end
it "should position a valid step correctly" do
post :create, :macro_id => @macro.id,
:macro_step => {
:action => 'create',
:record_type => 'A',
:name => 'www',
:content => '127.0.0.1',
:position => '1'
}, :format => 'js'
assigns(:macro_step).position.should == 1
end
it "should not create an invalid step" do
expect {
post :create, :macro_id => @macro.id,
:macro_step => {
:position => '1',
:record_type => 'A'
}, :format => 'js'
}.to_not change(@macro.macro_steps(true), :count)
response.should render_template('macro_steps/create')
end
it "should accept valid updates to steps" do
put :update, :macro_id => @macro.id, :id => @step.id,
:macro_step => {
:name => 'local'
}, :format => 'js'
response.should render_template('macro_steps/update')
@step.reload.name.should == 'local'
end
it "should not accept valid updates" do
put :update, :macro_id => @macro.id, :id => @step.id,
:macro_step => {
:name => ''
}, :format => 'js'
response.should render_template('macro_steps/update')
end
it "should re-position existing steps" do
Factory(:macro_step_create, :macro => @macro)
put :update, :macro_id => @macro.id, :id => @step.id,
:macro_step => { :position => '2' }
@step.reload.position.should == 2
end
it "should remove selected steps when asked" do
delete :destroy, :macro_id => @macro, :id => @step.id, :format => 'js'
flash[:info].should_not be_blank
response.should be_redirect
response.should redirect_to(macro_path(@macro))
expect { @step.reload }.to raise_error( ActiveRecord::RecordNotFound )
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/sessions_controller_spec.rb | spec/controllers/sessions_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe SessionsController, "and users" do
#before(:each) do
# @quentin = Factory(:quentin)
#end
#it 'logins and redirects' do
# post :create, :login => 'quentin', :password => 'test'
# session[:user_id].should_not be_nil
# response.should be_redirect
#end
#it 'fails login and does not redirect' do
# post :create, :login => 'quentin', :password => 'bad password'
# session[:user_id].should be_nil
# response.should be_success
#end
#it 'logs out' do
# login_as @quentin
# get :destroy
# session[:user_id].should be_nil
# response.should be_redirect
#end
#it 'remembers me' do
# post :create, :login => 'quentin', :password => 'test', :remember_me => "1"
# response.cookies["auth_token"].should_not be_nil
#end
#it 'does not remember me' do
# post :create, :login => 'quentin', :password => 'test', :remember_me => "0"
# response.cookies["auth_token"].should be_nil
#end
#it 'deletes token on logout' do
# login_as @quentin
# get :destroy
# response.cookies["auth_token"].should be_nil
#end
#it 'logs in with cookie' do
# @quentin.remember_me
# request.cookies["auth_token"] = cookie_for(@quentin)
# get :new
# controller.send(:logged_in?).should be_true
#end
#it 'fails expired cookie login' do
# @quentin.remember_me
# @quentin.update_attribute :remember_token_expires_at, 5.minutes.ago
# request.cookies["auth_token"] = cookie_for(@quentin)
# get :new
# controller.send(:logged_in?).should_not be_true
#end
#it 'fails cookie login' do
# @quentin.remember_me
# request.cookies["auth_token"] = auth_token('invalid_auth_token')
# get :new
# controller.send(:logged_in?).should_not be_true
#end
#def auth_token(token)
# CGI::Cookie.new('name' => 'auth_token', 'value' => token)
#end
#def cookie_for(user)
# auth_token user.remember_token
#end
end
describe SessionsController, "and auth tokens" do
before(:each) do
@domain = Factory(:domain)
@user = Factory(:admin)
@token = Factory(:auth_token, :domain => @domain, :user => @user)
end
xit 'accepts and redirects' do
post :token, :token => '5zuld3g9dv76yosy'
session[:token_id].should_not be_nil
controller.send(:token_user?).should be_true
response.should be_redirect
response.should redirect_to( domain_path( @domain ) )
end
xit 'fails login and does not redirect' do
post :token, :token => 'bad_token'
session[:token_id].should be_nil
response.should be_success
end
xit 'logs out' do
tokenize_as(@token)
get :destroy
session[:token_id].should be_nil
response.should redirect_to( session_path )
end
xit 'fails expired cookie login' do
@token.update_attribute :expires_at, 5.minutes.ago
get :new
controller.send(:token_user?).should_not be_true
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/users_controller_spec.rb | spec/controllers/users_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe UsersController do
describe "without an admin" do
it "should require a login" do
get 'index'
response.should redirect_to( new_user_session_path )
end
end
describe "with an admin" do
before(:each) do
@admin = Factory(:admin)
sign_in( @admin )
end
it "should show a list of current users" do
get 'index'
response.should render_template( 'users/index')
assigns(:users).should_not be_empty
end
it 'should load a users details' do
get 'show', :id => @admin.id
response.should render_template( 'users/show' )
assigns(:user).should_not be_nil
end
it 'should have a form for creating a new user' do
get 'new'
response.should render_template( 'users/new' )
assigns(:user).should_not be_nil
end
it "should create a new administrator" do
post :create, :user => {
:login => 'someone',
:email => 'someone@example.com',
:password => 'secret',
:password_confirmation => 'secret',
:admin => 'true'
}
assigns(:user).should be_an_admin
response.should be_redirect
response.should redirect_to( user_path( assigns(:user) ) )
end
it 'should create a new administrator with token privs' do
post :create, :user => {
:login => 'someone',
:email => 'someone@example.com',
:password => 'secret',
:password_confirmation => 'secret',
:admin => '1',
:auth_tokens => '1'
}
assigns(:user).admin?.should be_true
assigns(:user).auth_tokens?.should be_true
response.should be_redirect
response.should redirect_to( user_path( assigns(:user) ) )
end
it "should create a new owner" do
post :create, :user => {
:login => 'someone',
:email => 'someone@example.com',
:password => 'secret',
:password_confirmation => 'secret',
}
assigns(:user).should_not be_an_admin
response.should be_redirect
response.should redirect_to( user_path( assigns(:user) ) )
end
it 'should create a new owner ignoring token privs' do
post :create, :user => {
:login => 'someone',
:email => 'someone@example.com',
:password => 'secret',
:password_confirmation => 'secret',
:auth_tokens => '1'
}
assigns(:user).should_not be_an_admin
assigns(:user).auth_tokens?.should be_false
response.should be_redirect
response.should redirect_to( user_path( assigns(:user) ) )
end
it 'should update a user without password changes' do
user = Factory(:quentin)
lambda {
post :update, :id => user.id, :user => {
:email => 'new@example.com',
:password => '',
:password_confirmation => ''
}
user.reload
}.should change( user, :email )
response.should be_redirect
response.should redirect_to( user_path( user ) )
end
it 'should be able to suspend users' do
@user = Factory(:quentin)
put 'suspend', :id => @user.id
response.should be_redirect
response.should redirect_to( users_path )
end
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/domains_controller_spec.rb | spec/controllers/domains_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe DomainsController, "index" do
it "should display all zones to the admin" do
sign_in(Factory(:admin))
Factory(:domain)
get 'index'
response.should render_template('domains/index')
assigns(:domains).should_not be_empty
assigns(:domains).size.should be(Domain.count)
end
it "should restrict zones for owners" do
quentin = Factory(:quentin)
Factory(:domain, :user => quentin)
Factory(:domain, :name => 'example.net')
sign_in( quentin )
get 'index'
response.should render_template('domains/index')
assigns(:domains).should_not be_empty
assigns(:domains).size.should be(1)
end
it "should display all zones as XML" do
sign_in(Factory(:admin))
Factory(:domain)
get :index, :format => 'xml'
assigns(:domains).should_not be_empty
response.should have_tag('domains')
end
end
describe DomainsController, "when creating" do
before(:each) do
sign_in(Factory(:admin))
end
it "should have a form for adding a new zone" do
Factory(:template_soa, :zone_template => Factory(:zone_template))
Factory(:zone_template, :name => 'No SOA')
get 'new'
response.should render_template('domains/new')
end
it "should not save a partial form" do
Factory(:template_soa, :zone_template => Factory(:zone_template))
Factory(:zone_template, :name => 'No SOA')
expect {
post 'create', :domain => { :name => 'example.org' }, :zone_template => { :id => "" }
}.to_not change( Domain, :count )
response.should_not be_redirect
response.should render_template('domains/new')
end
it "should build from a zone template if selected" do
zone_template = Factory(:zone_template)
Factory(:template_soa, :zone_template => zone_template)
expect {
post 'create', :domain => { :name => 'example.org', :zone_template_id => zone_template.id }
}.to change( Domain, :count ).by(1)
assigns(:domain).should_not be_nil
response.should be_redirect
response.should redirect_to( domain_path(assigns(:domain)) )
end
it "should be redirected to the zone details after a successful save" do
expect {
post 'create', :domain => {
:name => 'example.org', :primary_ns => 'ns1.example.org',
:contact => 'admin@example.org', :refresh => 10800, :retry => 7200,
:expire => 604800, :minimum => 10800, :zone_template_id => "" }
}.to change( Domain, :count ).by(1)
response.should be_redirect
response.should redirect_to( domain_path( assigns(:domain) ) )
flash[:notice].should_not be_nil
end
it "should ignore the zone template if a slave is created" do
zone_template = Factory(:zone_template)
expect {
post 'create', :domain => {
:name => 'example.org',
:type => 'SLAVE',
:master => '127.0.0.1',
:zone_template_id => zone_template.id
}
}.to change( Domain, :count ).by(1)
assigns(:domain).should be_slave
assigns(:domain).soa_record.should be_nil
response.should be_redirect
end
end
describe DomainsController do
before(:each) do
sign_in(Factory(:admin))
end
it "should accept ownership changes" do
domain = Factory(:domain)
expect {
xhr :put, :change_owner, :id => domain.id, :domain => { :user_id => Factory(:quentin).id }
domain.reload
}.to change( domain, :user_id )
response.should render_template('domains/change_owner')
end
end
describe DomainsController, "and macros" do
before(:each) do
sign_in(Factory(:admin))
@macro = Factory(:macro)
@domain = Factory(:domain)
end
it "should have a selection for the user" do
get :apply_macro, :id => @domain.id
assigns(:domain).should_not be_nil
assigns(:macros).should_not be_empty
response.should render_template('domains/apply_macro')
end
it "should apply the selected macro" do
post :apply_macro, :id => @domain.id, :macro_id => @macro.id
flash[:notice].should_not be_blank
response.should be_redirect
response.should redirect_to( domain_path( @domain ) )
end
end
describe DomainsController, "should handle a REST client" do
before(:each) do
sign_in(Factory(:api_client))
@domain = Factory(:domain)
end
it "creating a new zone without a template" do
expect {
post 'create', :domain => {
:name => 'example.org', :primary_ns => 'ns1.example.org',
:contact => 'admin@example.org', :refresh => 10800, :retry => 7200,
:expire => 604800, :minimum => 10800
}, :format => "xml"
}.to change( Domain, :count ).by( 1 )
response.should have_tag( 'domain' )
end
it "creating a zone with a template" do
zt = Factory(:zone_template)
Factory(:template_soa, :zone_template => zt)
post 'create', :domain => { :name => 'example.org',
:zone_template_id => zt.id },
:format => "xml"
response.should have_tag( 'domain' )
end
it "creating a zone with a named template" do
zt = Factory(:zone_template)
Factory(:template_soa, :zone_template => zt)
post 'create', :domain => { :name => 'example.org',
:zone_template_name => zt.name },
:format => "xml"
response.should have_tag( 'domain' )
end
it "creating a zone with invalid input" do
expect {
post 'create', :domain => {
:name => 'example.org'
}, :format => "xml"
}.to_not change( Domain, :count )
response.should have_tag( 'errors' )
end
it "removing zones" do
delete :destroy, :id => @domain.id, :format => "xml"
expect {
@domain.reload
}.to raise_error(ActiveRecord::RecordNotFound)
end
it "viewing a list of all zones" do
get :index, :format => 'xml'
response.should have_selector('domains > domain')
end
it "viewing a zone" do
get :show, :id => @domain.id, :format => 'xml'
response.should have_selector('domain > records')
end
it "getting a list of macros to apply" do
Factory(:macro)
get :apply_macro, :id => @domain.id, :format => 'xml'
response.should have_selector('macros > macro')
end
it "applying a macro to a domain" do
macro = Factory(:macro)
post :apply_macro, :id => @domain.id, :macro_id => macro.id, :format => 'xml'
response.code.should == "202"
response.should have_tag('domain')
end
end
describe DomainsController, "and auth tokens" do
before(:each) do
@domain = Factory(:domain)
@token = Factory(:auth_token, :user => Factory(:admin), :domain => @domain)
tokenize_as(@token)
end
xit "should display the domain in the token" do
get :show, :id => @domain.id
response.should render_template('domains/show')
end
xit "should restrict the domain to that of the token" do
get :show, :id => rand(1_000_000)
assigns(:domain).should eql(@domain)
end
xit "should not allow a list of domains" do
get :index
response.should be_redirect
end
xit "should not accept updates to the domain" do
put :update, :id => @domain, :domain => { :name => 'hack' }
response.should be_redirect
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/templates_controller_spec.rb | spec/controllers/templates_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe TemplatesController, "and admins" do
before(:each) do
sign_in(Factory(:admin))
end
it "should have a template list" do
Factory(:zone_template)
get :index
assigns(:zone_templates).should_not be_empty
assigns(:zone_templates).size.should be( ZoneTemplate.count )
end
it "should have a detailed view of a template" do
get :show, :id => Factory(:zone_template).id
assigns(:zone_template).should_not be_nil
response.should render_template('templates/show')
end
it "should redirect to the template on create" do
expect {
post :create, :zone_template => { :name => 'Foo' }
}.to change( ZoneTemplate, :count ).by(1)
response.should redirect_to( zone_template_path( assigns(:zone_template) ) )
end
end
describe TemplatesController, "and users" do
before(:each) do
@quentin = Factory(:quentin)
sign_in(@quentin)
end
it "should have a limited list" do
Factory(:zone_template, :user => @quentin)
Factory(:zone_template, :name => '!Quentin')
get :index
assigns(:zone_templates).should_not be_empty
assigns(:zone_templates).size.should be(1)
end
it "should not have a list of users when showing the new form" do
get :new
assigns(:users).should be_nil
end
end
describe TemplatesController, "should handle a REST client" do
before(:each) do
sign_in(Factory(:api_client))
end
it "asking for a list of templates" do
Factory(:zone_template)
get :index, :format => "xml"
response.should have_tag('zone-templates > zone-template')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/dashboard_controller_spec.rb | spec/controllers/dashboard_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe DashboardController, "and admins" do
before(:each) do
sign_in( Factory(:admin) )
Factory(:domain)
get :index
end
it "should have a list of the latest zones" do
assigns(:latest_domains).should_not be_empty
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/reports_controller_spec.rb | spec/controllers/reports_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe ReportsController, "index" do
before(:each) do
sign_in(Factory(:admin))
Factory(:domain)
q = Factory(:quentin)
Factory(:domain, :name => 'example.net', :user => q)
end
it "should display all users to the admin" do
get 'index'
response.should render_template('reports/index')
assigns(:users).should_not be_empty
assigns(:users).size.should be(1)
end
it "should display total system domains and total domains to the admin" do
get 'index'
response.should render_template('reports/index')
assigns(:total_domains).should be(Domain.count)
assigns(:system_domains).should be(1)
end
end
describe ReportsController, "results" do
before(:each) do
sign_in(Factory(:admin))
end
it "should display a list of users for a search hit" do
Factory(:aaron)
Factory(:api_client)
get 'results', :q => "a"
response.should render_template('reports/results')
assigns(:results).should_not be_empty
assigns(:results).size.should be(3)
end
it "should redirect to reports/index if the search query is empty" do
get 'results' , :q => ""
response.should be_redirect
response.should redirect_to( reports_path )
end
end
describe ReportsController , "view" do
before(:each) do
sign_in(Factory(:admin))
end
it "should show a user reports" do
get "view" , :id => Factory(:aaron).id
response.should render_template("reports/view")
assigns(:user).should_not be_nil
assigns(:user).login.should == 'aaron'
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/record_template_controller_spec.rb | spec/controllers/record_template_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe RecordTemplatesController, "when updating SOA records" do
before(:each) do
sign_in(Factory(:admin))
@zt = Factory(:zone_template)
end
it "should create valid templates" do
expect {
xhr :post, :create, :record_template => {
:retry => "7200", :primary_ns => 'ns1.provider.net',
:contact => 'east-coast@example.com', :refresh => "10800", :minimum => "10800",
:expire => "604800", :record_type => "SOA"
}, :zone_template => { :id => @zt.id }
}.to change( RecordTemplate, :count ).by(1)
end
it "should accept a valid update" do
target_soa = Factory(:template_soa, :zone_template => @zt)
xhr :put, :update, :id => target_soa.id, :record_template => {
:retry => "7200", :primary_ns => 'ns1.provider.net',
:contact => 'east-coast@example.com', :refresh => "10800", :minimum => "10800",
:expire => "604800"
}
target_soa.reload
target_soa.primary_ns.should eql('ns1.provider.net')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/controllers/records_controller_spec.rb | spec/controllers/records_controller_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe RecordsController, ", users, and non-SOA records" do
before( :each ) do
sign_in(Factory(:admin))
@domain = Factory(:domain)
end
# Test adding various records
[
{ :name => '', :ttl => '86400', :type => 'NS', :content => 'ns3.example.com' },
{ :name => '', :ttl => '86400', :type => 'A', :content => '127.0.0.1' },
{ :name => '', :ttl => '86400', :type => 'MX', :content => 'mail.example.com', :prio => '10' },
{ :name => 'foo', :ttl => '86400', :type => 'CNAME', :content => 'bar.example.com' },
{ :name => '', :ttl => '86400', :type => 'AAAA', :content => '::1' },
{ :name => '', :ttl => '86400', :type => 'TXT', :content => 'Hello world' },
{ :name => '166.188.77.208.in-addr.arpa.', :type => 'PTR', :content => 'www.example.com' },
# TODO: Test these
{ :type => 'SPF', :pending => true },
{ :type => 'LOC', :pending => true },
{ :type => 'SPF', :pending => true }
].each do |record|
it "should create a #{record[:type]} record when valid" do
pending "Still need test for #{record[:type]}" if record.delete(:pending)
expect {
xhr :post, :create, :domain_id => @domain.id, :record => record
}.to change( @domain.records, :count ).by(1)
assigns(:domain).should_not be_nil
assigns(:record).should_not be_nil
end
end
it "shouldn't save when invalid" do
params = {
'name' => "",
'ttl' => "864400",
'type' => "NS",
'content' => ""
}
xhr :post, :create, :domain_id => @domain.id, :record => params
response.should render_template( 'records/create' )
end
it "should update when valid" do
record = Factory(:ns, :domain => @domain)
params = {
'name' => "",
'ttl' => "864400",
'type' => "NS",
'content' => "n4.example.com"
}
xhr :put, :update, :id => record.id, :domain_id => @domain.id, :record => params
response.should render_template("records/update")
end
it "shouldn't update when invalid" do
record = Factory(:ns, :domain => @domain)
params = {
'name' => "@",
'ttl' => '',
'type' => "NS",
'content' => ""
}
expect {
xhr :put, :update, :id => record.id, :domain_id => @domain.id, :record => params
record.reload
}.to_not change( record, :content )
response.should_not be_redirect
response.should render_template( "records/update" )
end
it "should destroy when requested to do so" do
delete :destroy, :domain_id => @domain.id, :id => Factory(:mx, :domain => @domain).id
response.should be_redirect
response.should redirect_to( domain_path( @domain ) )
end
end
describe RecordsController, ", users, and SOA records" do
it "should update when valid" do
sign_in( Factory(:admin) )
target_soa = Factory(:domain).soa_record
xhr :put, :update_soa, :id => target_soa.id, :domain_id => target_soa.domain.id,
:soa => {
:primary_ns => 'ns1.example.com', :contact => 'dnsadmin@example.com',
:refresh => "10800", :retry => "10800", :minimum => "10800", :expire => "604800"
}
target_soa.reload
target_soa.contact.should eql('dnsadmin@example.com')
end
end
describe RecordsController, "and tokens" do
before( :each ) do
@domain = Factory(:domain)
@admin = Factory(:admin)
@token = AuthToken.new(
:domain => @domain, :expires_at => 1.hour.since, :user => @admin
)
end
xit "should not be allowed to touch the SOA record" do
token = Factory(:auth_token, :domain => @domain, :user => @admin)
tokenize_as( token )
target_soa = @domain.soa_record
expect {
xhr :put, "update_soa", :id => target_soa.id, :domain_id => target_soa.domain.id,
:soa => {
:primary_ns => 'ns1.example.com', :contact => 'dnsadmin@example.com',
:refresh => "10800", :retry => "10800", :minimum => "10800", :expire => "604800"
}
target_soa.reload
}.to_not change( target_soa, :contact )
end
xit "should not allow new NS records" do
controller.stubs(:current_token).returns(@token)
params = {
'name' => '',
'ttl' => '86400',
'type' => 'NS',
'content' => 'n3.example.com'
}
expect {
xhr :post, :create, :domain_id => @domain.id, :record => params
}.to_not change( @domain.records, :size )
response.should_not be_success
response.code.should == "403"
end
xit "should not allow updating NS records" do
controller.stubs(:current_token).returns(@token)
record = Factory(:ns, :domain => @domain)
params = {
'name' => '',
'ttl' => '86400',
'type' => 'NS',
'content' => 'ns1.somewhereelse.com'
}
expect {
xhr :put, :update, :id => record.id, :domain_id => @domain.id, :record => params
record.reload
}.to_not change( record, :content )
response.should_not be_success
response.code.should == "403"
end
xit "should create when allowed" do
@token.allow_new_records = true
controller.stubs(:current_token).returns(@token)
params = {
'name' => 'test',
'ttl' => '86400',
'type' => 'A',
'content' => '127.0.0.2'
}
expect {
xhr :post, :create, :domain_id => @domain.id, :record => params
}.to change( @domain.records, :size )
response.should be_success
assigns(:domain).should_not be_nil
assigns(:record).should_not be_nil
# Ensure the token han been updated
@token.can_change?( 'test', 'A' ).should be_true
@token.can_remove?( 'test', 'A' ).should be_true
end
xit "should not create if not allowed" do
controller.stubs(:current_token).returns(@token)
params = {
'name' => "test",
'ttl' => "864400",
'type' => "A",
'content' => "127.0.0.2"
}
expect {
xhr :post, :create, :domain_id => @domain.id, :record => params
}.to_not change( @domain.records, :size )
response.should_not be_success
response.code.should == "403"
end
xit "should update when allowed" do
record = Factory(:www, :domain => @domain)
@token.can_change( record )
controller.stubs(:current_token).returns( @token )
params = {
'name' => "www",
'ttl' => "864400",
'type' => "A",
'content' => "10.0.1.10"
}
expect {
xhr :put, :update, :id => record.id, :domain_id => @domain.id, :record => params
record.reload
}.to change( record, :content )
response.should be_success
response.should render_template("update")
end
xit "should not update if not allowed" do
record = Factory(:www, :domain => @domain)
controller.stubs(:current_token).returns(@token)
params = {
'name' => "www",
'ttl' => '',
'type' => "A",
'content' => "10.0.1.10"
}
expect {
xhr :put, :update, :id => record.id, :domain_id => @domain.id, :record => params
record.reload
}.to_not change( record, :content )
response.should_not be_success
response.code.should == "403"
end
xit "should destroy when allowed" do
record = Factory(:mx, :domain => @domain)
@token.can_change( record )
@token.remove_records=( true )
controller.stubs(:current_token).returns(@token)
expect {
delete :destroy, :domain_id => @domain.id, :id => record.id
}.to change( @domain.records, :size ).by(-1)
response.should be_redirect
response.should redirect_to( domain_path( @domain ) )
end
xit "should not destroy records if not allowed" do
controller.stubs(:current_token).returns( @token )
record = Factory(:a, :domain => @domain)
expect {
delete :destroy, :domain_id => @domain.id, :id => record.id
}.to_not change( @domain.records, :count )
response.should_not be_success
response.code.should == "403"
end
xit "should not allow tampering with other domains" do
@token.allow_new_records=( true )
controller.stubs( :current_token ).returns( @token )
record = {
'name' => 'evil',
'type' => 'A',
'content' => '127.0.0.3'
}
xhr :post, :create, :domain_id => Factory(:domain, :name => 'example.net').id, :record => record
response.code.should == "403"
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/models/record_spec.rb | spec/models/record_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe Record, "when new" do
before(:each) do
@record = Record.new
end
it "should be invalid by default" do
@record.should_not be_valid
end
it "should require a domain" do
@record.should have(1).error_on(:domain_id)
end
it "should require a ttl" do
@record.should have(1).error_on(:ttl)
end
it "should only allow positive numeric ttl's" do
@record.ttl = -100
@record.should have(1).error_on(:ttl)
@record.ttl = '2d'
@record.should have(1).error_on(:ttl)
@record.ttl = 86400
@record.should have(:no).errors_on(:ttl)
end
it "should require a name" do
@record.should have(1).error_on(:name)
end
it "should not support priorities by default" do
@record.supports_prio?.should be_false
end
end
describe Record, "during updates" do
before(:each) do
@domain = Factory(:domain)
@soa = @domain.soa_record
end
it "should update the serial on the SOA" do
serial = @soa.serial
record = Factory(:a, :domain => @domain)
record.content = '10.0.0.1'
record.save.should be_true
@soa.reload
@soa.serial.should_not eql( serial )
end
it "should be able to restrict the serial number to one change (multiple updates)" do
serial = @soa.serial
# Implement some cheap DNS load balancing
Record.batch do
record = A.new(
:domain => @domain,
:name => 'app',
:content => '10.0.0.5',
:ttl => 86400
)
record.save.should be_true
record = A.new(
:domain => @domain,
:name => 'app',
:content => '10.0.0.6',
:ttl => 86400
)
record.save.should be_true
record = A.new(
:domain => @domain,
:name => 'app',
:content => '10.0.0.7',
:ttl => 86400
)
record.save.should be_true
end
# Our serial should have move just one position, not three
@soa.reload
@soa.serial.should_not be( serial )
@soa.serial.to_s.should eql( Time.now.strftime( "%Y%m%d" ) + '01' )
end
end
describe Record, "when created" do
before(:each) do
@domain = Factory(:domain)
@soa = @domain.soa_record
end
it "should update the serial on the SOA" do
serial = @soa.serial
record = A.new(
:domain => @domain,
:name => 'admin',
:content => '10.0.0.5',
:ttl => 86400
)
record.save.should be_true
@soa.reload
@soa.serial.should_not eql(serial)
end
it "should inherit the name from the parent domain if not provided" do
record = A.new(
:domain => @domain,
:content => '10.0.0.6'
)
record.save.should be_true
record.name.should eql('example.com')
end
it "should append the domain name to the name if not present" do
record = A.new(
:domain => @domain,
:name => 'test',
:content => '10.0.0.6'
)
record.save.should be_true
record.shortname.should eql('test')
record.name.should eql('test.example.com')
end
it "should inherit the TTL from the parent domain if not provided" do
ttl = @domain.ttl
ttl.should be( 86400 )
record = A.new(
:domain => @domain,
:name => 'ftp',
:content => '10.0.0.6'
)
record.save.should be_true
record.ttl.should be( 86400 )
end
it "should prefer own TTL over that of parent domain" do
record = A.new(
:domain => @domain,
:name => 'ftp',
:content => '10.0.0.6',
:ttl => 43200
)
record.save.should be_true
record.ttl.should be( 43200 )
end
end
describe Record, "when loaded" do
before(:each) do
domain = Factory(:domain)
@record = Factory(:a, :domain => domain)
end
it "should have a full name" do
@record.name.should eql('example.com')
end
it "should have a short name" do
@record.shortname.should be_blank
end
end
describe Record, "when serializing to XML" do
before(:each) do
domain = Factory(:domain)
@record = Factory(:a, :domain => domain)
end
it "should have a root tag of the record type" do
@record.to_xml.should match(/<a>/)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/models/record_template_spec.rb | spec/models/record_template_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe RecordTemplate, "when new" do
before(:each) do
@record_template = RecordTemplate.new
end
it "should be invalid by default" do
@record_template.should_not be_valid
end
end
describe RecordTemplate, "should inherit" do
before(:each) do
@record_template = RecordTemplate.new
@record_template.zone_template = Factory(:zone_template)
end
it "validations from A" do
@record_template.record_type = 'A'
@record_template.should_not be_valid
@record_template.content = '256.256.256.256'
@record_template.should have(1).error_on(:content)
@record_template.content = 'google.com'
@record_template.should have(1).error_on(:content)
@record_template.content = '10.0.0.9'
@record_template.should have(:no).error_on(:content)
end
it "validations from CNAME" do
@record_template.record_type = 'NS'
@record_template.should_not be_valid
@record_template.should have(2).error_on(:content)
end
it "validations from MX" do
@record_template.record_type = 'MX'
@record_template.should_not be_valid
@record_template.should have(1).error_on(:prio)
@record_template.should have(2).error_on(:content)
@record_template.prio = -10
@record_template.should have(1).error_on(:prio)
# FIXME: Why is priority 0 at this stage?
#@record_template.prio = 'low'
#@record_template.should have(1).error_on(:prio)
@record_template.prio = 10
@record_template.should have(:no).errors_on(:prio)
end
it "validations from NS" do
@record_template.record_type = 'NS'
@record_template.should_not be_valid
@record_template.should have(2).error_on(:content)
end
it "validations from TXT" do
@record_template.record_type = 'TXT'
@record_template.should_not be_valid
@record_template.should have(1).error_on(:content)
end
it "validations from SOA" do
@record_template.record_type = 'SOA'
@record_template.should_not be_valid
@record_template.should have(1).error_on(:primary_ns)
@record_template.should have(1).error_on(:contact)
end
it "convenience methods from SOA" do
@record_template.record_type = 'SOA'
@record_template.primary_ns = 'ns1.%ZONE%'
@record_template.contact = 'admin@example.com'
@record_template.refresh = 7200
@record_template.retry = 1800
@record_template.expire = 604800
@record_template.minimum = 10800
@record_template.content.should eql('ns1.%ZONE% admin@example.com 0 7200 1800 604800 10800')
@record_template.should be_valid
@record_template.save.should be_true
end
end
describe RecordTemplate, "when building" do
before(:each) do
@zone_template = Factory(:zone_template)
end
it "an SOA should replace the %ZONE% token with the provided domain name" do
template = Factory(:template_soa, :zone_template => @zone_template)
record = template.build( 'example.org' )
record.should_not be_nil
record.should be_a_kind_of( SOA )
record.primary_ns.should eql('ns1.example.org')
end
it "an NS should replace the %ZONE% token with the provided domain name" do
template = Factory(:template_ns, :zone_template => @zone_template)
record = template.build( 'example.org' )
record.should_not be_nil
record.should be_a_kind_of( NS )
record.content.should eql('ns1.example.org')
end
it "a MX should replace the %ZONE% token with provided domain name" do
template = Factory(:template_mx, :zone_template => @zone_template)
record = template.build( 'example.org' )
record.should_not be_nil
record.should be_a_kind_of( MX )
record.content.should eql('mail.example.org')
end
end
describe RecordTemplate, "when creating" do
before(:each) do
@zone_template = Factory(:zone_template)
end
it "should inherit the TTL from the ZoneTemplate" do
record_template = RecordTemplate.new( :zone_template => @zone_template )
record_template.record_type = 'A'
record_template.content = '10.0.0.1'
record_template.save.should be_true
record_template.ttl.should be(@zone_template.ttl)
end
it "should prefer own TTL over that of the ZoneTemplate" do
record_template = RecordTemplate.new( :zone_template => @zone_template )
record_template.record_type = 'A'
record_template.content = '10.0.0.1'
record_template.ttl = 43200
record_template.save.should be_true
record_template.ttl.should be(43200)
end
end
describe RecordTemplate, "when loaded" do
it "should have SOA convenience, if an SOA template" do
zone_template = Factory(:zone_template)
record_template = Factory(:template_soa, :zone_template => zone_template)
record_template.primary_ns.should eql('ns1.%ZONE%')
record_template.retry.should be(7200)
end
end
describe RecordTemplate, "when updated" do
it "should handle SOA convenience" do
zone_template = Factory(:zone_template)
record_template = Factory(:template_soa, :zone_template => zone_template, :primary_ns => 'ns1.provider.net')
record_template.primary_ns = 'ns1.provider.net'
record_template.save
record_template.reload
record_template.primary_ns.should eql('ns1.provider.net')
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/models/macro_step_spec.rb | spec/models/macro_step_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe MacroStep, "when new" do
before(:each) do
@macro_step = MacroStep.new
end
it "should be invalid by default" do
@macro_step.should_not be_valid
end
it "should require a macro" do
@macro_step.should have(1).error_on(:macro_id)
end
it "should require an action" do
@macro_step.should have(1).error_on(:action)
end
it "should only accept allowed actions" do
[ 'create', 'remove', 'update' ].each do |valid_action|
@macro_step.action = valid_action
@macro_step.should have(:no).errors_on(:action)
end
@macro_step.action = 'foo'
@macro_step.should have(1).error_on(:action)
end
it "should require a record type" do
@macro_step.should have(1).error_on(:record_type)
end
it "should only accept valid record types" do
Record.record_types.each do |known_record_type|
# We don't apply macro's to SOA records
next if known_record_type == 'SOA'
@macro_step.record_type = known_record_type
@macro_step.should have(:no).errors_on(:record_type)
end
@macro_step.record_type = 'SOA'
@macro_step.should have(1).error_on(:record_type)
end
it "should not require a record name" do
@macro_step.should have(:no).errors_on(:name)
end
it "should require content" do
@macro_step.should have(1).error_on(:content)
end
it "should be active by default" do
@macro_step.should be_active
end
describe "should inherit validations" do
it "from A records" do
@macro_step.record_type = 'A'
@macro_step.content = 'foo'
@macro_step.should have(1).error_on(:content)
@macro_step.should have(:no).errors_on(:name)
end
it "from MX records" do
@macro_step.record_type = 'MX'
@macro_step.should have(1).error_on(:prio)
@macro_step.should have(:no).errors_on(:name)
end
end
end
describe MacroStep, "when created" do
before(:each) do
@macro = Factory(:macro)
@macro_step = MacroStep.create!(
:macro => @macro,
:record_type => 'A',
:action => 'create',
:name => 'cdn',
:content => '127.0.0.8',
:ttl => 86400
)
end
it "should have a position" do
@macro_step.position.should_not be_blank
end
end
describe MacroStep, "for removing records" do
before(:each) do
@macro_step = MacroStep.new
@macro_step.action = 'remove'
end
it "should not require content" do
@macro_step.should have(:no).errors_on(:content)
end
it "should not require prio on MX" do
@macro_step.record_type = 'MX'
@macro_step.should have(:no).errors_on(:prio)
end
end
describe MacroStep, "when building records" do
before(:each) do
@macro_step = MacroStep.new
end
it "should build A records" do
@macro_step.attributes = {
:record_type => 'A',
:name => 'www',
:content => '127.0.0.7'
}
record = @macro_step.build
record.should be_an_instance_of( A )
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/models/ptr_spec.rb | spec/models/ptr_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe PTR do
it "should have tests"
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
globocom/GloboDNS | https://github.com/globocom/GloboDNS/blob/d745871945c76cd26a8c926873b59690ef1ea5a7/spec/models/a_spec.rb | spec/models/a_spec.rb | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe A, "when new" do
before(:each) do
@a = A.new
end
it "should be invalid by default" do
@a.should_not be_valid
end
it "should only accept valid IPv4 addresses as content" do
@a.content = '10'
@a.should have(1).error_on(:content)
@a.content = '10.0'
@a.should have(1).error_on(:content)
@a.content = '10.0.0'
@a.should have(1).error_on(:content)
@a.content = '10.0.0.9/32'
@a.should have(1).error_on(:content)
@a.content = '256.256.256.256'
@a.should have(1).error_on(:content)
@a.content = '10.0.0.9'
@a.should have(:no).error_on(:content)
end
it "should not accept new lines in content" do
@a.content = "10.1.1.1\nHELLO WORLD"
@a.should have(1).error_on(:content)
end
it "should not act as a CNAME" do
@a.content = 'google.com'
@a.should have(1).error_on(:content)
end
end
| ruby | Apache-2.0 | d745871945c76cd26a8c926873b59690ef1ea5a7 | 2026-01-04T17:43:23.539268Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.