public async Task GivenTheFollowingClientsExist(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String clientId          = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientId");
                String clientName        = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientName");
                String secret            = SpecflowTableHelper.GetStringRowValue(tableRow, "Secret");
                String allowedScopes     = SpecflowTableHelper.GetStringRowValue(tableRow, "AllowedScopes");
                String allowedGrantTypes = SpecflowTableHelper.GetStringRowValue(tableRow, "AllowedGrantTypes");

                List <String> splitAllowedScopes     = allowedScopes.Split(",").ToList();
                List <String> splitAllowedGrantTypes = allowedGrantTypes.Split(",").ToList();

                CreateClientRequest createClientRequest = new CreateClientRequest
                {
                    Secret            = secret,
                    AllowedGrantTypes = new List <String>(),
                    AllowedScopes     = new List <String>(),
                    ClientDescription = String.Empty,
                    ClientId          = clientId,
                    ClientName        = clientName
                };

                splitAllowedScopes.ForEach(a => { createClientRequest.AllowedScopes.Add(a.Trim()); });
                splitAllowedGrantTypes.ForEach(a => { createClientRequest.AllowedGrantTypes.Add(a.Trim()); });

                CreateClientResponse createClientResponse = await this.TestingContext.DockerHelper.SecurityServiceClient
                                                            .CreateClient(createClientRequest, CancellationToken.None).ConfigureAwait(false);

                createClientResponse.ClientId.ShouldBe(clientId);

                this.TestingContext.AddClientDetails(clientId, secret, allowedGrantTypes);
            }
        }
Esempio n. 2
0
        public async Task WhenIGetTheIdentityResourcesIdentityResourceDetailsAreReturnedAsFollows(Int32 numberOfIdentityResources, Table table)
        {
            List <IdentityResourceDetails> identityResourceDetailsList = await this.GetIdentityResources(CancellationToken.None).ConfigureAwait(false);

            identityResourceDetailsList.Count.ShouldBe(numberOfIdentityResources);
            foreach (TableRow tableRow in table.Rows)
            {
                String identityResourceName = SpecflowTableHelper.GetStringRowValue(tableRow, "Name");
                IdentityResourceDetails identityResourceDetails = identityResourceDetailsList.SingleOrDefault(u => u.Name == identityResourceName);

                String userClaims = SpecflowTableHelper.GetStringRowValue(tableRow, "UserClaims");

                identityResourceDetails.Description.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Description"));
                identityResourceDetails.Name.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Name"));
                identityResourceDetails.DisplayName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName"));

                if (string.IsNullOrEmpty(userClaims))
                {
                    identityResourceDetails.Claims.ShouldBeEmpty();
                }
                else
                {
                    identityResourceDetails.Claims.ShouldBe(userClaims.Split(",").ToList());
                }
            }
        }
        public async Task WhenICreateTheFollowingOperators(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String  operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName");
                Boolean requireCustomMerchantNumber = SpecflowTableHelper.GetBooleanValue(tableRow, "RequireCustomMerchantNumber");
                Boolean requireCustomTerminalNumber = SpecflowTableHelper.GetBooleanValue(tableRow, "RequireCustomTerminalNumber");

                CreateOperatorRequest createOperatorRequest = new CreateOperatorRequest
                {
                    Name = operatorName,
                    RequireCustomMerchantNumber = requireCustomMerchantNumber,
                    RequireCustomTerminalNumber = requireCustomTerminalNumber
                };

                // lookup the estate id based on the name in the table
                EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow);

                CreateOperatorResponse response = await this.TestingContext.DockerHelper.EstateClient.CreateOperator(this.TestingContext.AccessToken, estateDetails.EstateId, createOperatorRequest, CancellationToken.None).ConfigureAwait(false);

                response.ShouldNotBeNull();
                response.EstateId.ShouldNotBe(Guid.Empty);
                response.OperatorId.ShouldNotBe(Guid.Empty);

                // Cache the estate id
                estateDetails.AddOperator(response.OperatorId, operatorName);

                this.TestingContext.Logger.LogInformation($"Operator {operatorName} created with Id {response.OperatorId} for Estate {estateDetails.EstateName}");
            }
        }
        public async Task GivenICreateAContractWithTheFollowingValues(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow);

                String token = this.TestingContext.AccessToken;
                if (String.IsNullOrEmpty(estateDetails.AccessToken) == false)
                {
                    token = estateDetails.AccessToken;
                }

                String operatorName = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName");
                Guid   operatorId   = estateDetails.GetOperatorId(operatorName);

                CreateContractRequest createContractRequest = new CreateContractRequest
                {
                    OperatorId  = operatorId,
                    Description = SpecflowTableHelper.GetStringRowValue(tableRow, "ContractDescription")
                };

                CreateContractResponse contractResponse =
                    await this.TestingContext.DockerHelper.EstateClient.CreateContract(token, estateDetails.EstateId, createContractRequest, CancellationToken.None);

                estateDetails.AddContract(contractResponse.ContractId, createContractRequest.Description, operatorId);
            }
        }
Esempio n. 5
0
        public async Task GivenTheFollowingApiResourcesExist(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String resourceName = SpecflowTableHelper.GetStringRowValue(tableRow, "ResourceName");
                String displayName  = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName");
                String secret       = SpecflowTableHelper.GetStringRowValue(tableRow, "Secret");
                String scopes       = SpecflowTableHelper.GetStringRowValue(tableRow, "Scopes");
                String userClaims   = SpecflowTableHelper.GetStringRowValue(tableRow, "UserClaims");

                List <String> splitScopes     = scopes.Split(',').ToList();
                List <String> splitUserClaims = userClaims.Split(',').ToList();

                CreateApiResourceRequest createApiResourceRequest = new CreateApiResourceRequest
                {
                    Description = String.Empty,
                    DisplayName = displayName,
                    Name        = resourceName,
                    Scopes      = new List <String>(),
                    Secret      = secret,
                    UserClaims  = new List <String>()
                };
                splitScopes.ForEach(a => { createApiResourceRequest.Scopes.Add(a.Trim()); });
                splitUserClaims.ForEach(a => { createApiResourceRequest.UserClaims.Add(a.Trim()); });

                CreateApiResourceResponse createApiResourceResponse = await this
                                                                      .TestingContext.DockerHelper.SecurityServiceClient
                                                                      .CreateApiResource(createApiResourceRequest, CancellationToken.None).ConfigureAwait(false);

                createApiResourceResponse.ApiResourceName.ShouldBe(resourceName);
            }
        }
        public async Task WhenIRedeemTheFollowingVouchersTheBalanceWillBeAsExpected(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow);

                String  operatorIdentifier = SpecflowTableHelper.GetStringRowValue(tableRow, "OperatorName");
                Guid    transactionId      = Guid.Parse(SpecflowTableHelper.GetStringRowValue(tableRow, "TransactionId"));
                Decimal balance            = SpecflowTableHelper.GetDecimalValue(tableRow, "Balance");

                (Guid transactionId, Decimal value, String voucherCode, Guid voucherId)voucher = estateDetails.GetVoucher(operatorIdentifier, transactionId);

                // Build URI
                String uri = $"api/vouchers?applicationVersion=1.0.0&voucherCode={voucher.voucherCode}";

                String accessToken = estateDetails.GetVoucherRedemptionUserToken(operatorIdentifier);

                StringContent content = new StringContent(String.Empty);

                this.TestingContext.DockerHelper.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                HttpResponseMessage response = await this.TestingContext.DockerHelper.HttpClient.PutAsync(uri, content, CancellationToken.None).ConfigureAwait(false);

                response.IsSuccessStatusCode.ShouldBeTrue();

                RedeemVoucherResponseMessage redeemVoucherResponse = JsonConvert.DeserializeObject <RedeemVoucherResponseMessage>(await response.Content.ReadAsStringAsync().ConfigureAwait(false));

                redeemVoucherResponse.Balance.ShouldBe(balance);
                redeemVoucherResponse.VoucherCode.ShouldBe(voucher.voucherCode);
            }
        }
Esempio n. 7
0
        public async Task WhenIGetTheFileForEstateTheFollowingFileInformationIsReturned(string fileName, string estateName, Table table)
        {
            EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName);

            Guid fileId = estateDetails.GetFileId(fileName);

            TableRow tableRow            = table.Rows.First();
            Boolean  processingCompleted = SpecflowTableHelper.GetBooleanValue(tableRow, "ProcessingCompleted");
            Int32    numberOfLines       = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfLines");
            Int32    totaLines           = SpecflowTableHelper.GetIntValue(tableRow, "TotaLines");
            Int32    successfulLines     = SpecflowTableHelper.GetIntValue(tableRow, "SuccessfulLines");
            Int32    ignoredLines        = SpecflowTableHelper.GetIntValue(tableRow, "IgnoredLines");
            Int32    failedLines         = SpecflowTableHelper.GetIntValue(tableRow, "FailedLines");
            Int32    notProcessedLines   = SpecflowTableHelper.GetIntValue(tableRow, "NotProcessedLines");

            await Retry.For(async() =>
            {
                var fileDetails = await this.GetFile(estateName, fileId, CancellationToken.None);
                fileDetails.ProcessingCompleted.ShouldBe(processingCompleted);
                fileDetails.FileLines.Count.ShouldBe(numberOfLines);
                fileDetails.ProcessingSummary.TotalLines.ShouldBe(totaLines);
                fileDetails.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(successfulLines);
                fileDetails.ProcessingSummary.IgnoredLines.ShouldBe(ignoredLines);
                fileDetails.ProcessingSummary.FailedLines.ShouldBe(failedLines);
                fileDetails.ProcessingSummary.NotProcessedLines.ShouldBe(notProcessedLines);
            }, TimeSpan.FromMinutes(4), TimeSpan.FromSeconds(30));
        }
Esempio n. 8
0
        private async Task <Guid> UploadFile(Table table)
        {
            var    row            = table.Rows.First();
            String merchantName   = SpecflowTableHelper.GetStringRowValue(row, "MerchantName");
            String fileProfileId  = SpecflowTableHelper.GetStringRowValue(row, "FileProfileId");
            String userId         = SpecflowTableHelper.GetStringRowValue(row, "UserId");
            String uploadDateTime = SpecflowTableHelper.GetStringRowValue(row, "UploadDateTime");

            var    estate     = this.TestingContext.GetEstateDetails(row);
            Guid   estateId   = estate.EstateId;
            var    merchantId = estate.GetMerchantId(merchantName);
            String filePath   = this.TestingContext.UploadFile;
            var    fileData   = await File.ReadAllBytesAsync(filePath);

            UploadFileRequest uploadFileRequest = new UploadFileRequest
            {
                EstateId      = estateId,
                FileProfileId = Guid.Parse(fileProfileId),
                MerchantId    = merchantId,
                UserId        = Guid.Parse(userId),
            };

            if (String.IsNullOrEmpty(uploadDateTime) == false)
            {
                uploadFileRequest.UploadDateTime = SpecflowTableHelper.GetDateForDateString(uploadDateTime, DateTime.Now);
            }

            var fileId = await this.TestingContext.DockerHelper.FileProcessorClient.UploadFile(this.TestingContext.AccessToken,
                                                                                               Path.GetFileName(filePath),
                                                                                               fileData,
                                                                                               uploadFileRequest,
                                                                                               CancellationToken.None);

            return(fileId);
        }
Esempio n. 9
0
        public async Task GivenICreateTheFollowingApiResources(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                // Get the scopes
                String scopes     = SpecflowTableHelper.GetStringRowValue(tableRow, "Scopes");
                String userClaims = SpecflowTableHelper.GetStringRowValue(tableRow, "UserClaims");
                scopes = scopes.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"));

                CreateApiResourceRequest createApiResourceRequest = new CreateApiResourceRequest
                {
                    Secret      = SpecflowTableHelper.GetStringRowValue(tableRow, "Secret"),
                    Name        = SpecflowTableHelper.GetStringRowValue(tableRow, "Name").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")),
                    Scopes      = string.IsNullOrEmpty(scopes) ? null : scopes.Split(",").ToList(),
                    UserClaims  = string.IsNullOrEmpty(userClaims) ? null : userClaims.Split(",").ToList(),
                    Description = SpecflowTableHelper.GetStringRowValue(tableRow, "Description"),
                    DisplayName = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName")
                };
                CreateApiResourceResponse createApiResourceResponse =
                    await this.CreateApiResource(createApiResourceRequest, CancellationToken.None).ConfigureAwait(false);

                createApiResourceResponse.ShouldNotBeNull();
                createApiResourceResponse.ApiResourceName.ShouldNotBeNullOrEmpty();

                this.TestingContext.ApiResources.Add(createApiResourceResponse.ApiResourceName);
            }
        }
        public async Task WhenIGetTheApiResourceWithNameTheApiResourceDetailsAreReturnedAsFollows(String apiResourceName,
                                                                                                  Table table)
        {
            ApiResourceDetails apiResourceDetails = await this.GetApiResource(apiResourceName, CancellationToken.None).ConfigureAwait(false);

            table.Rows.Count.ShouldBe(1);
            TableRow tableRow = table.Rows.First();

            apiResourceDetails.ShouldNotBeNull();

            String scopes     = SpecflowTableHelper.GetStringRowValue(tableRow, "Scopes");
            String userClaims = SpecflowTableHelper.GetStringRowValue(tableRow, "UserClaims");

            apiResourceDetails.Description.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Description"));
            apiResourceDetails.Name.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Name"));
            apiResourceDetails.DisplayName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName"));
            if (string.IsNullOrEmpty(scopes))
            {
                apiResourceDetails.Scopes.ShouldBeEmpty();
            }
            else
            {
                apiResourceDetails.Scopes.ShouldBe(scopes.Split(",").ToList());
            }

            if (string.IsNullOrEmpty(userClaims))
            {
                apiResourceDetails.UserClaims.ShouldBeEmpty();
            }
            else
            {
                apiResourceDetails.UserClaims.ShouldBe(userClaims.Split(",").ToList());
            }
        }
        public async Task GivenICreateTheFollowingClients(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                // Get the scopes
                String scopes = SpecflowTableHelper.GetStringRowValue(tableRow, "Scopes");
                // Get the grant types
                String grantTypes = SpecflowTableHelper.GetStringRowValue(tableRow, "GrantTypes");
                // Get the redirect uris
                String redirectUris = SpecflowTableHelper.GetStringRowValue(tableRow, "RedirectUris");
                // Get the post logout redirect uris
                String postLogoutRedirectUris = SpecflowTableHelper.GetStringRowValue(tableRow, "PostLogoutRedirectUris");

                CreateClientRequest createClientRequest = new CreateClientRequest
                {
                    ClientId                     = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientId"),
                    Secret                       = SpecflowTableHelper.GetStringRowValue(tableRow, "Secret"),
                    ClientName                   = SpecflowTableHelper.GetStringRowValue(tableRow, "Name"),
                    AllowedScopes                = string.IsNullOrEmpty(scopes) ? null : scopes.Split(",").ToList(),
                    AllowedGrantTypes            = string.IsNullOrEmpty(grantTypes) ? null : grantTypes.Split(",").ToList(),
                    ClientRedirectUris           = string.IsNullOrEmpty(redirectUris) ? null : redirectUris.Split(",").ToList(),
                    ClientPostLogoutRedirectUris = string.IsNullOrEmpty(postLogoutRedirectUris) ? null : postLogoutRedirectUris.Split(",").ToList(),
                    ClientDescription            = SpecflowTableHelper.GetStringRowValue(tableRow, "Description"),
                    RequireConsent               = SpecflowTableHelper.GetBooleanValue(tableRow, "RequireConsent")
                };

                CreateClientResponse createClientResponse = await this.CreateClient(createClientRequest, CancellationToken.None).ConfigureAwait(false);

                createClientResponse.ShouldNotBeNull();
                createClientResponse.ClientId.ShouldNotBeNullOrEmpty();

                this.TestingContext.Clients.Add(createClientResponse.ClientId);
            }
        }
        public async Task WhenIGetTheClientWithClientIdTheClientDetailsAreReturnedAsFollows(String clientId,
                                                                                            Table table)
        {
            ClientDetails clientDetails = await this.GetClient(clientId, CancellationToken.None).ConfigureAwait(false);

            table.Rows.Count.ShouldBe(1);
            TableRow tableRow = table.Rows.First();

            clientDetails.ShouldNotBeNull();

            String scopes     = SpecflowTableHelper.GetStringRowValue(tableRow, "Scopes");
            String grantTypes = SpecflowTableHelper.GetStringRowValue(tableRow, "GrantTypes");

            clientDetails.ClientDescription.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Description"));
            clientDetails.ClientId.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "ClientId"));
            clientDetails.ClientName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Name"));
            if (string.IsNullOrEmpty(scopes))
            {
                clientDetails.AllowedScopes.ShouldBeEmpty();
            }
            else
            {
                clientDetails.AllowedScopes.ShouldBe(scopes.Split(",").ToList());
            }

            if (string.IsNullOrEmpty(grantTypes))
            {
                clientDetails.AllowedGrantTypes.ShouldBeEmpty();
            }
            else
            {
                clientDetails.AllowedGrantTypes.ShouldBe(grantTypes.Split(",").ToList());
            }
        }
Esempio n. 13
0
        public EstateDetails GetEstateDetails(TableRow tableRow, Guid?testId = null)
        {
            String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName").Replace("[id]", testId.Value.ToString("N"));

            EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName);

            estateDetails.ShouldNotBeNull();

            return(estateDetails);
        }
        public void WhenIEnterTheFollowingTopupDetails(Table table)
        {
            table.Rows.ShouldHaveSingleItem();
            TableRow topupDetails         = table.Rows.Single();
            String   customerMobileNumber = SpecflowTableHelper.GetStringRowValue(topupDetails, "CustomerMobileNumber");
            Decimal  topupAmount          = SpecflowTableHelper.GetDecimalValue(topupDetails, "TopupAmount");

            this.MobileTopupPerformTopupPage.EnterCustomerMobileNumber(customerMobileNumber);
            this.MobileTopupPerformTopupPage.EnterTopupAmount(topupAmount);
        }
Esempio n. 15
0
        public async Task WhenICreateTheFollowingEstates(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName");

                CreateEstateRequest createEstateRequest = new CreateEstateRequest
                {
                    EstateId   = Guid.NewGuid(),
                    EstateName = estateName
                };

                CreateEstateResponse response = null;
                try
                {
                    response = await this.TestingContext.DockerHelper.EstateClient
                               .CreateEstate(this.TestingContext.AccessToken, createEstateRequest, CancellationToken.None)
                               .ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    this.TestingContext.DockerHelper.Logger.LogInformation(e.Message);
                    if (e.InnerException != null)
                    {
                        this.TestingContext.DockerHelper.Logger.LogInformation(e.InnerException.Message);
                        if (e.InnerException.InnerException != null)
                        {
                            this.TestingContext.DockerHelper.Logger.LogInformation(e.InnerException.InnerException.Message);
                        }
                    }
                }

                response.ShouldNotBeNull();
                response.EstateId.ShouldNotBe(Guid.Empty);

                // Cache the estate id
                this.TestingContext.AddEstateDetails(response.EstateId, estateName);

                //this.TestingContext.Logger.LogInformation($"Estate {estateName} created with Id {response.EstateId}");
            }

            foreach (TableRow tableRow in table.Rows)
            {
                EstateDetails  estateDetails = this.TestingContext.GetEstateDetails(tableRow);
                EstateResponse estate        = null;
                await Retry.For(async() =>
                {
                    estate = await this.TestingContext.DockerHelper.EstateClient
                             .GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false);
                });

                estate.ShouldNotBeNull();
                estate.EstateName.ShouldBe(estateDetails.EstateName);
            }
        }
Esempio n. 16
0
        public async Task GivenTheFollowingUsersExist(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String emailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "EmailAddress");
                String password     = SpecflowTableHelper.GetStringRowValue(tableRow, "Password");

                await this.Backdoor.AddUserDetails((emailAddress, password));

                this.TestingContext.Users.Add((emailAddress, password));
            }
        }
Esempio n. 17
0
        public async Task WhenIGetTheApiScopeWithNameTheApiScopeDetailsAreReturnedAsFollows(String apiScopeName, Table table)
        {
            ApiScopeDetails apiScopeDetails = await this.GetApiScope(apiScopeName, CancellationToken.None).ConfigureAwait(false);

            table.Rows.Count.ShouldBe(1);
            TableRow tableRow = table.Rows.First();

            apiScopeDetails.ShouldNotBeNull();

            apiScopeDetails.Description.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Description"));
            apiScopeDetails.Name.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Name"));
            apiScopeDetails.DisplayName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName"));
        }
        public async Task WhenIGetTheRolesRolesDetailsAreReturnedAsFollows(Int32 numberOfRoles, Table table)
        {
            List <RoleDetails> roleDetailsList = await this.GetRoles(CancellationToken.None).ConfigureAwait(false);

            roleDetailsList.Count.ShouldBe(numberOfRoles);

            foreach (TableRow tableRow in table.Rows)
            {
                String      roleName    = SpecflowTableHelper.GetStringRowValue(tableRow, "Role Name");
                RoleDetails roleDetails = roleDetailsList.SingleOrDefault(u => u.RoleName == roleName);

                roleDetails.ShouldNotBeNull();
            }
        }
        public async Task WhenIGetTheRoleWithNameTheRoleDetailsAreReturnedAsFollows(String roleName, Table table)
        {
            // Get the role id
            Guid roleId = this.TestingContext.Roles.Single(u => u.Key == roleName).Value;

            RoleDetails roleDetails = await this.GetRole(roleId, CancellationToken.None).ConfigureAwait(false);

            table.Rows.Count.ShouldBe(1);
            TableRow tableRow = table.Rows.First();

            roleDetails.ShouldNotBeNull();

            roleDetails.RoleName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Role Name"));
        }
Esempio n. 20
0
        public async Task WhenIGetTheApiScopesApiScopeDetailsAreReturnedAsFollows(Int32 numberOfApiScopes, Table table)
        {
            List <ApiScopeDetails> apiScopeDetailsList = await this.GetApiScopes(CancellationToken.None).ConfigureAwait(false);

            apiScopeDetailsList.Count.ShouldBe(numberOfApiScopes);
            foreach (TableRow tableRow in table.Rows)
            {
                String          apiScopeName       = SpecflowTableHelper.GetStringRowValue(tableRow, "Name");
                ApiScopeDetails?apiResourceDetails = apiScopeDetailsList.SingleOrDefault(u => u.Name == apiScopeName);

                apiResourceDetails.Description.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Description"));
                apiResourceDetails.Name.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Name"));
                apiResourceDetails.DisplayName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName"));
            }
        }
Esempio n. 21
0
        public async Task WhenIGetTheImportLogsBetweenAndTheFollowingDataIsReturned(string estateName, string startDate, string endDate, Table table)
        {
            FileImportLogList importLogList = await this.GetFileImportLogList(estateName, startDate, endDate, CancellationToken.None);

            foreach (TableRow tableRow in table.Rows)
            {
                DateTime importLogDateTime = SpecflowTableHelper.GetDateForDateString(SpecflowTableHelper.GetStringRowValue(tableRow, "ImportLogDate"), DateTime.Now);
                Int32    fileCount         = SpecflowTableHelper.GetIntValue(tableRow, "FileCount");

                // Find the import log now
                FileImportLog?importLog = importLogList.FileImportLogs.SingleOrDefault(fil => fil.ImportLogDate == importLogDateTime.Date && fil.FileCount == fileCount);

                importLog.ShouldNotBeNull();
            }
        }
        public async Task GivenIHaveATokenToAccessTheEstateManagementAndVoucherManagementResources(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String clientId = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientId");

                ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId);

                if (clientDetails.GrantType == "client_credentials")
                {
                    TokenResponse tokenResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.GetToken(clientId, clientDetails.ClientSecret, CancellationToken.None).ConfigureAwait(false);

                    this.TestingContext.AccessToken = tokenResponse.AccessToken;
                }
            }
        }
        public async Task GivenICreateTheFollowingRoles(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                CreateRoleRequest createRoleRequest = new CreateRoleRequest
                {
                    RoleName = SpecflowTableHelper.GetStringRowValue(tableRow, "Role Name")
                };
                CreateRoleResponse createRoleResponse = await this.CreateRole(createRoleRequest, CancellationToken.None).ConfigureAwait(false);

                createRoleResponse.ShouldNotBeNull();
                createRoleResponse.RoleId.ShouldNotBe(Guid.Empty);

                this.TestingContext.Roles.Add(createRoleRequest.RoleName, createRoleResponse.RoleId);
            }
        }
        public async Task GivenTheFollowingSecurityRolesExist(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String roleName = SpecflowTableHelper.GetStringRowValue(tableRow, "RoleName");

                CreateRoleRequest createRoleRequest = new CreateRoleRequest
                {
                    RoleName = roleName
                };

                CreateRoleResponse createRoleResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.CreateRole(createRoleRequest, CancellationToken.None)
                                                        .ConfigureAwait(false);

                createRoleResponse.RoleId.ShouldNotBe(Guid.Empty);
            }
        }
        public async Task GivenICreateTheFollowingApiScopes(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                CreateApiScopeRequest createApiScopeRequest = new CreateApiScopeRequest
                {
                    Name        = SpecflowTableHelper.GetStringRowValue(tableRow, "Name"),
                    Description = SpecflowTableHelper.GetStringRowValue(tableRow, "Description"),
                    DisplayName = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName")
                };
                var createApiScopeResponse =
                    await this.CreateApiScope(createApiScopeRequest, CancellationToken.None).ConfigureAwait(false);

                createApiScopeResponse.ShouldNotBeNull();
                createApiScopeResponse.ApiScopeName.ShouldNotBeNullOrEmpty();
            }
        }
Esempio n. 26
0
        public async Task GivenTheFollowingClientsExist(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String clientId          = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientId");
                String clientName        = SpecflowTableHelper.GetStringRowValue(tableRow, "ClientName");
                String secret            = SpecflowTableHelper.GetStringRowValue(tableRow, "Secret");
                String allowedScopes     = SpecflowTableHelper.GetStringRowValue(tableRow, "AllowedScopes");
                String allowedGrantTypes = SpecflowTableHelper.GetStringRowValue(tableRow, "AllowedGrantTypes");

                List <String> splitAllowedScopes     = allowedScopes.Split(',').ToList();
                List <String> splitAllowedGrantTypes = allowedGrantTypes.Split(',').ToList();

                CreateClientRequest createClientRequest = new CreateClientRequest
                {
                    Secret            = secret,
                    AllowedGrantTypes = new List <String>(),
                    AllowedScopes     = new List <String>(),
                    ClientDescription = String.Empty,
                    ClientId          = clientId,
                    ClientName        = clientName
                };

                splitAllowedScopes.ForEach(a => { createClientRequest.AllowedScopes.Add(a.Trim()); });
                splitAllowedGrantTypes.ForEach(a => { createClientRequest.AllowedGrantTypes.Add(a.Trim()); });

                CreateClientResponse createClientResponse = await this.TestingContext.DockerHelper.SecurityServiceClient
                                                            .CreateClient(createClientRequest, CancellationToken.None).ConfigureAwait(false);

                createClientResponse.ClientId.ShouldBe(clientId);

                this.TestingContext.AddClientDetails(clientId, secret, allowedGrantTypes);
            }

            var merchantClient = this.TestingContext.GetClientDetails("merchantClient");

            // TODO: Handle local test running
            String securityService         = this.TestingContext.DockerHelper.SecurityServiceBaseAddress;
            String transactionProcessorAcl = this.TestingContext.DockerHelper.TransactionProcessorACLBaseAddress;

            Console.WriteLine($"securityService [{securityService}]");
            Console.WriteLine($"transactionProcessorAcl [{transactionProcessorAcl}]");

            AppManager.SetConfiguration(merchantClient.ClientId, merchantClient.ClientSecret,
                                        securityService, transactionProcessorAcl);
        }
        public async Task WhenIGetTheUsersUsersDetailsAreReturnedAsFollows(Int32 numberOfUsers,
                                                                           Table table)
        {
            List <UserDetails> userDetailsList = await this.GetUsers(CancellationToken.None).ConfigureAwait(false);

            userDetailsList.Count.ShouldBe(numberOfUsers);

            foreach (TableRow tableRow in table.Rows)
            {
                String      emailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address");
                UserDetails userDetails  = userDetailsList.SingleOrDefault(u => u.EmailAddress == emailAddress);

                userDetails.ShouldNotBeNull();

                Dictionary <String, String> userClaims = new Dictionary <String, String>();
                String   claims    = SpecflowTableHelper.GetStringRowValue(tableRow, "Claims");
                String[] claimList = claims.Split(",");
                foreach (String claim in claimList)
                {
                    // Split into claim name and value
                    String[] c = claim.Split(":");
                    userClaims.Add(c[0].Trim(), c[1].Trim());
                }

                String roles = SpecflowTableHelper.GetStringRowValue(tableRow, "Roles");

                userDetails.EmailAddress.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address"));
                userDetails.PhoneNumber.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Phone Number"));
                userDetails.UserId.ShouldNotBe(Guid.Empty);
                userDetails.UserName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address"));
                if (string.IsNullOrEmpty(roles))
                {
                    userDetails.Roles.ShouldBeEmpty();
                }
                else
                {
                    userDetails.Roles.ShouldBe(roles.Split(",").ToList());
                }

                foreach (KeyValuePair <String, String> claim in userClaims)
                {
                    KeyValuePair <String, String> x = userDetails.Claims.Where(c => c.Key == claim.Key).SingleOrDefault();
                    x.Value.ShouldBe(claim.Value);
                }
            }
        }
        public async Task WhenIGetTheUserWithUserNameTheUserDetailsAreReturnedAsFollows(String userName,
                                                                                        Table table)
        {
            // Get the user id
            Guid userId = this.TestingContext.Users.Single(u => u.Key == userName).Value;

            UserDetails userDetails = await this.GetUser(userId, CancellationToken.None).ConfigureAwait(false);

            table.Rows.Count.ShouldBe(1);
            TableRow tableRow = table.Rows.First();

            userDetails.ShouldNotBeNull();

            Dictionary <String, String> userClaims = new Dictionary <String, String>();
            String claims = SpecflowTableHelper.GetStringRowValue(tableRow, "Claims");

            String[] claimList = claims.Split(",");
            foreach (String claim in claimList)
            {
                // Split into claim name and value
                String[] c = claim.Split(":");
                userClaims.Add(c[0].Trim(), c[1].Trim());
            }

            String roles = SpecflowTableHelper.GetStringRowValue(tableRow, "Roles");

            userDetails.EmailAddress.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address"));
            userDetails.PhoneNumber.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Phone Number"));
            userDetails.UserId.ShouldBe(userId);
            userDetails.UserName.ShouldBe(SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address"));
            if (string.IsNullOrEmpty(roles))
            {
                userDetails.Roles.ShouldBeEmpty();
            }
            else
            {
                userDetails.Roles.ShouldBe(roles.Split(",").ToList());
            }

            foreach (KeyValuePair <String, String> claim in userClaims)
            {
                KeyValuePair <String, String> x = userDetails.Claims.Where(c => c.Key == claim.Key).SingleOrDefault();
                x.Value.ShouldBe(claim.Value);
            }
        }
Esempio n. 29
0
        private async Task SendSMS(TableRow tableRow)
        {
            String sender      = SpecflowTableHelper.GetStringRowValue(tableRow, "Sender");
            String destination = SpecflowTableHelper.GetStringRowValue(tableRow, "Destination");
            String message     = SpecflowTableHelper.GetStringRowValue(tableRow, "Message");

            SendSMSRequest request = new SendSMSRequest
            {
                ConnectionIdentifier = Guid.NewGuid(),
                Sender      = sender,
                Destination = destination,
                Message     = message
            };

            SendSMSResponse sendEmailResponse = await this.TestingContext.DockerHelper.MessagingServiceClient.SendSMS(this.TestingContext.AccessToken, request, CancellationToken.None).ConfigureAwait(false);

            sendEmailResponse.MessageId.ShouldNotBe(Guid.Empty);
        }
        public async Task WhenICreateTheFollowingEstates(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName");

                CreateEstateRequest createEstateRequest = new CreateEstateRequest
                {
                    EstateId   = Guid.NewGuid(),
                    EstateName = estateName
                };

                CreateEstateResponse response = await this.TestingContext.DockerHelper.EstateClient
                                                .CreateEstate(this.TestingContext.AccessToken, createEstateRequest, CancellationToken.None)
                                                .ConfigureAwait(false);

                response.ShouldNotBeNull();
                response.EstateId.ShouldNotBe(Guid.Empty);

                // Cache the estate id
                this.TestingContext.AddEstateDetails(response.EstateId, estateName);

                this.TestingContext.Logger.LogInformation($"Estate {estateName} created with Id {response.EstateId}");

                EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow);

                // Setup the subscriptions for the estate
                await Retry.For(async() =>
                {
                    await this.TestingContext.DockerHelper.PopulateSubscriptionServiceConfiguration(estateName).ConfigureAwait(false);
                }, retryFor : TimeSpan.FromMinutes(2), retryInterval : TimeSpan.FromSeconds(30));

                EstateResponse estate = null;
                await Retry.For(async() =>
                {
                    estate = await this.TestingContext.DockerHelper.EstateClient
                             .GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false);
                    estate.ShouldNotBeNull();
                }, TimeSpan.FromMinutes(2)).ConfigureAwait(false);

                estate.EstateName.ShouldBe(estateDetails.EstateName);
            }
        }