コード例 #1
0
            public void ApiKeyRemovedMessageIsCorrect()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Username = "******"
                };
                var cred = new CredentialBuilder().CreateApiKey(TimeSpan.FromDays(1));

                cred.Description = "new api key";
                var messageService = new TestableMessageService();

                messageService.MockAuthService
                .Setup(a => a.DescribeCredential(cred))
                .Returns(new CredentialViewModel
                {
                    Description = cred.Description
                });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal(string.Format(Strings.Emails_CredentialRemoved_Subject, TestGalleryOwner.DisplayName, Strings.CredentialType_ApiKey), message.Subject);
                Assert.Contains(string.Format(Strings.Emails_ApiKeyRemoved_Body, cred.Description), message.Body);
            }
コード例 #2
0
            public void UsesProviderNounToDescribeCredentialIfPresent()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Username = "******"
                };
                var cred           = new CredentialBuilder().CreateExternalCredential("MicrosoftAccount", "abc123", "Test User");
                var messageService = new TestableMessageService();

                messageService.MockAuthService
                .Setup(a => a.DescribeCredential(cred))
                .Returns(new CredentialViewModel {
                    AuthUI = new AuthenticatorUI("sign in", "Microsoft Account", "Microsoft Account")
                });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Microsoft Account removed from your account", message.Subject);
                Assert.Contains("A Microsoft Account was removed from your account", message.Body);
            }
コード例 #3
0
            public void UsesTypeCaptionToDescribeCredentialIfNoProviderNounPresent()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Username = "******"
                };
                var cred           = new CredentialBuilder().CreatePasswordCredential("bogus");
                var messageService = new TestableMessageService();

                messageService.MockAuthService
                .Setup(a => a.DescribeCredential(cred))
                .Returns(new CredentialViewModel()
                {
                    TypeCaption = "Password"
                });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Password removed from your account", message.Subject);
                Assert.Contains("A Password was removed from your account", message.Body);
            }
コード例 #4
0
            public void UsesTypeCaptionToDescribeCredentialIfNoProviderNounPresent()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Username = "******"
                };
                var cred           = new CredentialBuilder().CreatePasswordCredential("bogus");
                var messageService = new TestableMessageService();

                messageService.MockAuthService
                .Setup(a => a.DescribeCredential(cred))
                .Returns(new CredentialViewModel()
                {
                    TypeCaption = Strings.CredentialType_Password
                });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal(string.Format(Strings.Emails_CredentialRemoved_Subject, TestGalleryOwner.DisplayName, Strings.CredentialType_Password), message.Subject);
                Assert.Contains(string.Format(Strings.Emails_CredentialRemoved_Body, Strings.CredentialType_Password), message.Body);
            }
コード例 #5
0
            public void UsesProviderNounToDescribeCredentialIfPresent()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Username = "******"
                };
                var          cred = new CredentialBuilder().CreateExternalCredential("MicrosoftAccount", "abc123", "Test User");
                const string MicrosoftAccountCredentialName = "Microsoft Account";
                var          messageService = new TestableMessageService();

                messageService.MockAuthService
                .Setup(a => a.DescribeCredential(cred))
                .Returns(new CredentialViewModel
                {
                    AuthUI = new AuthenticatorUI("sign in", "register", MicrosoftAccountCredentialName)
                });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal(string.Format(Strings.Emails_CredentialRemoved_Subject, TestGalleryOwner.DisplayName, MicrosoftAccountCredentialName), message.Subject);
                Assert.Contains(string.Format(Strings.Emails_CredentialRemoved_Body, MicrosoftAccountCredentialName), message.Body);
            }
コード例 #6
0
            public void UsesTypeCaptionToDescribeCredentialIfNoProviderNounPresent()
            {
                var user = new User { EmailAddress = "*****@*****.**", Username = "******" };
                var cred = CredentialBuilder.CreatePbkdf2Password("bogus");
                var messageService = new TestableMessageService();
                messageService.MockAuthService
                    .Setup(a => a.DescribeCredential(cred))
                    .Returns(new CredentialViewModel() {
                        TypeCaption = "Password"
                    });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Password removed from your account", message.Subject);
                Assert.Contains("A Password was removed from your account", message.Body);
            }
コード例 #7
0
            public void UsesProviderNounToDescribeCredentialIfPresent()
            {
                var user = new User { EmailAddress = "*****@*****.**", Username = "******" };
                var cred = CredentialBuilder.CreateExternalCredential("MicrosoftAccount", "abc123", "Test User");
                var messageService = new TestableMessageService();
                messageService.MockAuthService
                    .Setup(a => a.DescribeCredential(cred))
                    .Returns(new CredentialViewModel() {
                        AuthUI = new AuthenticatorUI("sign in", "Microsoft Account", "Microsoft Account")
                    });

                messageService.SendCredentialRemovedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Microsoft Account removed from your account", message.Subject);
                Assert.Contains("A Microsoft Account was removed from your account", message.Body);
            }