23 |
23 |
fixtures :users, :email_addresses, :members, :member_roles, :roles, :projects
|
24 |
24 |
|
25 |
25 |
test "GET /users.xml should return users" do
|
|
26 |
users = User.active.order('login')
|
|
27 |
users.last.update(twofa_scheme: 'totp')
|
26 |
28 |
get '/users.xml', :headers => credentials('admin')
|
27 |
29 |
|
28 |
30 |
assert_response :success
|
29 |
31 |
assert_equal 'application/xml', response.media_type
|
30 |
32 |
assert_select 'users' do
|
31 |
|
users = User.active.order('login')
|
32 |
33 |
assert_select 'user', :count => users.size do |nodeset|
|
33 |
34 |
nodeset.zip(users) do |user_element, user|
|
34 |
35 |
assert_select user_element, 'id', :text => user.id.to_s
|
35 |
36 |
assert_select user_element, 'updated_on', :text => user.updated_on.iso8601
|
|
37 |
assert_select user_element, 'twofa_scheme', :text => user.twofa_scheme.to_s
|
36 |
38 |
|
37 |
39 |
# No one has changed password.
|
38 |
40 |
assert_select user_element, 'passwd_changed_on', :text => ''
|
|
41 |
|
|
42 |
if user == users.last
|
|
43 |
assert_select user_element, 'twofa_scheme', :text => 'totp'
|
|
44 |
else
|
|
45 |
assert_select user_element, 'twofa_scheme', :text => ''
|
|
46 |
end
|
39 |
47 |
end
|
40 |
48 |
end
|
41 |
49 |
end
|
42 |
50 |
end
|
43 |
51 |
|
44 |
52 |
test "GET /users.json should return users" do
|
|
53 |
users = User.active.order('login')
|
|
54 |
users.last.update(twofa_scheme: 'totp')
|
45 |
55 |
get '/users.json', :headers => credentials('admin')
|
46 |
56 |
|
47 |
57 |
assert_response :success
|
... | ... | |
58 |
68 |
|
59 |
69 |
# No one has changed password.
|
60 |
70 |
assert_nil user_json['passwd_changed_on']
|
|
71 |
|
|
72 |
if user == users.last
|
|
73 |
assert_equal 'totp', user_json['twofa_scheme']
|
|
74 |
else
|
|
75 |
assert_nil user_json['twofa_scheme']
|
|
76 |
end
|
61 |
77 |
end
|
62 |
78 |
end
|
63 |
79 |
|
... | ... | |
68 |
84 |
assert_select 'user id', :text => '2'
|
69 |
85 |
assert_select 'user updated_on', :text => Time.zone.parse('2006-07-19T20:42:15Z').iso8601
|
70 |
86 |
assert_select 'user passwd_changed_on', :text => ''
|
|
87 |
assert_select 'user twofa_scheme', :text => ''
|
71 |
88 |
end
|
72 |
89 |
|
73 |
90 |
test "GET /users/:id.json should return the user" do
|
... | ... | |
80 |
97 |
assert_equal 2, json['user']['id']
|
81 |
98 |
assert_equal Time.zone.parse('2006-07-19T20:42:15Z').iso8601, json['user']['updated_on']
|
82 |
99 |
assert_nil json['user']['passwd_changed_on']
|
|
100 |
assert_nil json['user']['twofa_scheme']
|
83 |
101 |
end
|
84 |
102 |
|
85 |
103 |
test "GET /users/:id.xml with include=memberships should include memberships" do
|