| | 51 | |
|---|
| | 52 | # Test the index method |
|---|
| | 53 | |
|---|
| | 54 | def test_index |
|---|
| | 55 | |
|---|
| | 56 | # Test the index page |
|---|
| | 57 | |
|---|
| | 58 | get :index |
|---|
| | 59 | assert_response :success |
|---|
| | 60 | |
|---|
| | 61 | |
|---|
| | 62 | # Check that the subtitle is set to 'Device Administration' |
|---|
| | 63 | |
|---|
| | 64 | assert_tag :tag => "div", |
|---|
| | 65 | :attributes => { :class => 'title' }, |
|---|
| | 66 | :descendant => { :tag => 'div', :attributes => { :class => 'title_line_2' }, :child => 'Device Administration' } |
|---|
| | 67 | |
|---|
| | 68 | end |
|---|
| | 69 | |
|---|
| | 70 | |
|---|
| | 71 | # Test the new device method |
|---|
| | 72 | |
|---|
| | 73 | def test_new_device |
|---|
| | 74 | |
|---|
| | 75 | get :new |
|---|
| | 76 | assert_response :success |
|---|
| | 77 | |
|---|
| | 78 | |
|---|
| | 79 | # Check that the subtitle is set to 'Device Administration: New Device' |
|---|
| | 80 | |
|---|
| | 81 | assert_tag :tag => "div", |
|---|
| | 82 | :attributes => { :class => 'title' }, |
|---|
| | 83 | :descendant => { :tag => 'div', :attributes => { :class => 'title_line_2' }, :child => 'Device Administration: New Device' } |
|---|
| | 84 | |
|---|
| | 85 | |
|---|
| | 86 | # Check that the necessary fields exist on the page and are empty |
|---|
| | 87 | |
|---|
| | 88 | assert_tag :tag => "input", |
|---|
| | 89 | :attributes => { :id => 'device_hostname', :name => 'device[hostname]', :type => 'text' } |
|---|
| | 90 | |
|---|
| | 91 | assert_tag :tag => "input", |
|---|
| | 92 | :attributes => { :id => 'device_description', :name => 'device[description]', :type => 'text' } |
|---|
| | 93 | |
|---|
| | 94 | assert_tag :tag => "select", |
|---|
| | 95 | :attributes => { :id => 'device_site_id', :name => 'device[site_id]' } |
|---|
| | 96 | |
|---|
| | 97 | assert_tag :tag => "input", |
|---|
| | 98 | :attributes => { :id => 'device_description', :name => 'device[description]', :type => 'text' } |
|---|
| | 99 | |
|---|
| | 100 | |
|---|
| | 101 | # For SNMPv1, we should have a radio button and an input box for the |
|---|
| | 102 | # community string, with a warning dialogue regarding GETBULK |
|---|
| | 103 | |
|---|
| | 104 | assert_tag :tag => "input", |
|---|
| | 105 | :attributes => { :id => 'device_snmp_version_1', :name => 'device[snmp_version]', :type => 'radio' } |
|---|
| | 106 | |
|---|
| | 107 | assert_tag :tag => "input", |
|---|
| | 108 | :attributes => { :id => 'device_snmp_community', :name => 'device[snmp_community]', :type => 'text' } |
|---|
| | 109 | |
|---|
| | 110 | assert_tag :tag => "p", |
|---|
| | 111 | :descendant => { :tag => 'strong', :child => /GETBULK/ } |
|---|
| | 112 | |
|---|
| | 113 | |
|---|
| | 114 | |
|---|
| | 115 | # For SNMPv2, we should have a radio button and an input box for the |
|---|
| | 116 | # community string |
|---|
| | 117 | |
|---|
| | 118 | assert_tag :tag => "input", |
|---|
| | 119 | :attributes => { :id => 'device_snmp_version_2', :name => 'device[snmp_version]', :type => 'radio' } |
|---|
| | 120 | |
|---|
| | 121 | assert_tag :tag => "input", |
|---|
| | 122 | :attributes => { :id => 'device_snmp_community', :name => 'device[snmp_community]', :type => 'text' } |
|---|
| | 123 | |
|---|
| | 124 | |
|---|
| | 125 | # For SNMPv3, we should have a radio button, security level selection, |
|---|
| | 126 | # authentication and privacy protocols and passphrases, and a security |
|---|
| | 127 | # name field |
|---|
| | 128 | |
|---|
| | 129 | assert_tag :tag => "input", |
|---|
| | 130 | :attributes => { :id => 'device_snmp_version_3', :name => 'device[snmp_version]', :type => 'radio' } |
|---|
| | 131 | |
|---|
| | 132 | assert_tag :tag => "select", |
|---|
| | 133 | :attributes => { :id => 'snmpv3_security_level_', :name => 'snmpv3_security_level[]' }, |
|---|
| | 134 | :descendant => { :tag => 'option', :attributes => { :value => 'noAuthNoPriv' } } |
|---|
| | 135 | |
|---|
| | 136 | assert_tag :tag => "select", |
|---|
| | 137 | :attributes => { :id => 'snmpv3_security_level_', :name => 'snmpv3_security_level[]' }, |
|---|
| | 138 | :descendant => { :tag => 'option', :attributes => { :value => 'authNoPriv' } } |
|---|
| | 139 | |
|---|
| | 140 | assert_tag :tag => "select", |
|---|
| | 141 | :attributes => { :id => 'snmpv3_security_level_', :name => 'snmpv3_security_level[]' }, |
|---|
| | 142 | :descendant => { :tag => 'option', :attributes => { :value => 'authPriv' } } |
|---|
| | 143 | |
|---|
| | 144 | # TODO: Write tests for SNMPv3 authentication protocol elements and security name |
|---|
| | 145 | |
|---|
| | 146 | # Finally, the form should have an input tag |
|---|
| | 147 | |
|---|
| | 148 | assert_tag :tag => "input", |
|---|
| | 149 | :attributes => { :name => 'commit', :type => 'submit', :value => 'Create' } |
|---|
| | 150 | |
|---|
| | 151 | |
|---|
| | 152 | end |
|---|
| | 153 | |
|---|