diff --git a/Gemfile b/Gemfile index cc2d658ce..bf2124804 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'axlsx', '2.0.1' gem 'sass-rails', '4.0.3'  # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '2.5.0' +# gem 'uglifier', '2.5.0'  # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '4.0.1' @@ -113,4 +113,17 @@ gem 'redis-rails', '4.0.0'  #dependency for sidekiq gem 'connection_pool', '2.2.2' -gem 'redis-namespace', '1.6.0' \ No newline at end of file +gem 'redis-namespace', '1.6.0' + +gem 'domain_name', '0.5.20170404' +gem 'unf', '0.1.4' +gem 'http-cookie', '1.0.3' + +gem 'execjs', '2.7.0' +gem 'uglifier', '2.5.3' +gem 'therubyracer', '0.12.2' + +gem 'stripe', '3.5.0' +gem 'faraday', '0.17.6' +gem 'multipart-post', '1.2.0' +gem 'byebug' \ No newline at end of file diff --git a/app/controllers/v_lans_controller.rb b/app/controllers/v_lans_controller.rb index a7f9a9dba..23b8f895e 100644 --- a/app/controllers/v_lans_controller.rb +++ b/app/controllers/v_lans_controller.rb @@ -2,12 +2,12 @@ class VLansController < ApplicationController include ChangeNetwork include CacheExistence before_filter :authenticate_user! - before_filter :check_network_presence?, only: [:index, :show, :create, :update, :destroy], if: Proc.new { |c| c.request.format.json? } + before_filter :check_network_presence?, only: [:index, :show, :create, :update, :destroy, :add_dhcp_mapping], if: Proc.new { |c| c.request.format.json? } before_filter :dashboard_topbar, if: Proc.new { |c| !c.request.format.json? } - before_action :set_v_lan, only: [:show, :edit, :update, :destroy] + before_action :set_v_lan, only: [:show, :edit, :update, :destroy, :add_dhcp_mapping] before_action :find_radius_configuration,only: [:edit,:new] load_and_authorize_resource :class => VLan - check_policy_for :create, :update, :destroy, with: VLan, id_param: :id + check_policy_for :create, :update, :destroy, :add_dhcp_mapping, with: VLan, id_param: :id  skip_load_resource :only => [:new, :create,:edit,:destroy]  @@ -128,6 +128,31 @@ class VLansController < ApplicationController end end  + def add_dhcp_mapping + @v_lan.dhcp_mappings ||= [] + mapping_params = params.permit(:IPADDR, :MAC) + if params[:dhcp_mapping].present? + mapping_params = params.require(:dhcp_mapping).permit(:IPADDR, :MAC) + end + + new_mapping = { + "IPADDR" => mapping_params[:IPADDR], + "MAC" => mapping_params[:MAC] + } + + mappings = (@v_lan.dhcp_mappings || []).dup + mappings << new_mapping + @v_lan.dhcp_mappings = mappings + + if @v_lan.save + json_data = { data: @v_lan.json_build, status: 200 } + else + json_data = { message: "DHCP mapping not added (Reason: #{@v_lan.errors.full_messages.join(', ')}).", status: 422 } + end + + render json: json_data, status: json_data[:status] + end + private # Use callbacks to share common setup or constraints between actions. def set_v_lan diff --git a/app/models/ability/v_lan_ability.rb b/app/models/ability/v_lan_ability.rb index d6fcd60c5..ac42f7ef1 100644 --- a/app/models/ability/v_lan_ability.rb +++ b/app/models/ability/v_lan_ability.rb @@ -16,9 +16,9 @@ class Ability::VLanAbility < Ability::BaseAbility else case user.role.try(:name) when "customer_care_devices_senior_experts" - can [:read, :update, :verify_ip], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) + can [:read, :update, :verify_ip, :add_dhcp_mapping], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) when "customer_care_devices_experts" - can [:read, :update, :verify_ip], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) + can [:read, :update, :verify_ip, :add_dhcp_mapping], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) when "customer_care_devices_specialists" can :read, VLan, id: VLan.where(location_network_id: user.location_networks.pluck(:id)) when "vendor_techs" @@ -29,7 +29,7 @@ class Ability::VLanAbility < Ability::BaseAbility can :read, VLan, id: VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) when "nw_onboarding_techs" # can :read, VLan, id: VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) - can [:read, :update, :verify_ip], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) + can [:read, :update, :verify_ip, :add_dhcp_mapping], VLan, :id => VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) when "network_r&d" can :manage, VLan, id: VLan.where(location_network_id: user.location_networks.pluck(:id)).pluck(:id) end diff --git a/app/models/v_lan.rb b/app/models/v_lan.rb index efb540d58..b59146890 100644 --- a/app/models/v_lan.rb +++ b/app/models/v_lan.rb @@ -43,6 +43,8 @@ class VLan < ActiveRecord::Base serialize :dhcp_ranges, Array serialize :dhcp_options, Array  + validate :validate_dhcp_mappings + DHCP_SERVER = {"1" => "Disabled", "2" => "Enabled", "3" => "Relay"} FORM_CONST = {"0" => "Disabled", "1" => "Enabled"} def update_redis @@ -138,4 +140,91 @@ class VLan < ActiveRecord::Base def json_build {id: self.id, v_lan_id: self.v_lan_id, ip_address: self.ip_address, net_mask: self.net_mask, dhcp_start_range: self.dhcp_start_range, dhcp_end_range: self.dhcp_end_range, dns1: self.dns1, dns2: self.dns2, gateway: self.gateway, enable_gre_on_v_lan: self.enable_gre_on_v_lan, enable_dhcp_on_v_lan: self.enable_dhcp_on_v_lan, dns_mode: self.dns_mode, dhcp_relay_server: self.dhcp_relay_server, dhcp_mappings: self.dhcp_mappings, dhcp_ranges: self.dhcp_ranges, dhcp_lease_time: self.dhcp_lease_time, nat: self.nat, wna: self.wna, captive_portal: self.captive_portal, splash_url: self.splash_url, wallgarden: self.wallgarden, walled_garden_range: self.walled_garden_range, overwrite_success_url: self.overwrite_success_url, success_url: self.success_url, auth_radius_id: self.auth_radius_id, acc_radius_id: self.acc_radius_id, acc_radius_enabled: self.acc_radius_enabled, per_user_qos: self.per_user_qos, default_interim_time: self.default_interim_time, default_idle_timeout: self.default_idle_timeout, active_scan: self.active_scan, mac_auth: self.mac_auth, uplink_priority: self.uplink_priority, dhcp_options: self.dhcp_options, uam_secret_key: self.uam_secret_key, uam_secret: self.uam_secret} end + + def validate_dhcp_mappings + return if dhcp_mappings.blank? + + unless dhcp_mappings.is_a?(Array) + errors.add(:dhcp_mappings, "must be an array") + return + end + + ips_in_mappings = [] + macs_in_mappings = [] + + dhcp_mappings.each_with_index do |mapping, index| + unless mapping.is_a?(Hash) || (defined?(ActionController::Parameters) && mapping.is_a?(ActionController::Parameters)) + errors.add(:dhcp_mappings, "invalid format at index #{index}") + next + end + + m = mapping.stringify_keys + ip = m['IPADDR'] + mac = m['MAC'] + + # Both IP and MAC are required + if ip.blank? || mac.blank? + errors.add(:dhcp_mappings, "Both IP and MAC is required") + next + end + + # IP format check + ip_regex = /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/ + unless ip =~ ip_regex + errors.add(:dhcp_mappings, "Invalid IP address") + end + + # MAC format check + mac_regex = /^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/ + unless mac =~ mac_regex + errors.add(:dhcp_mappings, "Invalid Mac address") + end + + # Multicast MAC check + if mac.present? && mac.length >= 2 && ['1','3','5','7','9','b','d','f'].include?(mac[1].downcase) + errors.add(:dhcp_mappings, "Multicast MAC not allowed.") + end + + # IP range check + if ip.present? && ip =~ ip_regex && ip_address.present? && net_mask.present? + unless ip_in_subnet?(ip, ip_address, net_mask) + errors.add(:dhcp_mappings, "IP Address is not in the range of IP and Gateway fields!") + end + end + + # IP Conflict checks + clashing_ips = [ip_address, gateway, dns1, dns2, dhcp_start_range, dhcp_end_range].compact.reject(&:empty?) + if clashing_ips.include?(ip) + errors.add(:dhcp_mappings, "Field cannot contain same IP Address!") + end + + # Check for duplicate IPs/MACs in the same request + if ips_in_mappings.include?(ip) + errors.add(:dhcp_mappings, "Duplicate IP address #{ip} in mappings") + end + if macs_in_mappings.include?(mac) + errors.add(:dhcp_mappings, "Duplicate MAC address #{mac} in mappings") + end + + ips_in_mappings << ip + macs_in_mappings << mac + end + end + + private + + def ip_in_subnet?(ip, subnet_ip, netmask) + begin + ip_parts = ip.split('.').map(&:to_i) + subnet_parts = subnet_ip.split('.').map(&:to_i) + mask_parts = netmask.split('.').map(&:to_i) + return false unless ip_parts.length == 4 && subnet_parts.length == 4 && mask_parts.length == 4 +  + (0..3).all? do |i| + (ip_parts[i] & mask_parts[i]) == (subnet_parts[i] & mask_parts[i]) + end + rescue + false + end + end end diff --git a/config/application.yml b/config/application.yml index f46fe42a8..0d76df37b 100644 --- a/config/application.yml +++ b/config/application.yml @@ -9,7 +9,7 @@ defaults: &defaults #Twilio for Wireless SIM Management #Twilio acccount configured as Pronto Account under jas@prontonetworks.com #Twilio Account SID - recaptcha: true + recaptcha: false recaptcha_site_key: '6LcP1sMSAAAAAJNPSFmLyDyVp9Fkzcxr42uVU2gg' recaptcha_secret_key: '6LcP1sMSAAAAANIW6FvcSNQOF3comGuspZqX2gkr' twilio_sid: ACfde9cc4317aab2aa69c98bd92f4e9b68 @@ -42,19 +42,25 @@ defaults: &defaults # "rate":"RATE", # "tsf":"TSF", # "essid":"ESSID", "mode":"MODE", "client_mac": "SRC_MAC", "channel" : "CHANNEL", "last_seen":"TIMESTAMP"} - meraki_2.0: {"mac_id":"apMac","floors":"apFloors", - "tags":"apTags", - "ipv4":"ipv4", - "location":"location", - "ssid":"ssid", - "os":"os", - "seentime":"seenTime", - "ipv6":"ipv6", - "manufacturer":"manufacturer", - "rss":"rssi", "status":"", "client_mac": "clientMac", "last_seen":"seenEpoch"} - SUPER_ADMIN: ["arun@wavespot.net", "ankur@wavespot.net", "jas@wavespot.net","matt@wavespot.net", "kalyan.sannedhi@prontonetworks.net"] + meraki_2.0: { + "mac_id": "apMac", + "floors": "apFloors", + "tags": "apTags", + "ipv4": "ipv4", + "location": "location", + "ssid": "ssid", + "os": "os", + "seentime": "seenTime", + "ipv6": "ipv6", + "manufacturer": "manufacturer", + "rss": "rssi", + "status": "", + "client_mac": "clientMac", + "last_seen": "seenEpoch" + } + SUPER_ADMIN: ["arun@wavespot.net", "ankur@wavespot.net", "arihant.nahar@prontonetworks.ai","yuvraj.singh@prontonetworks.ai","sahil.shaikh@prontonetworks.ai"] #list of allowed MAC ID - macid_allowed_range: ["74:F8:DB", "00:0C:66", "00:16:3E", "78:D3:8D", "04:F0:21", "00:25:22", "FC:B6:98", "00:19:C7", "78:A3:51", "64:9A:12", "C6:58:D6", "44:D1:FA", "78:13:51","20:05:05","30:38:31","BA:39:57","EE:41:60","8E:A3:83","00:18:0A", "7A:66:2D","BA:C8:77","92:A9:9C","DA:8F:BA","14:44:8F", "2E:B2:0F","0A:98:3C","E0:01:A6","04:B6:BE","36:50:6D","A2:C8:5D","F8:8E:A1", "80:8D:B7","02:60:B5","90:3C:B3","E2:DD:29","BA:18:C7","7C:9F:07","00:06:AE","D4:BA:BA","D0:77:CE","98:19:2C","E0:01:06","9A:CE:1B", "4C:B1:CD","80:03:84","90:2D:77","28:99:C7","C4:4B:D1","D0:4F:58","BC:A9:93","00:0E:D8","04:C3:E6","E0:D7:38","E4:9D:73","5C:17:83","A8:27:C8","B4:6A:D4","A4:7D:78","A8:C7:28","7C:8D:9C","D4:DC:85","A8:2B:B5","00:33:58","34:20:E3","84:23:88","FC:5C:45","DC:AE:EB","7C:27:3C","0C:E0:FC", "C0:C9:89", "A0:1A:E3", "24:34:08"] + macid_allowed_range: ["74:F8:DB", "00:0C:66", "00:16:3E", "78:D3:8D", "04:F0:21", "00:25:22", "FC:B6:98", "00:19:C7", "78:A3:51", "64:9A:12", "C6:58:D6", "44:D1:FA", "78:13:51","20:05:05","30:38:31","BA:39:57","EE:41:60","8E:A3:83","00:18:0A", "7A:66:2D","BA:C8:77","92:A9:9C","DA:8F:BA","14:44:8F", "2E:B2:0F","0A:98:3C","E0:01:A6","04:B6:BE","36:50:6D","A2:C8:5D","F8:8E:A1", "80:8D:B7","02:60:B5","90:3C:B3","E2:DD:29","BA:18:C7","7C:9F:07","00:06:AE","D4:BA:BA","D0:77:CE","98:19:2C","E0:01:06","9A:CE:1B", "4C:B1:CD","80:03:84","90:2D:77","28:99:C7","C4:4B:D1","D0:4F:58","BC:A9:93","00:0E:D8","04:C3:E6","E0:D7:38","E4:9D:73","5C:17:83","A8:27:C8","B4:6A:D4","A4:7D:78","A8:C7:28","7C:8D:9C","D4:DC:85","A8:2B:B5","00:33:58","34:20:E3","84:23:88","FC:5C:45","DC:AE:EB","7C:27:3C","0C:E0:FC", "C0:C9:89", "A0:1A:E3", "24:34:08", "FC:8F:C4"] operator_mapping: {"AT&T Mobility": "AT&T LTE", "Sprint Corporation": "SPRINT LTE","Verizon Wireless": "VERIZON LTE", "T-Mobile US": "TMOBILE LTE"} opencell_api_token: "pk.8d14a2cbe1ad74046ce4f63c3d957201" callback_url: "callbackUrl=https://sim.prontonetworks.com/teal_response" @@ -85,21 +91,20 @@ defaults: &defaults VERSION_MATRIX: "v9_0" development: <<: *defaults - heartbeat_url: "http://demo-pcc.wavespot.net:3000/heartbeat" - presence_url: "http://demo-pcc.wavespot.net:3000/presence" - alerts_server_url: "http://demo-pcc.wavespot.net:3000/alerts" - node_url: "http://demo-pcc.wavespot.net:3000" + heartbeat_url: "http://localhost:3000/heartbeat" + presence_url: "http://localhost:3000/presence" + alerts_server_url: "http://localhost:3000/alerts" + node_url: "https://demo-replica.prontonetworks.ai" node_protocol: "https" + default: protocol: "http" - domain: "demo-pcc.wavespot.net" + domain: "207.244.235.152" port: "3000" + redis: host: "localhost" port: "6379" - alerts_sidekiq_redis: - host: "localhost" - port: "6379"  test: <<: *defaults @@ -108,16 +113,15 @@ test: alerts_server_url: "http://live.prontonetworks.com/alerts" node_url: "pcc.wavespot.net:80" node_protocol: "http" + default: protocol: "https" domain: "localhost" port: "3000" + redis: host: "localhost" port: "6379" - alerts_sidekiq_redis: - host: "localhost" - port: "6379"  production: <<: *defaults @@ -126,13 +130,12 @@ production: alerts_server_url: "https://unifi.wavespot.ai/nwalerts" node_url: "https://unifi.wavespot.ai" node_protocol: "https" + default: protocol: "https" domain: "unifi.wavespot.ai" port: "" + redis: - host: "localhost" - port: "6379" - alerts_sidekiq_redis: host: "localhost" port: "6379" \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index f7e8a5b71..02e345779 100644 --- a/config/database.yml +++ b/config/database.yml @@ -7,7 +7,7 @@ development: adapter: mysql2 database: prontooss username: root - password: root + password: Root@123 pool: 5 timeout: 5000  diff --git a/config/routes.rb b/config/routes.rb index e86edec4c..99665e142 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -496,7 +496,11 @@ Oss::Application.routes.draw do get "history_metrics", to: 'monitoring#fetch_history_data' ############################ #VLAN API - resources :vlans, controller: :v_lans, only: [:create, :update, :show, :index, :destroy], param: :vlan_id, format: :json + resources :vlans, controller: :v_lans, only: [:create, :update, :show, :index, :destroy], param: :vlan_id, format: :json do + member do + post :add_dhcp_mappinggit + end + end ############################ #NTP Configuration API get 'ntp_configuration' => 'ntp_servers#index', format: :json diff --git a/db/migrate/20140723154849_change_monitoring_data_format_on_monitoring.rb b/db/migrate/20140723154849_change_monitoring_data_format_on_monitoring.rb index 9172915fe..0a3f1382b 100644 --- a/db/migrate/20140723154849_change_monitoring_data_format_on_monitoring.rb +++ b/db/migrate/20140723154849_change_monitoring_data_format_on_monitoring.rb @@ -1,10 +1,10 @@ class ChangeMonitoringDataFormatOnMonitoring < ActiveRecord::Migration def change - MonitoringChild.all.each do |mc| - if(mc.monitoring_data.is_a? String) - mc.monitoring_data = JSON.parse(mc.monitoring_data.gsub("=>", ":")) - mc.save - end - end + # MonitoringChild.all.each do |mc| + # if(mc.monitoring_data.is_a? String) + # mc.monitoring_data = JSON.parse(mc.monitoring_data.gsub("=>", ":")) + # mc.save + # end + # end end end diff --git a/db/schema.rb b/db/schema.rb index 05da99d71..09cd1ee9e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,12 +11,25 @@ # # It's strongly recommended that you check this file into your version control system.  -ActiveRecord::Schema.define(version: 20170523073658) do +ActiveRecord::Schema.define(version: 20260108120839) do  - create_table "PRADEEP", id: false, force: true do |t| - t.string "FIRST_NAME", limit: 50 - t.integer "AGE" - t.float "INCOME" + create_table "access_control_list_layer_nines", force: true do |t| + t.string "policy" + t.string "protocol" + t.string "src_ip" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "acl_group_id" + t.string "policy_ly7" + t.string "src_domainly7" + t.string "src_bitmaskly7" + t.string "application" + t.string "host_iprange" + t.string "port" + t.string "application_value" + t.string "src_uplink_type" + t.string "src_uplink_typely7" + t.string "src_iply7" end  create_table "access_control_lists", force: true do |t| @@ -31,6 +44,21 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "dst_ip" t.string "dst_bitmask" t.string "dst_port" + t.string "src_uplink_type", default: "All" + t.string "dst_uplink_type", default: "All" + t.string "policy_ly7" + t.string "application" + t.string "host_iprange" + t.string "port" + t.string "form_type" + t.string "application_value" + t.string "src_domainly7" + t.string "src_bitmaskly7" + t.string "form_type2" + t.boolean "is_enabled" + t.boolean "log" + t.integer "priority" + t.string "src_mac" end  create_table "acl_groups", force: true do |t| @@ -40,7 +68,9 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "location_network_id" t.datetime "created_at" t.datetime "updated_at" - t.text "tagging_lists" + t.text "tagging_lists", limit: 255 + t.string "logging" + t.integer "clone_id" end  create_table "acl_inventories", force: true do |t| @@ -63,11 +93,13 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "location_network_id" t.datetime "created_at" t.datetime "updated_at" - t.string "custom_field", default: "1" + t.string "assumed_by" + t.integer "router_inventory_id" end  - add_index "activities", ["owner_id", "owner_type"], name: "index_activities_on_owner_id_and_owner_type", using: :btree - add_index "activities", ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type", using: :btree + add_index "activities", ["organisation_id", "created_at"], name: "index_activities_on_organisation_id_and_created_at" + add_index "activities", ["owner_id", "owner_type"], name: "index_activities_on_owner_id_and_owner_type" + add_index "activities", ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type"  create_table "air_quality_configs", force: true do |t| t.integer "organisation_id" @@ -83,8 +115,11 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "alert_id" t.datetime "created_at" t.datetime "updated_at" + t.integer "clone_id" end  + add_index "alert_rules", ["alert_id", "alert_on"], name: "index_alert_rules_on_alert_id_and_alert_on" + create_table "alerts", force: true do |t| t.string "name" t.text "message" @@ -94,13 +129,30 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" t.integer "location_network_id" t.text "actions" + t.string "subject" + t.integer "clone_id" + t.integer "organisation_id" end  + add_index "alerts", ["location_network_id"], name: "index_alerts_on_location_network_id" + add_index "alerts", ["organisation_id"], name: "index_alerts_on_organisation_id" + create_table "alerts_notification_groups", force: true do |t| t.integer "alert_id" t.integer "notification_group_id" end  + add_index "alerts_notification_groups", ["alert_id"], name: "index_alerts_notification_groups_on_alert_id" + add_index "alerts_notification_groups", ["notification_group_id"], name: "index_alerts_notification_groups_on_notification_group_id" + + create_table "ap_groups", force: true do |t| + t.string "name" + t.text "vendor_details" + t.string "vendor_id" + t.integer "location_network_id" + t.integer "wlan_group_id" + end + create_table "ap_metadata", force: true do |t| t.string "project_name" t.string "location_name" @@ -113,6 +165,29 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  + create_table "approved_firmwares", force: true do |t| + t.integer "upgrade_data_id" + t.string "version" + t.string "approved_hardware_models" + t.integer "organisation_id" + t.integer "hardware_category_id" + t.datetime "schedule_time_slot" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "assume_user_details", force: true do |t| + t.string "token" + t.integer "assume_user_id" + t.integer "token_validity" + t.boolean "status", default: true + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "assume_user_details", ["user_id"], name: "index_assume_user_details_on_user_id" + create_table "client_communications", force: true do |t| t.string "source_interface" t.string "destination_interface" @@ -121,15 +196,17 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "created_at" t.datetime "updated_at" t.integer "priority" + t.integer "unidir", limit: 255, default: 0 end  create_table "commands", force: true do |t| - t.text "aps" + t.text "aps", limit: 255 t.string "commands" t.datetime "created_at" t.datetime "updated_at" t.string "status" - t.text "result" + t.text "result", limit: 255 + t.integer "upgrade_id" end  create_table "commands_router_inventories", id: false, force: true do |t| @@ -137,6 +214,10 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "router_inventory_id" end  + add_index "commands_router_inventories", ["command_id", "router_inventory_id"], name: "commands_router_inventories_c_id_ri_id" + add_index "commands_router_inventories", ["command_id"], name: "index_commands_router_inventories_on_command_id" + add_index "commands_router_inventories", ["router_inventory_id"], name: "commands_router_inventories_ri_id" + create_table "config_mappings", force: true do |t| t.integer "configurable_id" t.string "configurable_type" @@ -146,6 +227,18 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  + add_index "config_mappings", ["configurable_id", "configurable_type"], name: "index_config_mappings_on_configurable_id_and_configurable_type" + add_index "config_mappings", ["resourceable_id", "resourceable_type"], name: "index_config_mappings_on_resourceable_id_and_resourceable_type" + + create_table "customer_credit_cards", force: true do |t| + t.integer "card_number" + t.integer "exp_date" + t.integer "exp_month" + t.integer "cvv" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "del_data_fm_monitorings", force: true do |t| t.datetime "created_at" t.datetime "updated_at" @@ -156,8 +249,11 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "location_network_id" t.datetime "created_at" t.datetime "updated_at" + t.integer "organisation_id" end  + add_index "firewall_configs", ["organisation_id"], name: "index_firewall_configs_on_organisation_id" + create_table "firewall_rules", force: true do |t| t.datetime "created_at" t.datetime "updated_at" @@ -173,16 +269,79 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.boolean "is_enabled" end  + create_table "hardware_categories", force: true do |t| + t.string "name" + t.string "label" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "hardware_parts", force: true do |t| t.string "name" t.string "part_number" t.string "internal_name" t.datetime "created_at" t.datetime "updated_at" - t.boolean "wifi_uplink", default: false - t.boolean "usb", default: false + t.boolean "wifi_uplink", default: false + t.boolean "usb", default: false + t.integer "wired_count", default: 1 + t.integer "port_count" + t.string "vendor_type" + t.string "hardware_category" + t.integer "hardware_category_id" + t.text "port_position" end  + create_table "hotspot20s", force: true do |t| + t.boolean "hotspot_2_0", default: false + t.string "operator_name" + t.string "venue_name" + t.string "venue_operator_language_code" + t.text "venue_type", limit: 255 + t.string "network_type" + t.boolean "internet", default: false + t.text "domain_list" + t.text "roaming_consortium_oi" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "network_ssid_id" + end + + create_table "init_templates", force: true do |t| + t.integer "organisation_id" + t.integer "user_id" + t.string "name" + t.string "template_type" + t.text "details" + t.string "ap_mac_id" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "is_default", default: false + end + + create_table "integration_types", force: true do |t| + t.string "api_key" + t.integer "organisation_id" + t.string "org_id" + t.string "vendor_name" + t.text "details" + t.datetime "created_at" + t.datetime "updated_at" + t.string "level" + t.string "name" + end + + create_table "known_client_mac_ouis", force: true do |t| + t.string "mac_prefix" + t.string "manufacture" + t.string "hostname" + t.integer "organisation_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "known_client_mac_ouis", ["mac_prefix", "organisation_id"], name: "index_known_client_mac_ouis_on_mac_prefix_and_org_id" + create_table "location_networks", force: true do |t| t.string "network_name" t.string "network_type" @@ -193,9 +352,24 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "organisation_id" t.string "timezone" t.boolean "aggregation_flag" - t.integer "hb_freq", default: 5 + t.integer "hb_freq", default: 5 + t.boolean "presence", default: false + t.text "presence_url" + t.string "vendor_network_id" + t.string "vendor_type" + t.text "vendor_details" + t.integer "integration_type_id" + t.string "heartbeat_url" + t.boolean "network_template", default: false + t.boolean "template_adherence", default: true + t.boolean "enable_policy" + t.integer "router_inventories_count", default: 0, null: false + t.text "external_guid" + t.integer "original_cloned_network_id" end  + add_index "location_networks", ["organisation_id"], name: "index_location_networks_on_organisation_id" + create_table "loggings", force: true do |t| t.string "name" t.string "logging_type" @@ -205,8 +379,27 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "extra_data" t.datetime "created_at" t.datetime "updated_at" + t.integer "clone_id" + t.integer "organisation_id" + end + + add_index "loggings", ["location_network_id"], name: "index_loggings_on_location_network_id" + add_index "loggings", ["organisation_id"], name: "index_loggings_on_organisation_id" + + create_table "master_router_inventories", force: true do |t| + t.string "mac_id" + t.integer "hardware_part_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "wan_mac_address" + t.string "serial" + t.integer "integration_type_id" end  + add_index "master_router_inventories", ["hardware_part_id"], name: "index_master_router_inventories_on_hardware_part_id" + add_index "master_router_inventories", ["mac_id"], name: "index_master_router_inventories_on_mac_id" + add_index "master_router_inventories", ["serial"], name: "index_master_router_inventories_on_serial" + create_table "media", force: true do |t| t.integer "attachable_id" t.string "attachable_type" @@ -223,6 +416,16 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  + create_table "nai_realms", force: true do |t| + t.string "realm_name" + t.string "realm_format" + t.string "authentication" + t.text "gpp_plmn_id" + t.integer "hotspot20_id" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "network_ssids", force: true do |t| t.string "ssid_name" t.string "ssid_mode" @@ -240,7 +443,7 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "acl_mac" t.string "mac_filter_policy" t.text "acl_mac_list" - t.integer "vlan_id" + t.integer "vlan_id", limit: 255 t.string "captive_portal" t.text "splash_url" t.string "wallgarden" @@ -259,18 +462,45 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "ssid_qos" t.boolean "enable_ssid_qos" t.string "per_user_qos" - t.string "radio_band", default: "2.4" - t.integer "max_association", default: 0 - t.boolean "wds_enabled", default: false - t.string "dns_mode", default: "1" + t.string "radio_band", default: "2.4" + t.integer "max_association", default: 0 + t.boolean "wds_enabled", default: false + t.string "dns_mode", default: "1" t.string "dns_primary" t.string "dns_secondary" - t.string "wna", default: "1" - t.text "dhcp_mappings", limit: 2147483647 - t.string "default_interim_time", default: "300" - t.string "default_idle_timeout", default: "1800" + t.string "wna", default: "1" + t.text "dhcp_mappings" + t.string "default_interim_time", default: "300" + t.string "default_idle_timeout", default: "1800" + t.string "uplink_priority", default: "1" t.string "dhcp_ranges" - t.string "uplink_priority", default: "1" + t.string "psk_type" + t.integer "mac_auth", default: 0 + t.text "dhcp_options" + t.boolean "power_save", default: false + t.boolean "band_steering", default: false + t.string "roaming_mode", default: "f" + t.string "hotspot_mode", default: "f" + t.string "radio_bands", default: "---\n- '2.4'\n" + t.text "vendor_details" + t.boolean "ssid_802_11_k", default: false + t.string "ssid_802_11_w" + t.string "multi_psk", default: "local" + t.text "multi_psk_options" + t.boolean "uam_secret", default: false + t.string "uam_secret_key" + t.boolean "radius_gw_proxy", default: false + t.integer "clone_id" + t.integer "organisation_id" + end + + add_index "network_ssids", ["location_network_id", "vlan_id"], name: "index_network_ssids_on_location_network_id_and_vlan_id" + add_index "network_ssids", ["location_network_id"], name: "index_network_ssids_on_location_network_id" + add_index "network_ssids", ["organisation_id"], name: "index_network_ssids_on_organisation_id" + + create_table "network_ssids_wlan_groups", id: false, force: true do |t| + t.integer "network_ssid_id" + t.integer "wlan_group_id" end  create_table "notification_groups", force: true do |t| @@ -281,6 +511,7 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "organisation_id" t.datetime "created_at" t.datetime "updated_at" + t.integer "clone_id" end  create_table "ntp_servers", force: true do |t| @@ -289,14 +520,49 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "location_network_id" t.datetime "created_at" t.datetime "updated_at" + t.integer "organisation_id" end  + add_index "ntp_servers", ["organisation_id"], name: "index_ntp_servers_on_organisation_id" + create_table "organisations", force: true do |t| t.string "organisation_name" t.datetime "created_at" t.datetime "updated_at" - t.integer "no_of_aps", default: 200 + t.integer "no_of_aps", default: 200 t.text "sms_config" + t.string "organisation_logo_file_name" + t.string "organisation_logo_content_type" + t.integer "organisation_logo_file_size" + t.datetime "organisation_logo_updated_at" + t.string "organisation_domain" + t.string "organisation_support_email" + t.boolean "branding", default: false + t.string "header_bg_color" + t.string "sidebar_bg_color" + t.string "footer_bg_color" + t.string "live_domain" + t.string "footer_font_bg_color" + t.string "heartbeat_url" + t.text "organisation_settings" + end + + create_table "payment_invoices", force: true do |t| + t.string "payment_status", default: "new" + t.datetime "invoiced_on" + t.integer "organisation_id" + t.integer "router_inventory_id" + t.string "invoice_number" + t.string "stripeToken" + t.integer "purchase_order_id" + t.string "amount" + t.string "transcation_id" + t.string "failure_message" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "ordered_by" + t.string "customer_id" + t.string "customer_email" end  create_table "pf_inventories", force: true do |t| @@ -324,7 +590,42 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "location_network_id" t.datetime "created_at" t.datetime "updated_at" - t.text "tagging_lists" + t.text "tagging_lists", limit: 255 + end + + create_table "purchase_order_items", force: true do |t| + t.integer "purchase_order_id" + t.integer "itemable_id" + t.string "itemable_type" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "purchase_orders", force: true do |t| + t.string "payment_status", default: "new" + t.integer "organisation_id" + t.integer "router_inventory_id" + t.integer "sim_rate_plan_id" + t.string "mac_id" + t.string "amount" + t.string "imei" + t.string "plan_description" + t.boolean "auto_recharge" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "ordered_by" + end + + create_table "radio_managements", force: true do |t| + t.boolean "client_steering" + t.boolean "assoc_steering" + t.boolean "auto_channel_balancing" + t.integer "required_probe_snr" + t.integer "required_roam_snr" + t.integer "load_kick_threshold" + t.integer "radio_profile_id" + t.datetime "created_at" + t.datetime "updated_at" end  create_table "radio_profiles", force: true do |t| @@ -334,18 +635,36 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "created_at" t.datetime "updated_at" t.integer "location_network_id" + t.string "vendor_network_id" + t.text "vendor_details" + t.integer "clone_id" end  + add_index "radio_profiles", ["location_network_id"], name: "index_radio_profiles_on_location_network_id" + add_index "radio_profiles", ["organisation_id"], name: "index_radio_profiles_on_organisation_id" + create_table "radio_settings", force: true do |t| t.string "band" t.integer "channel" t.integer "power" t.integer "radio_profile_id" - t.boolean "is_disable", default: false - t.boolean "country_ie", default: true + t.boolean "is_disable", default: false + t.boolean "country_ie", default: true t.string "require_mode" t.datetime "created_at" t.datetime "updated_at" + t.string "bandwidth" + t.boolean "channel_utlilization" + t.integer "maximum_clients" + t.string "multiple_bssid" + t.string "beacon_rate" + t.integer "beacon_interval" + t.integer "dtim_period" + t.string "multicast" + t.string "ema" + t.integer "bss_color" + t.text "vendor_details" + t.text "valid_auto_channel", limit: 4294967295 end  create_table "radius", force: true do |t| @@ -367,6 +686,8 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "organisation_id" t.datetime "created_at" t.datetime "updated_at" + t.text "vendor_details" + t.integer "clone_id" end  create_table "reports", force: true do |t| @@ -379,6 +700,25 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "flag" t.string "path" t.integer "scheduled_report_id" + t.string "download_type" + t.integer "organisation_id" + end + + add_index "reports", ["location_network_id"], name: "index_reports_on_location_network_id" + add_index "reports", ["organisation_id"], name: "index_reports_on_organisation_id" + + create_table "roamings", force: true do |t| + t.string "message_exchange" + t.string "domain_identifier" + t.string "pmk_r1_type" + t.string "pmk_r0_type" + t.string "pmk_r1_key_holder" + t.boolean "generate_psk", default: false + t.string "pmk_r0_key_holder" + t.integer "network_ssid_id" + t.integer "organisation_id" + t.datetime "created_at" + t.datetime "updated_at" end  create_table "roles", force: true do |t| @@ -389,8 +729,8 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  - add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree - add_index "roles", ["name"], name: "index_roles_on_name", using: :btree + add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" + add_index "roles", ["name"], name: "index_roles_on_name"  create_table "router_inventories", force: true do |t| t.string "mac_id" @@ -447,8 +787,29 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "retry_ip2" t.string "sim_iccid" t.string "sim_imei" + t.text "presence_url" + t.string "kernal_version" + t.boolean "is_auto_provisioned", default: false + t.boolean "enable_pci", default: false + t.string "ttl", default: "0" + t.string "operator" + t.string "operator_band" + t.string "serial" + t.string "model" + t.text "vendor_details" + t.integer "ap_group_id" + t.text "external_guid" + t.string "current_firmware" + t.string "previous_firmware" + t.string "build_number" + t.boolean "firmware_locked" + t.string "device_status" end  + add_index "router_inventories", ["location_network_id"], name: "index_router_inventories_on_location_network_id" + add_index "router_inventories", ["mac_id"], name: "index_router_inventories_on_mac_id" + add_index "router_inventories", ["organisation_id"], name: "index_router_inventories_on_organisation_id" + create_table "scheduled_reports", force: true do |t| t.string "title" t.datetime "from_time" @@ -466,27 +827,54 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "notification_group_id" end  + create_table "sessions", force: true do |t| + t.string "email" + t.datetime "logged_in_time" + t.datetime "last_active_at" + t.integer "assume_user_detail_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "sessions", ["assume_user_detail_id"], name: "index_sessions_on_assume_user_detail_id" + create_table "sim_managements", force: true do |t| - t.boolean "is_active", default: false t.string "mac_id" t.string "plan_type" - t.string "invoice_number" - t.datetime "purchased_on" - t.datetime "activated_on" t.string "iccid" t.string "imei" t.integer "organisation_id" t.integer "router_inventory_id" + t.integer "rate_plan_id" + t.integer "sim_rate_plan_id" + t.string "activated_on" + t.string "is_active", default: "false" + t.datetime "created_at" + t.datetime "updated_at" + t.string "data_limit" + t.string "sid" + t.boolean "auto_recharge" + t.string "current_status" + end + + create_table "sim_payments", force: true do |t| + t.string "stripeToken" + t.string "amount" + t.string "invoice_number" + t.integer "organisation_id" + t.integer "sim_management_id" t.datetime "created_at" t.datetime "updated_at" end  create_table "sim_rate_plans", force: true do |t| - t.string "start_date" - t.string "end_date" + t.string "plan_description" + t.string "amount" + t.string "plan_id" t.string "plan_type" t.datetime "created_at" t.datetime "updated_at" + t.string "data_plan" end  create_table "snmp_configs", force: true do |t| @@ -500,6 +888,19 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "rw_community" t.datetime "created_at" t.datetime "updated_at" + t.text "tagging_lists", limit: 255 + end + + create_table "sqms", force: true do |t| + t.boolean "is_enabled" + t.string "uplink" + t.integer "download_speed" + t.integer "upload_speed" + t.string "queuing_disciplines" + t.string "queue_setup_script" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "organisation_id" t.text "tagging_lists" end  @@ -513,6 +914,8 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  + add_index "static_routes", ["organisation_id"], name: "index_static_routes_on_organisation_id" + create_table "static_routing_lists", force: true do |t| t.string "network" t.string "bitmask" @@ -522,6 +925,44 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "updated_at" end  + create_table "switch_configurations", force: true do |t| + t.integer "organisation_id" + t.integer "location_network_id" + t.string "switch_model" + t.integer "hardware_part_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "sw_mac_oui" + t.integer "clone_id" + end + + add_index "switch_configurations", ["location_network_id"], name: "index_switch_configurations_on_location_network_id" + add_index "switch_configurations", ["organisation_id"], name: "index_switch_configurations_on_organisation_id" + + create_table "switch_port_configurations", force: true do |t| + t.integer "port_number" + t.string "name" + t.boolean "port_status" + t.string "link_negotiation" + t.integer "speed" + t.integer "power" + t.boolean "poe" + t.string "vlan" + t.boolean "port_isolation" + t.integer "switch_configuration_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "native_vlan", default: 1 + t.boolean "rstp", default: false + t.string "port_type" + t.boolean "acl_mac", default: false + t.string "mac_filter_policy" + t.text "acl_mac_list" + t.integer "clone_id" + end + + add_index "switch_port_configurations", ["switch_configuration_id"], name: "index_switch_port_configurations_on_switch_configuration_id" + create_table "taggings", force: true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -532,14 +973,22 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "created_at" end  - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree + add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true  create_table "tags", force: true do |t| t.string "name" t.integer "taggings_count", default: 0 end  - add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree + add_index "tags", ["name"], name: "index_tags_on_name", unique: true + + create_table "template_policies", force: true do |t| + t.text "unlock_controls", limit: 4294967295 + t.boolean "disable_unlock_controls", default: false + t.integer "location_network_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + end  create_table "unities", force: true do |t| t.integer "role_id" @@ -549,19 +998,28 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "created_at" t.datetime "updated_at" t.string "permission" + t.integer "locatable_id" + t.string "locatable_type" end  + add_index "unities", ["locatable_id", "locatable_type"], name: "index_unities_on_locatable_id_and_locatable_type" + add_index "unities", ["location_network_id"], name: "index_unities_on_location_network_id" + add_index "unities", ["user_id"], name: "index_unities_on_user_id" + create_table "upgrade_data", force: true do |t| t.string "version" - t.text "url" + t.text "url", limit: 4294967295 t.datetime "created_at" t.datetime "updated_at" - t.string "upload_time" + t.text "upload_time", limit: 4294967295 + t.boolean "is_released", default: false + t.integer "organisation_id" + t.text "fw_checksum" end  create_table "upgrades", force: true do |t| t.string "version" - t.text "aps" + t.text "aps", limit: 255 t.datetime "created_at" t.datetime "updated_at" t.integer "organisation_id" @@ -572,13 +1030,20 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "schedule_at" t.string "time_zone" t.string "worker_job_id" - t.boolean "save_prev_config", default: true + t.boolean "save_prev_config", default: true + end + + add_index "upgrades", ["router_inventory_id"], name: "index_upgrades_on_router_inventory_id" + + create_table "uplink_connectivities", force: true do |t| + t.integer "uid" + t.string "connectivity_time" end  create_table "uplinks", force: true do |t| t.integer "router_inventory_id" t.string "wl_association" - t.boolean "wds_enabled", default: false + t.boolean "wds_enabled", default: false t.string "wl_wpa_key" t.string "wl_band" t.string "wl_ssid_name" @@ -592,28 +1057,50 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "ip" t.string "subnet_mask" t.string "gateway" - t.string "uplink_type", default: "1" + t.string "uplink_type", default: "1" t.string "primary_dns" t.string "secondary_dns" t.datetime "created_at" t.datetime "updated_at" - t.integer "load_balance_percentage", default: 0 - t.boolean "is_primary", default: false + t.integer "load_balance_percentage", default: 0 + t.boolean "is_primary", default: false t.string "uplink_name" t.string "mo_proto_key" - t.boolean "mo_is_advanced", default: false + t.boolean "mo_is_advanced", default: false t.string "pppoe_username" t.string "pppoe_password" - t.string "dns_mode" + t.string "dns_mode", default: "1" + t.boolean "is_deleted", default: false + t.string "last_mobile_status" + t.string "last_seen_ip" + t.integer "hb_type", default: 1 + t.integer "hb_interval", default: 5 + t.string "uplink_module", default: "1" + t.string "ttl", default: "0" + t.string "operator" + t.text "operator_band", limit: 255 + t.string "nt" + t.string "mm" + t.string "cid" + t.string "lac" + t.string "lat" + t.string "lng" + t.string "default_lbc" + t.string "eid" + t.string "imsi" + t.text "mwan3_cfg" + t.string "public_ip" end  + add_index "uplinks", ["is_deleted", "router_inventory_id"], name: "index_uplinks_on_is_deleted_and_router_inventory_id" + create_table "users", force: true do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" @@ -631,14 +1118,18 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.datetime "confirmation_sent_at" t.string "unconfirmed_email" t.integer "role_id" - t.boolean "approved", default: false, null: false - t.boolean "is_super_admin", default: false + t.boolean "approved", default: false, null: false + t.boolean "is_super_admin", default: false + t.string "access_token" + t.text "network_tags", limit: 255 + t.text "claimed_devices" + t.string "user_type" end  - add_index "users", ["approved"], name: "index_users_on_approved", using: :btree - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree - add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["approved"], name: "index_users_on_approved" + add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true + add_index "users", ["email"], name: "index_users_on_email", unique: true + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true  create_table "users_notification_groups", force: true do |t| t.integer "user_id" @@ -650,7 +1141,7 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "role_id" end  - add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree + add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"  create_table "v_lans", force: true do |t| t.integer "organisation_id" @@ -671,26 +1162,40 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "name" t.string "dns_mode" t.string "dhcp_relay_server" - t.text "dhcp_mappings", limit: 2147483647 - t.text "dhcp_ranges", limit: 2147483647 + t.text "dhcp_mappings" + t.text "dhcp_ranges" t.string "dhcp_lease_time" - t.string "nat", default: "1" - t.string "wna", default: "1" + t.string "nat", default: "1" + t.string "wna", default: "1" t.string "captive_portal" t.text "splash_url" t.string "wallgarden" t.text "walled_garden_range" - t.string "overwrite_success_url", default: "false" + t.string "overwrite_success_url", default: "false" t.text "success_url" t.string "auth_radius_id" t.string "acc_radius_id" t.string "acc_radius_enabled" t.string "per_user_qos" - t.string "default_interim_time", default: "300" - t.string "default_idle_timeout", default: "1800" + t.string "default_interim_time", default: "300" + t.string "default_idle_timeout", default: "1800" t.integer "location_network_id" + t.boolean "active_scan", default: false + t.integer "mac_auth", default: 0 + t.string "uplink_priority", default: "1" + t.text "dhcp_options" + t.string "uam_secret_key" + t.boolean "uam_secret", default: false + t.string "qos_bw", default: "0" + t.boolean "enable_vlan_qos", default: false + t.string "vlan_qos" + t.integer "clone_id" end  + add_index "v_lans", ["location_network_id"], name: "index_v_lans_on_location_network_id" + add_index "v_lans", ["network_ssid_id"], name: "index_v_lans_on_network_ssid_id" + add_index "v_lans", ["organisation_id", "location_network_id"], name: "index_v_lans_on_org_and_location_network" + create_table "vpn_configs", force: true do |t| t.string "name" t.string "ike_time" @@ -705,15 +1210,69 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.integer "location_network_id" t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_server", default: true - t.boolean "enable_server_client", default: false + t.boolean "is_server", default: true + t.boolean "enable_server_client", default: false + t.string "tunnel_connection" + t.string "pass_through" + t.boolean "enable_gateway" + t.string "gateway_ip" + t.boolean "enable_nat" + t.string "vpn_name" + t.string "protocol" + t.string "private_key" + t.string "public_key" + t.string "address" + t.string "dns_servers" + t.string "peer_public_key" + t.string "peer_pre_shared_key" + t.string "end_point" + t.text "allowed_ips" + t.string "local_ip" + t.string "local_port" + t.string "wireguard" + t.string "listener_port" + t.string "mtu" + t.text "server_peer" + t.boolean "wireguard_enable_gateway" + t.string "wireguard_gateway_ip" + t.boolean "wireguard_enable_nat" + t.string "psk" + t.string "end_point_ip" + t.string "end_point_port" + t.string "wireguard_passthrough" + t.text "server_p_allowed_ips" + t.integer "organisation_id" + end + + add_index "vpn_configs", ["organisation_id"], name: "index_vpn_configs_on_organisation_id" + + create_table "webhook_endpoints", force: true do |t| + t.string "url", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "notification_group_id" + t.string "name" + t.boolean "enabled", default: true + t.string "shared_key" + end + + create_table "webhook_events", force: true do |t| + t.integer "webhook_endpoint_id", null: false + t.string "event", null: false + t.text "payload", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "response", limit: 4294967295 + t.integer "location_network_id" + t.integer "organisation_id" + t.boolean "is_test", default: false end  create_table "wired_configs", force: true do |t| t.string "name" - t.string "mode", default: "0" - t.string "nat", default: "1" - t.boolean "is_enabled", default: true + t.string "mode", default: "0" + t.string "nat", default: "1" + t.boolean "is_enabled", default: true t.integer "location_network_id" t.string "acl_mac" t.string "mac_filter_policy" @@ -722,7 +1281,7 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.text "splash_url" t.string "wallgarden" t.text "walled_garden_range" - t.string "overwrite_success_url", default: "false" + t.string "overwrite_success_url", default: "false" t.text "success_url" t.string "dhcp_range_start" t.string "dhcp_range_end" @@ -736,25 +1295,40 @@ ActiveRecord::Schema.define(version: 20170523073658) do t.string "ssid_qos" t.boolean "enable_ssid_qos" t.string "per_user_qos" - t.integer "max_association", default: 0 + t.integer "max_association", default: 0 t.datetime "created_at" t.datetime "updated_at" - t.string "dns_mode", default: "1" + t.string "dns_mode", default: "1" t.string "dns_primary" t.string "dns_secondary" - t.string "wna", default: "0" - t.text "dhcp_mappings", limit: 2147483647 - t.string "default_interim_time", default: "300" - t.string "default_idle_timeout", default: "1800" - t.text "port_configs", limit: 2147483647 + t.string "wna", default: "0" + t.text "dhcp_mappings" + t.string "default_interim_time", default: "300" + t.string "default_idle_timeout", default: "1800" + t.text "port_configs" t.string "custom_port" - t.string "enabled", default: "1" + t.string "enabled", default: "1" t.string "dhcp_ranges" + t.integer "clone_id" + t.integer "organisation_id" end  + add_index "wired_configs", ["location_network_id"], name: "index_wired_configs_on_location_network_id" + add_index "wired_configs", ["organisation_id"], name: "index_wired_configs_on_organisation_id" + create_table "wired_configs_v_lans", force: true do |t| t.integer "wired_config_id" t.integer "v_lan_id" end  + add_index "wired_configs_v_lans", ["v_lan_id"], name: "index_wired_configs_v_lans_on_v_lan_id" + add_index "wired_configs_v_lans", ["wired_config_id"], name: "index_wired_configs_v_lans_on_wired_config_id" + + create_table "wlan_groups", force: true do |t| + t.string "name" + t.text "vendor_details" + t.string "vendor_id" + t.integer "location_network_id" + end + end diff --git a/test/controllers/v_lans_controller_test.rb b/test/controllers/v_lans_controller_test.rb index b484d5923..647206c0f 100644 --- a/test/controllers/v_lans_controller_test.rb +++ b/test/controllers/v_lans_controller_test.rb @@ -1,8 +1,23 @@ require 'test_helper'  class VLansControllerTest < ActionController::TestCase + include Devise::TestHelpers + setup do + @user = users(:one) + @user.is_super_admin = true + @user.save! + sign_in @user + + @network = location_networks(:one) + @network.organisation_id = @user.organisation_id + @network.save! + @v_lan = v_lans(:one) + @v_lan.organisation_id = @user.organisation_id + @v_lan.location_network_id = @network.id + @v_lan.v_lan_id = "1" + @v_lan.save! end  test "should get index" do @@ -18,7 +33,7 @@ class VLansControllerTest < ActionController::TestCase  test "should create v_lan" do assert_difference('VLan.count') do - post :create, v_lan: { dhcp_end_range: @v_lan.dhcp_end_range, dhcp_start_range: @v_lan.dhcp_start_range, dns1: @v_lan.dns1, dns2: @v_lan.dns2, gateway: @v_lan.gateway, ip_address: @v_lan.ip_address, ip_type: @v_lan.ip_type, net_mask: @v_lan.net_mask, network_ssid_id: @v_lan.network_ssid_id, organisation_id: @v_lan.organisation_id, v_lan_id: @v_lan.v_lan_id } + post :create, v_lan: { dhcp_end_range: @v_lan.dhcp_end_range, dhcp_start_range: @v_lan.dhcp_start_range, dns1: @v_lan.dns1, dns2: @v_lan.dns2, gateway: @v_lan.gateway, ip_address: @v_lan.ip_address, ip_type: @v_lan.ip_type, net_mask: @v_lan.net_mask, network_ssid_id: @v_lan.network_ssid_id, organisation_id: @v_lan.organisation_id, v_lan_id: "2" } end  assert_redirected_to v_lan_path(assigns(:v_lan)) @@ -46,4 +61,49 @@ class VLansControllerTest < ActionController::TestCase  assert_redirected_to v_lans_path end + + test "should add dhcp mapping via API" do + @v_lan.v_lan_id = "10" + @v_lan.ip_address = "192.168.1.1" + @v_lan.net_mask = "255.255.255.0" + @v_lan.gateway = "192.168.1.254" + @v_lan.dhcp_mappings = [] + @v_lan.save! + + post :add_dhcp_mapping, { + network_id: @network.id, + vlan_id: @v_lan.v_lan_id, + IPADDR: "192.168.1.15", + MAC: "00:11:22:33:44:55", + format: :json + } + + assert_response :success + json = JSON.parse(response.body) + assert_equal 200, json['status'] + assert_equal "192.168.1.15", json['data']['dhcp_mappings'].last['IPADDR'] + assert_equal "00:11:22:33:44:55", json['data']['dhcp_mappings'].last['MAC'] + end + + test "should fail to add invalid dhcp mapping via API" do + @v_lan.v_lan_id = "10" + @v_lan.ip_address = "192.168.1.1" + @v_lan.net_mask = "255.255.255.0" + @v_lan.gateway = "192.168.1.254" + @v_lan.dhcp_mappings = [] + @v_lan.save! + + post :add_dhcp_mapping, { + network_id: @network.id, + vlan_id: @v_lan.v_lan_id, + IPADDR: "192.168.2.15", + MAC: "00:11:22:33:44:55", + format: :json + } + + assert_response 422 + json = JSON.parse(response.body) + assert_equal 422, json['status'] + assert_match /IP Address is not in the range of IP and Gateway fields!/, json['message'] + end end diff --git a/test/fixtures/alerts.yml b/test/fixtures/alerts.yml index ffe3fc357..42df97467 100644 --- a/test/fixtures/alerts.yml +++ b/test/fixtures/alerts.yml @@ -1,30 +1,11 @@ -# == Schema Information -# -# Table name: alerts -# -# id :integer not null, primary key -# name :string(255) -# message :text -# category :string(255) -# severity_color :string(255) -# created_at :datetime -# updated_at :datetime -# location_network_id :integer -# actions :text -# - -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - one: name: MyString message: MyText category: MyString - tagging_lists: MyText severity_color: MyString  two: name: MyString message: MyText category: MyString - tagging_lists: MyText severity_color: MyString diff --git a/test/fixtures/firewall_rules.yml b/test/fixtures/firewall_rules.yml index 602c0ecd5..f21d1e1f6 100644 --- a/test/fixtures/firewall_rules.yml +++ b/test/fixtures/firewall_rules.yml @@ -1,20 +1,5 @@ -# == Schema Information -# -# Table name: firewall_rules -# -# id :integer not null, primary key -# created_at :datetime -# updated_at :datetime -# +one: + id: 1  -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value +two: + id: 2 diff --git a/test/fixtures/monitorings.yml b/test/fixtures/monitorings.yml deleted file mode 100644 index c63aac0b6..000000000 --- a/test/fixtures/monitorings.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/notification_groups.yml b/test/fixtures/notification_groups.yml index b7cd75d70..4a8926559 100644 --- a/test/fixtures/notification_groups.yml +++ b/test/fixtures/notification_groups.yml @@ -1,15 +1,13 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html  one: - type:  + notification_type: MyString mobile: MyString email: MyString - user_id: 1 organisation_id: 1  two: - type:  + notification_type: MyString mobile: MyString email: MyString - user_id: 1 organisation_id: 1 diff --git a/test/fixtures/radio_profiles.yml b/test/fixtures/radio_profiles.yml index 92273f1db..62d770f3d 100644 --- a/test/fixtures/radio_profiles.yml +++ b/test/fixtures/radio_profiles.yml @@ -14,12 +14,10 @@  one: name: MyString - is_enable: false country_code: MyString - country_ie: false + organisation_id: 1  two: name: MyString - is_enable: false country_code: MyString - country_ie: false + organisation_id: 1 diff --git a/test/fixtures/radio_settings.yml b/test/fixtures/radio_settings.yml index e560141c0..dbbf670eb 100644 --- a/test/fixtures/radio_settings.yml +++ b/test/fixtures/radio_settings.yml @@ -1,29 +1,9 @@ -# == Schema Information -# -# Table name: radio_settings -# -# id :integer not null, primary key -# band :string(255) -# channel :integer -# power :integer -# radio_profile_id :integer -# is_disable :boolean default(FALSE) -# country_ie :boolean default(TRUE) -# require_mode :string(255) -# created_at :datetime -# updated_at :datetime -# - -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - one: band: MyString - name: MyString channel: 1 power: 1  two: band: MyString - name: MyString channel: 1 power: 1 diff --git a/test/fixtures/radius.yml b/test/fixtures/radius.yml index c63aac0b6..f21d1e1f6 100644 --- a/test/fixtures/radius.yml +++ b/test/fixtures/radius.yml @@ -1,11 +1,5 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html +one: + id: 1  -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value +two: + id: 2 diff --git a/test/fixtures/radius_accountings.yml b/test/fixtures/radius_accountings.yml index c63aac0b6..f21d1e1f6 100644 --- a/test/fixtures/radius_accountings.yml +++ b/test/fixtures/radius_accountings.yml @@ -1,11 +1,5 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html +one: + id: 1  -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value +two: + id: 2 diff --git a/test/fixtures/reports.yml b/test/fixtures/reports.yml index 5934465c2..f4eecfd62 100644 --- a/test/fixtures/reports.yml +++ b/test/fixtures/reports.yml @@ -19,9 +19,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html  one: - name: MyString - generated: 2014-09-06 16:42:40 + title: MyString  two: - name: MyString - generated: 2014-09-06 16:42:40 + title: MyString