Permalink
Browse files

add change password by name

Change-Id: Ic9e565443e4eab84f55e2891e17ce55ca66bd1c6
  • Loading branch information...
1 parent 3342b83 commit f0a820376ab5a5ecd8116db0efb6ea23689f8479 @daleolds daleolds committed Mar 10, 2012
Showing with 23 additions and 10 deletions.
  1. +12 −2 gem/lib/uaa/user_account.rb
  2. +11 −8 gem/spec/integration_spec.rb
@@ -86,11 +86,21 @@ def delete(user_id)
end
def delete_by_name(username)
- qinfo = query_by_value(:id, :username, username)
+ delete user_id_from_name(username)
+ end
+
+ def change_password_by_name(username, new_password)
+ change_password(user_id_from_name(username), new_password)
+ end
+
+ private
+
+ def user_id_from_name(name)
+ qinfo = query_by_value(:id, :username, name)
unless qinfo && qinfo[:resources] && qinfo[:resources][0] && qinfo[:resources][0][:id]
raise NotFound, "user #{username} not found in #{@target}"
end
- delete qinfo[:resources][0][:id]
+ qinfo[:resources][0][:id]
end
end
@@ -14,9 +14,9 @@
require 'spec_helper'
require 'uaa'
-ENV["UAA_CLIENT_ID"] = "scim"
-ENV["UAA_CLIENT_SECRET"] = "scimsecret"
-ENV["UAA_CLIENT_TARGET"] = "http://localhost:8080/uaa"
+#ENV["UAA_CLIENT_ID"] = "scim"
+#ENV["UAA_CLIENT_SECRET"] = "scimsecret"
+#ENV["UAA_CLIENT_TARGET"] = "http://localhost:8080/uaa"
if ENV["UAA_CLIENT_ID"] && ENV["UAA_CLIENT_SECRET"] && ENV["UAA_CLIENT_TARGET"]
@@ -57,23 +57,26 @@
puts usr[:id]
end
- it "finds the user" do
+ it "finds the user by name" do
user_info = @user_acct.query_by_value("id", "username", @username)
puts JSON.pretty_generate(user_info)
puts user_info
end
- it "gets the user" do
+ it "gets the user by id" do
user_id = ENV["UAA_USER_ID"]
user_info = @user_acct.get(user_id)
puts JSON.pretty_generate(user_info)
puts user_info[:meta][:version]
end
+ it "changes the user's password by name" do
+ @user_acct.change_password_by_name(@username, "newpassword")
+ # TODO: query that the user is gone
+ end
+
it "deletes the user by name" do
- user_id = ENV["UAA_USER_ID"]
- puts user_id
- @user_acct.delete(user_id)
+ @user_acct.delete_by_name(@username)
# TODO: query that the user is gone
end

0 comments on commit f0a8203

Please sign in to comment.