environment_test.rb
5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require 'test_helper'
class EnvironmentTest < ActiveSupport::TestCase
def setup
@enviroment = Environment.default
end
should 'have ldap_plugin variable defined' do
assert_equal Hash, @enviroment.ldap_plugin.class
end
should 'return an empty hash by default on ldap_plugin_attributes method' do
assert_equal Hash.new, @enviroment.ldap_plugin_attributes
end
should 'ldap_plugin_host= define the ldap host' do
host = "http://something"
@enviroment.ldap_plugin_host= host
assert_equal host, @enviroment.ldap_plugin['host']
end
should 'ldap_plugin_host return the defined ldap host' do
host = "http://something"
@enviroment.ldap_plugin_host= host
assert_equal host, @enviroment.ldap_plugin_host
end
should 'ldap_plugin_port= define the ldap port' do
value = 255
@enviroment.ldap_plugin_port= value
assert_equal value, @enviroment.ldap_plugin['port']
end
should 'ldap_plugin_port return the defined ldap port' do
value = 255
@enviroment.ldap_plugin_port= value
assert_equal value, @enviroment.ldap_plugin_port
end
should 'default ldap_plugin_port be 389' do
assert_equal 389, @enviroment.ldap_plugin_port
end
should 'ldap_plugin_account= define the ldap acccount' do
value = 'uid=sector,ou=Service,ou=corp,dc=company,dc=com,dc=br'
@enviroment.ldap_plugin_account= value
assert_equal value, @enviroment.ldap_plugin['account']
end
should 'ldap_plugin_account return the defined ldap account' do
value = 'uid=sector,ou=Service,ou=corp,dc=company,dc=com,dc=br'
@enviroment.ldap_plugin_account= value
assert_equal value, @enviroment.ldap_plugin_account
end
should 'ldap_plugin_account_password= define the ldap acccount_password' do
value = 'password'
@enviroment.ldap_plugin_account_password= value
assert_equal value, @enviroment.ldap_plugin['account_password']
end
should 'ldap_plugin_account_password return the defined ldap account password' do
value = 'password'
@enviroment.ldap_plugin_account_password= value
assert_equal value, @enviroment.ldap_plugin_account_password
end
should 'ldap_plugin_base_dn= define the ldap base_dn' do
value = 'dc=company,dc=com,dc=br'
@enviroment.ldap_plugin_base_dn= value
assert_equal value, @enviroment.ldap_plugin['base_dn']
end
should 'ldap_plugin_base_dn return the defined ldap base_dn' do
value = 'dc=company,dc=com,dc=br'
@enviroment.ldap_plugin_base_dn= value
assert_equal value, @enviroment.ldap_plugin_base_dn
end
should 'ldap_plugin_attr_login= define the ldap attr_login' do
value = 'uid'
@enviroment.ldap_plugin_attr_login= value
assert_equal value, @enviroment.ldap_plugin['attr_login']
end
should 'ldap_plugin_attr_login return the defined ldap attr_login' do
value = 'uid'
@enviroment.ldap_plugin_attr_login= value
assert_equal value, @enviroment.ldap_plugin_attr_login
end
should 'ldap_plugin_attr_fullname= define the ldap attr_fullname' do
value = 'Noosfero System'
@enviroment.ldap_plugin_attr_fullname= value
assert_equal value, @enviroment.ldap_plugin['attr_fullname']
end
should 'ldap_plugin_attr_fullname return the defined ldap attr_fullname' do
value = 'uid'
@enviroment.ldap_plugin_attr_fullname= value
assert_equal value, @enviroment.ldap_plugin_attr_fullname
end
should 'ldap_plugin_attr_mail= define the ldap attr_mail' do
value = 'test@noosfero.com'
@enviroment.ldap_plugin_attr_mail= value
assert_equal value, @enviroment.ldap_plugin['attr_mail']
end
should 'ldap_plugin_attr_mail return the defined ldap attr_mail' do
value = 'test@noosfero.com'
@enviroment.ldap_plugin_attr_mail= value
assert_equal value, @enviroment.ldap_plugin_attr_mail
end
should 'ldap_plugin_onthefly_register= define the ldap onthefly_register' do
value = '1'
@enviroment.ldap_plugin_onthefly_register= value
assert @enviroment.ldap_plugin['onthefly_register']
end
should 'ldap_plugin_onthefly_register return true if ldap onthefly_register variable is defined as true' do
value = '1'
@enviroment.ldap_plugin_onthefly_register= value
assert @enviroment.ldap_plugin_onthefly_register
end
should 'ldap_plugin_onthefly_register return false if ldap onthefly_register variable is defined as false' do
value = '0'
@enviroment.ldap_plugin_onthefly_register= value
assert !@enviroment.ldap_plugin_onthefly_register
end
should 'ldap_plugin_filter= define the ldap filter' do
value = 'test'
@enviroment.ldap_plugin_filter= value
assert_equal value, @enviroment.ldap_plugin['filter']
end
should 'ldap_plugin_filter return the defined ldap filter' do
value = 'test'
@enviroment.ldap_plugin_filter= value
assert_equal value, @enviroment.ldap_plugin_filter
end
should 'ldap_plugin_tls= define the ldap tls' do
value = '1'
@enviroment.ldap_plugin_tls= value
assert @enviroment.ldap_plugin['tls']
end
should 'tls return true if ldap tls variable is defined as true' do
value = '1'
@enviroment.ldap_plugin_tls= value
assert @enviroment.ldap_plugin_tls
end
should 'tls return false if ldap tls variable is defined as false' do
value = '0'
@enviroment.ldap_plugin_tls= value
assert !@enviroment.ldap_plugin_tls
end
should 'validates presence of host' do
@enviroment.ldap_plugin= {:port => 3000}
@enviroment.valid?
assert @enviroment.errors.include?(:ldap_plugin_host)
@enviroment.ldap_plugin_host= "http://somehost.com"
@enviroment.valid?
assert !@enviroment.errors.include?(:ldap_plugin_host)
end
should 'validates presence of host only if some ldap configuration is defined' do
@enviroment.valid?
assert !@enviroment.errors.include?(:ldap_plugin_host)
@enviroment.ldap_plugin= {:port => 3000}
@enviroment.valid?
assert @enviroment.errors.include?(:ldap_plugin_host)
end
end