{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Identity/pulls/comments/28029827","id":28029827,"diff_hunk":"@@ -128,15 +128,56 @@ protected RoleManager<TRole> CreateRoleManager(object context = null, IServiceCo\n         }\n \n         [Fact]\n-        public async Task CanSetUserName()\n+        public async Task CheckSetUserNameValidatesUser()\n         {\n             var manager = CreateManager();\n-            var user = CreateTestUser(\"UpdateAsync\");\n+            manager.UserValidators.Add(new UserValidator<TUser>());\n+            var username = \"UpdateAsync\" + Guid.NewGuid().ToString();\n+            var newUsername = \"New\" + Guid.NewGuid().ToString();\n+            var user = CreateTestUser(username, useNamePrefixAsUserName: true);\n+            IdentityResultAssert.IsSuccess(await manager.CreateAsync(user));\n+            Assert.Null(await manager.FindByNameAsync(newUsername));\n+            IdentityResultAssert.IsSuccess(await manager.SetUserNameAsync(user, newUsername));\n+            Assert.NotNull(await manager.FindByNameAsync(newUsername));\n+            Assert.Null(await manager.FindByNameAsync(username));\n+\n+            var newUser = CreateTestUser(username, useNamePrefixAsUserName: true);\n+            IdentityResultAssert.IsSuccess(await manager.CreateAsync(newUser));\n+            IdentityResultAssert.IsFailure(await manager.SetUserNameAsync(newUser, \"\"), IdentityErrorDescriber.Default.InvalidUserName(\"\"));\n+            IdentityResultAssert.IsFailure(await manager.SetUserNameAsync(newUser, newUsername), IdentityErrorDescriber.Default.DuplicateUserName(newUsername));\n+        }\n+\n+        [Fact]\n+        public async Task SetUserNameUpdatesSecurityStamp()\n+        {\n+            var manager = CreateManager();\n+            var username = \"UpdateAsync\" + Guid.NewGuid().ToString();\n+            var newUsername = \"New\" + Guid.NewGuid().ToString();\n+            var user = CreateTestUser(username, useNamePrefixAsUserName: true);\n             IdentityResultAssert.IsSuccess(await manager.CreateAsync(user));\n-            Assert.Null(await manager.FindByNameAsync(\"New\"));\n-            IdentityResultAssert.IsSuccess(await manager.SetUserNameAsync(user, \"New\"));\n-            Assert.NotNull(await manager.FindByNameAsync(\"New\"));\n-            Assert.Null(await manager.FindByNameAsync(\"UpdateAsync\"));\n+            var stamp = await manager.GetSecurityStampAsync(user);\n+            Assert.Null(await manager.FindByNameAsync(newUsername));\n+            IdentityResultAssert.IsSuccess(await manager.SetUserNameAsync(user, newUsername));\n+            Assert.NotEqual(stamp, await manager.GetSecurityStampAsync(user));\n+        }\n+\n+        [Fact]\n+        public async Task CheckSetEmailValidatesUser()\n+        {\n+            var manager = CreateManager();\n+            manager.Options.User.RequireUniqueEmail = true;\n+            manager.UserValidators.Add(new UserValidator<TUser>());\n+            var random = new Random();\n+            var email = \"foo\" + random.Next() + \"@example.com\";\n+            var newEmail = \"foo\" + random.Next() + \"@example.com\";","path":"test/Shared/UserManagerTestBase.cs","position":51,"original_position":51,"commit_id":"2636268f99162b2baed8cce2169c0332ca5b75eb","original_commit_id":"2636268f99162b2baed8cce2169c0332ca5b75eb","user":{"login":"suhasj","id":1919946,"avatar_url":"https://avatars.githubusercontent.com/u/1919946?v=3","gravatar_id":"","url":"https://api.github.com/users/suhasj","html_url":"https://github.com/suhasj","followers_url":"https://api.github.com/users/suhasj/followers","following_url":"https://api.github.com/users/suhasj/following{/other_user}","gists_url":"https://api.github.com/users/suhasj/gists{/gist_id}","starred_url":"https://api.github.com/users/suhasj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suhasj/subscriptions","organizations_url":"https://api.github.com/users/suhasj/orgs","repos_url":"https://api.github.com/users/suhasj/repos","events_url":"https://api.github.com/users/suhasj/events{/privacy}","received_events_url":"https://api.github.com/users/suhasj/received_events","type":"User","site_admin":false},"body":"sure","created_at":"2015-04-09T01:42:37Z","updated_at":"2015-04-09T01:42:37Z","html_url":"https://github.com/aspnet/Identity/pull/438#discussion_r28029827","pull_request_url":"https://api.github.com/repos/aspnet/Identity/pulls/438","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/comments/28029827"},"html":{"href":"https://github.com/aspnet/Identity/pull/438#discussion_r28029827"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/438"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Identity/pulls/438","id":32916754,"html_url":"https://github.com/aspnet/Identity/pull/438","diff_url":"https://github.com/aspnet/Identity/pull/438.diff","patch_url":"https://github.com/aspnet/Identity/pull/438.patch","issue_url":"https://api.github.com/repos/aspnet/Identity/issues/438","number":438,"state":"open","locked":false,"title":"Correct user manager setter","user":{"login":"suhasj","id":1919946,"avatar_url":"https://avatars.githubusercontent.com/u/1919946?v=3","gravatar_id":"","url":"https://api.github.com/users/suhasj","html_url":"https://github.com/suhasj","followers_url":"https://api.github.com/users/suhasj/followers","following_url":"https://api.github.com/users/suhasj/following{/other_user}","gists_url":"https://api.github.com/users/suhasj/gists{/gist_id}","starred_url":"https://api.github.com/users/suhasj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suhasj/subscriptions","organizations_url":"https://api.github.com/users/suhasj/orgs","repos_url":"https://api.github.com/users/suhasj/repos","events_url":"https://api.github.com/users/suhasj/events{/privacy}","received_events_url":"https://api.github.com/users/suhasj/received_events","type":"User","site_admin":false},"body":"@HaoK @divega \r\nThe old PR was not restored, hence this new one. \r\n\r\nChanges\r\n- removed the private method for UpdateUserName since the normalizedUsername is called on UpdateUserAsync method\r\n- Added unit test to check validation happen on set username/ password","created_at":"2015-04-09T00:57:09Z","updated_at":"2015-04-09T01:42:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"94640fd9e992452412099d59c9dd17fa740e0e90","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Identity/pulls/438/commits","review_comments_url":"https://api.github.com/repos/aspnet/Identity/pulls/438/comments","review_comment_url":"https://api.github.com/repos/aspnet/Identity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Identity/issues/438/comments","statuses_url":"https://api.github.com/repos/aspnet/Identity/statuses/2636268f99162b2baed8cce2169c0332ca5b75eb","head":{"label":"aspnet:CorrectUserManagerSetter","ref":"CorrectUserManagerSetter","sha":"2636268f99162b2baed8cce2169c0332ca5b75eb","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16491880,"name":"Identity","full_name":"aspnet/Identity","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Identity","description":"Membership system for building ASP.NET web applications, including membership, login, and user data.","fork":false,"url":"https://api.github.com/repos/aspnet/Identity","forks_url":"https://api.github.com/repos/aspnet/Identity/forks","keys_url":"https://api.github.com/repos/aspnet/Identity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Identity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Identity/teams","hooks_url":"https://api.github.com/repos/aspnet/Identity/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Identity/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Identity/events","assignees_url":"https://api.github.com/repos/aspnet/Identity/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Identity/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Identity/tags","blobs_url":"https://api.github.com/repos/aspnet/Identity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Identity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Identity/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Identity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Identity/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Identity/languages","stargazers_url":"https://api.github.com/repos/aspnet/Identity/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Identity/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Identity/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Identity/subscription","commits_url":"https://api.github.com/repos/aspnet/Identity/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Identity/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Identity/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Identity/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Identity/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Identity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Identity/merges","archive_url":"https://api.github.com/repos/aspnet/Identity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Identity/downloads","issues_url":"https://api.github.com/repos/aspnet/Identity/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Identity/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Identity/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Identity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Identity/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Identity/releases{/id}","created_at":"2014-02-03T20:23:53Z","updated_at":"2015-04-08T21:10:00Z","pushed_at":"2015-04-09T00:57:09Z","git_url":"git://github.com/aspnet/Identity.git","ssh_url":"git@github.com:aspnet/Identity.git","clone_url":"https://github.com/aspnet/Identity.git","svn_url":"https://github.com/aspnet/Identity","homepage":"","size":7832,"stargazers_count":334,"watchers_count":334,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":51,"forks":104,"open_issues":51,"watchers":334,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"07d9e864506794d93a03bc68efd825d935013e8f","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16491880,"name":"Identity","full_name":"aspnet/Identity","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Identity","description":"Membership system for building ASP.NET web applications, including membership, login, and user data.","fork":false,"url":"https://api.github.com/repos/aspnet/Identity","forks_url":"https://api.github.com/repos/aspnet/Identity/forks","keys_url":"https://api.github.com/repos/aspnet/Identity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Identity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Identity/teams","hooks_url":"https://api.github.com/repos/aspnet/Identity/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Identity/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Identity/events","assignees_url":"https://api.github.com/repos/aspnet/Identity/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Identity/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Identity/tags","blobs_url":"https://api.github.com/repos/aspnet/Identity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Identity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Identity/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Identity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Identity/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Identity/languages","stargazers_url":"https://api.github.com/repos/aspnet/Identity/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Identity/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Identity/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Identity/subscription","commits_url":"https://api.github.com/repos/aspnet/Identity/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Identity/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Identity/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Identity/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Identity/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Identity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Identity/merges","archive_url":"https://api.github.com/repos/aspnet/Identity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Identity/downloads","issues_url":"https://api.github.com/repos/aspnet/Identity/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Identity/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Identity/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Identity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Identity/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Identity/releases{/id}","created_at":"2014-02-03T20:23:53Z","updated_at":"2015-04-08T21:10:00Z","pushed_at":"2015-04-09T00:57:09Z","git_url":"git://github.com/aspnet/Identity.git","ssh_url":"git@github.com:aspnet/Identity.git","clone_url":"https://github.com/aspnet/Identity.git","svn_url":"https://github.com/aspnet/Identity","homepage":"","size":7832,"stargazers_count":334,"watchers_count":334,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":51,"forks":104,"open_issues":51,"watchers":334,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/438"},"html":{"href":"https://github.com/aspnet/Identity/pull/438"},"issue":{"href":"https://api.github.com/repos/aspnet/Identity/issues/438"},"comments":{"href":"https://api.github.com/repos/aspnet/Identity/issues/438/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/438/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Identity/pulls/438/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Identity/statuses/2636268f99162b2baed8cce2169c0332ca5b75eb"}}}}