public void GenerateTokenWithUnrecognizedTokenProviderNameThrows()
        {
            IDelegatedApp client    = this.GetDelegatedClient();
            string        pinNumber = "141414";

            UseUnrecognizedTokenProvider();
            AspenException exception = Assert.Throws <AspenException>(() => client.Token.GenerateToken(pinNumber));

            Assert.That(exception.EventId, Is.EqualTo("15898"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotImplemented));
            StringAssert.IsMatch("No se reconoce el nombre el proveedor de token transaccionales configurado para la aplicación", exception.Message);
        }
示例#2
0
        public void ThrowArgumentNullException_WhenLeagueServiceIsNull()
        {
            var gameService = new Mock <IGameService>();
            var viewMock    = new Mock <IScoresView>();

            viewMock.Setup(v => v.Model).Returns(new ScoresViewModel());

            var actualMessage = Assert.Throws <ArgumentNullException>(
                () => new ScoresPresenter(viewMock.Object, gameService.Object, null));

            StringAssert.IsMatch("leagueService", actualMessage.ParamName);
        }
示例#3
0
        public async Task VersionDoesntHaveCommitHash()
        {
            var transport       = new MockTransport(new MockResponse(200));
            var telemetryPolicy = HttpPipelineBuilder.CreateTelemetryPolicy(new TestOptions());

            await SendGetRequest(transport, telemetryPolicy);

            Assert.True(transport.SingleRequest.TryGetHeader("User-Agent", out var userAgent));
            StringAssert.IsMatch(Regex.Escape("azsdk-net-Core.Tests/") +
                                 "[.\\-0-9a-z]+" +
                                 Regex.Escape($" ({RuntimeInformation.FrameworkDescription}; {RuntimeInformation.OSDescription})"), userAgent);
        }
        public void GetStatementsByAliasUnrecognizedEnrollmentAliasThrows()
        {
            IAutonomousApp client    = this.GetAutonomousClient();
            string         channelId = "5845EDE2-6593-4183-A2B5-280EA15F89E4";
            string         unrecognizedEnrollmentAlias = new Random().Next(1000000000, int.MaxValue).ToString();
            string         accountId = new Random().Next(999, 9999).ToString();
            AspenException exception = Assert.Throws <AspenException>(() => client.Inquiries.GetStatementsByAlias(channelId, unrecognizedEnrollmentAlias, accountId));

            Assert.That(exception.EventId, Is.EqualTo("15881"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            StringAssert.IsMatch("No se ha encontrado información de enrolamiento con los valores suministrados", exception.Message);
        }
示例#5
0
        public void NotFoundValidTokenWhenAppSignedRequestThrows()
        {
            IAutonomousApp client      = this.GetAutonomousClient();
            IAppIdentity   appIdentity = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().RemoveAppAuthToken(appIdentity.ApiKey);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15847"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No hay un token de autenticación vigente", exception.Message);
        }
        public void CopyToChangeDropFolder_WithSimpleOutput_PutsOutputInChangeDropFolderWithNumbers()
        {
            var sut        = MakeTestableRoundhouseMigrationRunner(false, true);
            var dropFolder = MakeMigrationsFolder("folderName", A.Dummy <bool>(), A.Dummy <bool>());

            sut.CopyToChangeDropFolder("folder1\\file1.sql", dropFolder);
            sut.CopyToChangeDropFolder("folder2\\file2.sql", dropFolder);
            sut.CopyToChangeDropFolder("folder3\\file3.sql", dropFolder);
            StringAssert.IsMatch("-> " + FOLDER_PATH + @"\\change_drop\\scripts\\individualScripts\\2\d\d_file1.sql", sut.CheckFilesCopied.ToString());
            StringAssert.IsMatch("-> " + FOLDER_PATH + @"\\change_drop\\scripts\\individualScripts\\2\d\d_file2.sql", sut.CheckFilesCopied.ToString());
            StringAssert.IsMatch("-> " + FOLDER_PATH + @"\\change_drop\\scripts\\individualScripts\\2\d\d_file3.sql", sut.CheckFilesCopied.ToString());
        }
        public void ShouldEvaluateIf()
        {
            GetPageContent("ng_watch_ng_if.htm");
            IWebElement  button    = ngDriver.FindElement(By.CssSelector("button.btn"));
            NgWebElement ng_button = new NgWebElement(ngDriver, button);
            Object       state     = ng_button.Evaluate("!house.frontDoor.isOpen");

            Assert.IsTrue(Convert.ToBoolean(state));
            StringAssert.IsMatch("house.frontDoor.open()", button.GetAttribute("ng-click"));
            StringAssert.IsMatch("Open Door", button.Text);
            button.Click();
        }
        public void EvaluateRequestedDateTime_RequiresArgument_NotBeforeMaxLifetime()
        {
            IHttpActionResult badRequest = null;
            DateTime          parsed;
            string            argumentBeforeLifetime = _lifetimeStub.Since.AddHours(-1).ToIso8061BasicString();

            bool success = _controller.EvaluateRequestedDateTime(argumentBeforeLifetime, out parsed, out badRequest);

            Assert.IsFalse(success);
            Assert.IsNotNull(badRequest as BadRequestErrorMessageResult);
            StringAssert.IsMatch("provided.+earlier than.+lifetime", (badRequest as BadRequestErrorMessageResult).Message);
        }
示例#9
0
        public void ApiKeyDisabledUserSigninRequestThrows()
        {
            IAppIdentity appIdentity = DelegatedAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().UpdateEnabled(appIdentity.ApiKey, false);
            AspenException exception = Assert.Throws <AspenException>(() => this.GetDelegatedClient());

            Assert.That(exception.EventId, Is.EqualTo("20006"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
            StringAssert.IsMatch("ApiKey está desactivado. Póngase en contacto con el administrador", exception.Message);
            TestContext.CurrentContext.DatabaseHelper().UpdateEnabled(appIdentity.ApiKey, true);
        }
示例#10
0
        public void AppRequiresChangeSecretWhenUserSigninRequestThrows()
        {
            IAppIdentity appIdentity = DelegatedAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().UpdateChangeSecret(appIdentity.ApiKey, true);
            AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient());

            Assert.That(exception.EventId, Is.EqualTo("20009"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.UpgradeRequired));
            StringAssert.IsMatch("Necesita actualizar el secreto de la aplicación.", exception.Message);
            TestContext.CurrentContext.DatabaseHelper().UpdateChangeSecret(appIdentity.ApiKey, false);
        }
示例#11
0
        public void DictionaryToString()
        {
            var dict         = Dictionary.ByKeysValues(new string[] { "A", "B", "C", "D" }, new object[] { 1, 2, 3, 4 });
            var dictAsString = dict.ToString();

            // Entries can be in any order, so this is a safe way to assert the result.
            StringAssert.Contains("A:1", dictAsString);
            StringAssert.Contains("B:2", dictAsString);
            StringAssert.Contains("C:3", dictAsString);
            StringAssert.Contains("D:4", dictAsString);
            StringAssert.IsMatch(@"\{\w:\d,\w:\d,\w:\d,\w:\d\}", dictAsString);
        }
示例#12
0
 public async Task SelectSkipTake()
 {
     await using (var db = await GetDbContext <SelectContext>())
     {
         var query = db.Set <MonAttachment>()
                     .Skip(1)
                     .Take(3);
         Assert.DoesNotThrowAsync(() => query.LoadAsync());
         var sql = db.LastCommandText;
         StringAssert.IsMatch(@"ROWS \((.+) \+ 1\) TO \(\1 \+ .+\)", sql);
     }
 }
示例#13
0
        public void GetAppSettingsUsingAutonomousApiKeyThrows()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();
            string         autonomousApiKey = AutonomousAppIdentity.Master.ApiKey;
            AspenException exception        = Assert.Throws <AspenException>(() => client.Settings.GetAppSettings(autonomousApiKey));

            Assert.That(exception.EventId, Is.EqualTo("1000478"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
            StringAssert.IsMatch("ApiKey no tiene permisos para realizar la operación. Alcance requerido: 'Delegated'", exception.Message);
        }
        public void DoorOpen_RunnigMicrowaveAndCanceling_Test(string result)
        {
            _door.Open();
            _powerButton.Press();
            _timeButton.Press();
            _startCancelButton.Press();
            var constraint = Is.True.After(2000);

            Assert.That(() => true, constraint);
            _startCancelButton.Press();
            StringAssert.IsMatch(result, _stringWriter.ToString());
        }
示例#15
0
 public void ApiException_CanExtract_RequestId()
 {
     try
     {
         var _ = _factory.Api <PortfoliosApi>().GetPortfolio("doesnt", "exist");
     }
     catch (ApiException e)
     {
         var requestId = e.GetRequestId();
         StringAssert.IsMatch(RequestIdRegexPattern, requestId);
     }
 }
示例#16
0
        public void should_have_named_anchors_inserted_by_headers_in_html()
        {
            // Arrange
            TocParser tocParser = new TocParser();
            string    html      = GetHtml();

            // Act
            string actual = tocParser.InsertToc(html);

            // Assert
            StringAssert.IsMatch(@"<h2><a name=\"".*?""></a>First h2</h2>", actual);
        }
        public void InvalidFormatPayloadWhenUserSignedRequestThrows()
        {
            IAutonomousApp  client = this.GetAutonomousClient();
            IHeadersManager invalidPayloadHeaderBehavior = InvalidPayloadHeader.WithHeaderBehavior(() => "Lorem ipsum dolor sit amet, consetetur sadipscing elitr");

            ServiceLocator.Instance.RegisterHeadersManager(invalidPayloadHeaderBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("20007"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("El contenido de la cabecera personalizada 'X-PRO-Auth-Payload' no es válido", exception.Message);
        }
示例#18
0
        public void MismatchTokenSignatureWhenAppSignedRequestThrows()
        {
            IAutonomousApp client            = this.GetAutonomousClient();
            IAppIdentity   appIdentityMaster = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().EnsureMismatchAppAuthToken(appIdentityMaster.ApiKey);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15846"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No coinciden los datos recibidos del token vs los valores esperados. ¿Se modificaron los valores en tránsito o está utilizando el ApiKey en otra aplicación?", exception.Message);
        }
        public void EpochExceededWhenSignedRequestThrows()
        {
            IAutonomousApp client     = this.GetAutonomousClient();
            int            randomDays = new Random().Next(2, 10);

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromDatePicker(randomDays));
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15851"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.RequestedRangeNotSatisfiable));
            StringAssert.IsMatch("Epoch está fuera de rango admitido", exception.Message);
        }
示例#20
0
        public void Update_PartitionKeyOmitted()
        {
            // Setup
            Movie movieToUpdate = _movieList[1];

            // Update to different values
            var    expectedMovie  = new Movie(movieToUpdate.Title + "_something_different", movieToUpdate.Director, "something_different_" + Randomm.RandomAlphaNum(10), null, 1212);
            var    err            = Assert.Throws <InvalidQueryException>(() => _mapper.Update(expectedMovie));
            string expectedErrMsg = "Invalid null value (for partition key part|in condition for column) moviemaker";

            StringAssert.IsMatch(expectedErrMsg, err.Message);
        }
        public void EpochNegativeWhenSignedRequestThrows()
        {
            IAutonomousApp client          = this.GetAutonomousClient();
            double         negativeSeconds = -DateTimeOffset.Now.ToUnixTimeSeconds();

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromStaticSeconds(negativeSeconds));
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15850"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("Formato de Epoch no es valido. Debe ser un número.", exception.Message);
        }
示例#22
0
        public void ShouldGetNextMoveAsWhiteWithDepthOne()
        {
            var connector = new UCIConnector(_setting);

            connector.Connect();

            var move = connector.GetNextMove("e2e4", 1);

            connector.Disconnect();

            StringAssert.IsMatch(MOVE_REGEX_PATTERN, move);
        }
        public void InvalidFormatTokenWhenSignedRequestThrows()
        {
            IAutonomousApp        client = this.GetAutonomousClient();
            IPayloadClaimsManager invalidTokenClaimBehavior = InvalidTokenPayloadClaim.WithClaimBehavior(() => "gXjyhrYqannHUA$LLV&7guTHmF&1X5JB$Uobx3@!rPn9&x4BzE");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(invalidTokenClaimBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("20007"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("El contenido de la cabecera personalizada 'X-PRO-Auth-Payload' no es válido", exception.Message);
        }
        public void GetStatementsByAliasUnrecognizedChannelThrows()
        {
            IAutonomousApp client = this.GetAutonomousClient();
            string         unrecognizedChannelId = Guid.NewGuid().ToString();
            string         enrollmentAlias       = "52080323";
            string         accountId             = new Random().Next(999, 9999).ToString();
            AspenException exception             = Assert.Throws <AspenException>(() => client.Inquiries.GetStatementsByAlias(unrecognizedChannelId, enrollmentAlias, accountId));

            Assert.That(exception.EventId, Is.EqualTo("15881"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            StringAssert.IsMatch("No se ha encontrado información de enrolamiento con los valores suministrados", exception.Message);
        }
示例#25
0
        public void MismatchDeviceIdWhenUserSignedRequestThrows()
        {
            IDelegatedApp         client = this.GetDelegatedClient();
            IPayloadClaimsManager randomDeviceIdClaimBehavior = InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"MyRandomDevice-{new Random().Next(999999, 9999999)}");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(randomDeviceIdClaimBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15847"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No hay un token de autenticación vigente.", exception.Message);
        }
示例#26
0
        public void Insert_UnconfiguredTable()
        {
            // Setup
            var mapper = new Mapper(_session, new MappingConfiguration());
            ManyDataTypesPoco manyTypesPoco = ManyDataTypesPoco.GetRandomInstance();

            // Validate Error Message
            var    e = Assert.Throws <InvalidQueryException>(() => mapper.Insert(manyTypesPoco));
            string expectedErrMsg = "unconfigured (columnfamily|table) " + typeof(ManyDataTypesPoco).Name.ToLower();

            StringAssert.IsMatch(expectedErrMsg, e.Message);
        }
示例#27
0
        public void CreatePatternDefaultFormat()
        {
            var format        = BackupSettings.DefaultTimeStampFormat;
            var pattern       = FileInfoExt.CreateTimeStampPattern(format);
            var dateTime      = new DateTime(2015, 06, 14, 12, 33, 24);
            var s             = "." + dateTime.ToString(format, CultureInfo.InvariantCulture);
            var strictPattern = $"^{pattern}$";

            ////Console.WriteLine(pattern);
            Assert.AreEqual(@"\.(?<timestamp>\d+_\d+_\d+_\d+_\d+_\d+)", pattern);
            StringAssert.IsMatch(strictPattern, s);
        }
 public void SelectTake()
 {
     using (var db = GetDbContext <SelectContext>())
     {
         var query = db.Set <MonAttachment>()
                     .Take(3);
         Assert.DoesNotThrow(() => query.Load());
         var sql = db.LastCommandText;
         StringAssert.IsMatch(@"ROWS \(.+\)", sql);
         StringAssert.DoesNotMatch(@" TO \(", sql);
     }
 }
示例#29
0
        public void Insert_WithMapperInsert_TwoPartitionKeys_OnlyOne()
        {
            // Setup
            var mappingConfig = new MappingConfiguration().Define(new Map <ClassWithTwoPartitionKeys>()
                                                                  .TableName(typeof(ClassWithTwoPartitionKeys).Name).CaseSensitive()
                                                                  .PartitionKey(new string[] { "PartitionKey1", "PartitionKey2" }).CaseSensitive()
                                                                  );
            var table = new Table <ClassWithTwoPartitionKeys>(_session, mappingConfig);

            table.Create();

            // Insert the data
            ClassWithTwoPartitionKeys defaultInstance = new ClassWithTwoPartitionKeys();
            ClassWithTwoPartitionKeys instance        = new ClassWithTwoPartitionKeys();
            var mapper = new Mapper(_session, mappingConfig);

            mapper.Insert(instance);

            List <ClassWithTwoPartitionKeys> instancesRetrieved = new List <ClassWithTwoPartitionKeys>();
            DateTime futureDateTime = DateTime.Now.AddSeconds(5);

            while (instancesRetrieved.Count < 1 && DateTime.Now < futureDateTime)
            {
                instancesRetrieved = mapper.Fetch <ClassWithTwoPartitionKeys>("SELECT * from \"" + table.Name + "\"").ToList();
            }
            Assert.AreEqual(1, instancesRetrieved.Count);
            Assert.AreEqual(defaultInstance.PartitionKey1, instancesRetrieved[0].PartitionKey1);
            Assert.AreEqual(defaultInstance.PartitionKey2, instancesRetrieved[0].PartitionKey2);
            instancesRetrieved.Clear();

            futureDateTime = DateTime.Now.AddSeconds(5);
            string cqlSelect = "SELECT * from \"" + table.Name + "\" where \"PartitionKey1\" = '" + instance.PartitionKey1 + "' and \"PartitionKey2\" = '" + instance.PartitionKey2 + "'";

            while (instancesRetrieved.Count < 1 && DateTime.Now < futureDateTime)
            {
                instancesRetrieved = mapper.Fetch <ClassWithTwoPartitionKeys>(cqlSelect).ToList();
            }
            Assert.AreEqual(1, instancesRetrieved.Count);
            Assert.AreEqual(defaultInstance.PartitionKey1, instancesRetrieved[0].PartitionKey1);
            Assert.AreEqual(defaultInstance.PartitionKey2, instancesRetrieved[0].PartitionKey2);

            var    err            = Assert.Throws <InvalidQueryException>(() => mapper.Fetch <ClassWithTwoPartitionKeys>("SELECT * from \"" + table.Name + "\" where \"PartitionKey1\" = '" + instance.PartitionKey1 + "'"));
            string expectedErrMsg = "Partition key part(s:)? PartitionKey2 must be restricted (since preceding part is|as other parts are)";

            if (TestClusterManager.CheckCassandraVersion(false, Version.Parse("3.10"), Comparison.GreaterThanOrEqualsTo))
            {
                expectedErrMsg = "Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING";
            }
            StringAssert.IsMatch(expectedErrMsg, err.Message);

            Assert.Throws <InvalidQueryException>(() => mapper.Fetch <ClassWithTwoPartitionKeys>("SELECT * from \"" + table.Name + "\" where \"PartitionKey2\" = '" + instance.PartitionKey2 + "'"));
        }
示例#30
0
        public void Person_ChangeDataToAnotherCorrectValue_DataChanged(string name, string surname, string email, string password, string hours, Boolean?admin)
        {
            String            personValues = "test";
            LoginPageObject   loginPage    = new LoginPageObject();
            MySchedPageObject mySchedPage  = loginPage.Login("*****@*****.**", "admin");
            MenuLayoutObject  menu         = new MenuLayoutObject();
            PeoplePageObject  peoplePage   = menu.EnterPeople();
            PersonPageObject  personPage;

            string id = "0";

            try
            {
                id = peoplePage.GetCellContent(0, 0);
            }
            catch { }
            peoplePage.AddPerson(personValues, personValues, personValues + id + "@" + personValues + id + ".pl", "1qazxsw2", "1");
            SeleniumUtilityMethods.WaitForJavascript();
            personPage = peoplePage.EneterPerson(0);

            personPage.setData(name, surname, email, hours, admin, password);
            personPage.Save();
            peoplePage = menu.EnterPeople();
            personPage = peoplePage.EneterPerson(0);

            string  nname    = personPage.getName();
            string  nsurname = personPage.getSurname();
            string  nemail   = personPage.getEmail();
            string  nhours   = personPage.getHours();
            Boolean nadmin   = personPage.getAdminstrator();

            if (name != null)
            {
                StringAssert.IsMatch(name, nname);
            }
            if (surname != null)
            {
                StringAssert.IsMatch(surname, nsurname);
            }
            if (email != null)
            {
                StringAssert.IsMatch(email, nemail);
            }
            if (hours != null)
            {
                StringAssert.IsMatch(hours, nhours);
            }
            if (admin != null)
            {
                Assert.That(nadmin == admin);
            }
        }