Beispiel #1
0
 public static PexipConfigResponse MapPexipConfigToResponse(KinlyConfiguration kinlyConfiguration)
 {
     return(new PexipConfigResponse
     {
         PexipSelfTestNode = kinlyConfiguration.PexipSelfTestNode
     });
 }
Beispiel #2
0
        public static ConferenceForAdminResponse MapConferenceToSummaryResponse(Conference conference,
                                                                                KinlyConfiguration configuration)
        {
            var phoneNumber  = configuration.ConferencePhoneNumber;
            var participants = conference.GetParticipants()
                               .Select(ParticipantToSummaryResponseMapper.MapParticipantToSummary)
                               .ToList();

            return(new ConferenceForAdminResponse
            {
                Id = conference.Id,
                CaseType = conference.CaseType,
                CaseNumber = conference.CaseNumber,
                CaseName = conference.CaseName,
                ScheduledDateTime = conference.ScheduledDateTime,
                StartedDateTime = conference.ActualStartTime,
                ClosedDateTime = conference.ClosedDateTime,
                ScheduledDuration = conference.ScheduledDuration,
                Status = conference.GetCurrentStatus(),
                Participants = participants,
                HearingRefId = conference.HearingRefId,
                HearingVenueName = conference.HearingVenueName,
                TelephoneConferenceId = conference.MeetingRoom.TelephoneConferenceId,
                TelephoneConferenceNumber = phoneNumber
            });
        }
        public void TestInitialize()
        {
            HearingId          = Guid.NewGuid();
            EndpointId         = Guid.NewGuid();
            AddEndpointRequest = new AddEndpointRequest {
                DisplayName = "DisplayNameAdded"
            };

            QueryHandler       = new Mock <IQueryHandler>();
            CommandHandlerMock = new Mock <ICommandHandler>();
            RandomGenerator    = new Mock <IRandomGenerator>();
            EventPublisher     = new Mock <IEventPublisher>();
            KinlyConfiguration = new KinlyConfiguration {
                SipAddressStem = "@hmcts.net"
            };

            Controller = new EndPointsController(
                CommandHandlerMock.Object,
                RandomGenerator.Object,
                new OptionsWrapper <KinlyConfiguration>(KinlyConfiguration),
                EventPublisher.Object, QueryHandler.Object);

            QueryHandler.Setup(q => q.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync(GetVideoHearing(true));
        }
 public void SetUp()
 {
     _kinlyConfiguration = new KinlyConfiguration
     {
         SelfTestApiSecret = "W2gEmBn2H7b2FCMIQl6l9rggbJU1qR7luIeAf1uuaY+ik6TP5rN0NEsPVg0TGkroiel0SoCQT7w3cbk7hFrBtA=="
     };
 }
        public void OneTimeSetup()
        {
            var configRootBuilder = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json")
                                    .AddEnvironmentVariables()
                                    .AddUserSecrets <Startup>();

            var configRoot = configRootBuilder.Build();

            _databaseConnectionString = configRoot.GetConnectionString("VideoApi");
            _kinlyConfiguration       = Options.Create(configRoot.GetSection("KinlyConfiguration").Get <KinlyConfiguration>()).Value;

            var dbContextOptionsBuilder = new DbContextOptionsBuilder <VideoApiDbContext>();

            dbContextOptionsBuilder.EnableSensitiveDataLogging();
            dbContextOptionsBuilder.UseSqlServer(_databaseConnectionString);
            dbContextOptionsBuilder.EnableSensitiveDataLogging();
            VideoBookingsDbContextOptions = dbContextOptionsBuilder.Options;

            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            context.Database.Migrate();

            TestDataManager = new TestDataManager(_kinlyConfiguration, VideoBookingsDbContextOptions);
        }
Beispiel #6
0
 public TokenController(IHashGenerator hashGenerator,
                        ICustomJwtTokenProvider customJwtTokenProvider,
                        KinlyConfiguration kinlyConfiguration)
 {
     _hashGenerator          = hashGenerator;
     _customJwtTokenProvider = customJwtTokenProvider;
     _kinlyConfiguration     = kinlyConfiguration;
 }
 public EndPointsController(ICommandHandler commandHandler, IRandomGenerator randomGenerator,
                            IOptions <KinlyConfiguration> kinlyConfiguration, IEventPublisher eventPublisher, IQueryHandler queryHandler)
 {
     _commandHandler     = commandHandler;
     _randomGenerator    = randomGenerator;
     _eventPublisher     = eventPublisher;
     _queryHandler       = queryHandler;
     _kinlyConfiguration = kinlyConfiguration.Value;
 }
Beispiel #8
0
        public void Should_return_not_found()
        {
            _kinlyConfiguration = null;
            _controller         = new SelfTestController(Options.Create(_kinlyConfiguration), _mockLogger.Object);

            var response = (NotFoundResult)_controller.GetPexipServicesConfiguration();

            response.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Beispiel #9
0
        public void Setup()
        {
            var secretKey           = "6t8obpbl0iHOSvDpnUImSdZjYEpTcaEWC8SzLO4/X6iOHArHEm/3Ja6NnzaKS6JwE3U/Bjy1LE/bARMqNCN98w==";
            var customTokenSettings = new KinlyConfiguration {
                ApiSecret = secretKey, Audience = Audience, Issuer = Issuer
            };

            _customJwtTokenProvider = new CustomJwtTokenProvider(customTokenSettings);
            _customJwtTokenHandler  = new CustomJwtTokenHandler(customTokenSettings);
        }
 public ConfigSettingsController(IOptions <AzureAdConfiguration> azureAdConfiguration,
                                 IOptions <HearingServicesConfiguration> servicesConfiguration, KinlyConfiguration kinlyConfiguration, ILogger <ConfigSettingsController> logger,
                                 IMapperFactory mapperFactory)
 {
     _azureAdConfiguration  = azureAdConfiguration.Value;
     _servicesConfiguration = servicesConfiguration.Value;
     _logger             = logger;
     _mapperFactory      = mapperFactory;
     _kinlyConfiguration = kinlyConfiguration;
 }
        public void Should_map_all_properties()
        {
            var pexipConfig = new KinlyConfiguration
            {
                PexipSelfTestNode = "self-test.node"
            };

            var response = PexipConfigurationMapper.MapPexipConfigToResponse(pexipConfig);

            response.PexipSelfTestNode.Should().BeEquivalentTo(pexipConfig.PexipSelfTestNode);
        }
 public ConfigSettingsController(
     IOptions <AzureAdConfiguration> azureAdConfiguration,
     IOptions <KinlyConfiguration> kinlyConfiguration,
     IOptions <ApplicationInsightsConfiguration> applicationInsightsConfiguration,
     IOptions <TestUserSecrets> testSettings)
 {
     _azureAdConfiguration             = azureAdConfiguration.Value;
     _kinlyConfiguration               = kinlyConfiguration.Value;
     _applicationInsightsConfiguration = applicationInsightsConfiguration.Value;
     _testUserSecrets = testSettings.Value;
 }
 public KinlyPlatformService(IKinlyApiClient kinlyApiClient,
                             IOptions <KinlyConfiguration> kinlyConfigOptions,
                             ILogger <KinlyPlatformService> logger,
                             IKinlySelfTestHttpClient kinlySelfTestHttpClient,
                             IPollyRetryService pollyRetryService)
 {
     _kinlyApiClient          = kinlyApiClient;
     _logger                  = logger;
     _kinlyConfigOptions      = kinlyConfigOptions.Value;
     _kinlySelfTestHttpClient = kinlySelfTestHttpClient;
     _pollyRetryService       = pollyRetryService;
 }
Beispiel #14
0
        public void Should_return_response_with_settings()
        {
            var azureAdConfiguration = new AzureAdConfiguration
            {
                ClientId              = "ClientId",
                TenantId              = "TenantId",
                ClientSecret          = "ClientSecret",
                Authority             = "Authority",
                RedirectUri           = "https://vh-admin-web.com",
                PostLogoutRedirectUri = "https://vh-admin-web.com/"
            };

            var testSettings = new TestUserSecrets
            {
                TestUsernameStem = "@hmcts.net"
            };

            var kinlyConfiguration = new KinlyConfiguration {
                ConferencePhoneNumber = "1111111", JoinByPhoneFromDate = "2021-02-03"
            };
            var applicationInsightsConfiguration = new ApplicationInsightsConfiguration();

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Scheme   = "https";
            httpContext.Request.Host     = new HostString("vh-admin-web.com");
            httpContext.Request.PathBase = "";

            var controllerContext = new ControllerContext {
                HttpContext = httpContext
            };

            var configSettingsController = new ConfigSettingsController(
                Options.Create(azureAdConfiguration),
                Options.Create(kinlyConfiguration),
                Options.Create(applicationInsightsConfiguration),
                Options.Create(testSettings))
            {
                ControllerContext = controllerContext
            };

            var actionResult   = (OkObjectResult)configSettingsController.Get().Result;
            var clientSettings = (ClientSettingsResponse)actionResult.Value;

            clientSettings.ClientId.Should().Be(azureAdConfiguration.ClientId);
            clientSettings.TenantId.Should().Be(azureAdConfiguration.TenantId);
            clientSettings.RedirectUri.Should().Be(azureAdConfiguration.RedirectUri);
            clientSettings.PostLogoutRedirectUri.Should().Be(azureAdConfiguration.PostLogoutRedirectUri);
            clientSettings.ConferencePhoneNumber.Should().Be(kinlyConfiguration.ConferencePhoneNumber);
            clientSettings.JoinByPhoneFromDate.Should().Be(kinlyConfiguration.JoinByPhoneFromDate);
            clientSettings.TestUsernameStem.Should().Be(testSettings.TestUsernameStem);
        }
Beispiel #15
0
        public void Should_return_okay_with_response()
        {
            _kinlyConfiguration = new KinlyConfiguration();
            _controller         = new SelfTestController(Options.Create(_kinlyConfiguration), _mockLogger.Object);
            _kinlyConfiguration.PexipSelfTestNode = "test.self-test.node";

            var response = (OkObjectResult)_controller.GetPexipServicesConfiguration();

            response.Should().NotBeNull();
            var pexipConfig = (PexipConfigResponse)response.Value;

            pexipConfig.PexipSelfTestNode.Should().Be(_kinlyConfiguration.PexipSelfTestNode);
        }
 public ConferenceController(IQueryHandler queryHandler, ICommandHandler commandHandler,
                             IVideoPlatformService videoPlatformService, IOptions <KinlyConfiguration> kinlyConfiguration,
                             ILogger <ConferenceController> logger, IAudioPlatformService audioPlatformService,
                             IAzureStorageServiceFactory azureStorageServiceFactory, IPollyRetryService pollyRetryService)
 {
     _queryHandler         = queryHandler;
     _commandHandler       = commandHandler;
     _videoPlatformService = videoPlatformService;
     _kinlyConfiguration   = kinlyConfiguration.Value;
     _logger = logger;
     _audioPlatformService       = audioPlatformService;
     _azureStorageServiceFactory = azureStorageServiceFactory;
     _pollyRetryService          = pollyRetryService;
 }
Beispiel #17
0
        public void Should_be_invalid_token_when_token_generated_with_different_secret()
        {
            var secretKey           = "F8pf/zwOgm/kASEFs+BKRDdyq+RhHCQ9i9tPjeaPjUebm6HvzXKIsr/nX28wpwAZoWRG0FQK9LVf6nrkW/vg4w==";
            var customTokenSettings = new KinlyConfiguration {
                ApiSecret = secretKey, Audience = Audience, Issuer = Issuer
            };

            _customJwtTokenProvider = new CustomJwtTokenProvider(customTokenSettings);

            var token = _customJwtTokenProvider.GenerateApiToken("Test User", 1);

            var claimsPrincipal = _customJwtTokenHandler.IsValidToken(token);

            claimsPrincipal.Should().BeFalse();
        }
        public HearingsController(IQueryHandler queryHandler, ICommandHandler commandHandler,
                                  IEventPublisher eventPublisher,
                                  IRandomGenerator randomGenerator,
                                  IOptions <KinlyConfiguration> kinlyConfiguration,
                                  IHearingService hearingService,
                                  ILogger logger)
        {
            _queryHandler    = queryHandler;
            _commandHandler  = commandHandler;
            _eventPublisher  = eventPublisher;
            _randomGenerator = randomGenerator;
            _hearingService  = hearingService;
            _logger          = logger;

            _kinlyConfiguration = kinlyConfiguration.Value;
        }
        public void Setup()
        {
            SbQueueClient      = new ServiceBusQueueClientFake();
            QueryHandlerMock   = new Mock <IQueryHandler>();
            CommandHandlerMock = new Mock <ICommandHandler>();
            HearingServiceMock = new Mock <IHearingService>();
            KinlyConfiguration = new KinlyConfiguration {
                SipAddressStem = "@WhereAreYou.com"
            };
            RandomGenerator = new Mock <IRandomGenerator>();
            _eventPublisher = new EventPublisher(SbQueueClient);
            Logger          = new Mock <ILogger>();

            Controller = new BookingsApi.Controllers.HearingsController(QueryHandlerMock.Object, CommandHandlerMock.Object,
                                                                        _eventPublisher, RandomGenerator.Object, new OptionsWrapper <KinlyConfiguration>(KinlyConfiguration),
                                                                        HearingServiceMock.Object, Logger.Object);
        }
Beispiel #20
0
        public void Should_return_response_with_settings()
        {
            var securitySettings = new AzureAdConfiguration
            {
                ClientId            = "ClientId",
                ClientSecret        = "ClientSecret",
                TenantId            = "TenantId",
                Authority           = "Authority",
                ApplicationInsights = new ApplicationInsightsConfiguration {
                    InstrumentationKey = "AiKey"
                }
            };

            var servicesConfiguration = new HearingServicesConfiguration
            {
                VideoApiUrl = "https://vh-video-api/"
            };

            var kinlyConfiguration = new KinlyConfiguration
            {
                JoinByPhoneFromDate = "2021-02-09"
            };

            var parameters = new ParameterBuilder(_mocker).AddObject(Options.Create(securitySettings))
                             .AddObject(Options.Create(servicesConfiguration))
                             .AddObject(kinlyConfiguration).Build();

            var configSettingsController = _mocker.Create <ConfigSettingsController>(parameters);

            var actionResult   = (OkObjectResult)configSettingsController.GetClientConfigurationSettings().Result;
            var clientSettings = (ClientSettingsResponse)actionResult.Value;

            clientSettings.ClientId.Should().Be(securitySettings.ClientId);
            clientSettings.TenantId.Should().Be(securitySettings.TenantId);
            clientSettings.VideoApiUrl.Should().Be(servicesConfiguration.VideoApiUrl);
            clientSettings.JoinByPhoneFromDate.Should().Be(kinlyConfiguration.JoinByPhoneFromDate);
        }
Beispiel #21
0
 public TestDataManager(KinlyConfiguration kinlyConfiguration, DbContextOptions <VideoApiDbContext> dbContextOptions)
 {
     _kinlyConfiguration = kinlyConfiguration;
     _dbContextOptions   = dbContextOptions;
 }
Beispiel #22
0
 public CustomJwtTokenProvider(KinlyConfiguration kinlyConfiguration)
 {
     _kinlyConfiguration = kinlyConfiguration;
 }
        public static string SetCustomJwTokenForCallback(KinlyConfiguration kinlyConfiguration)
        {
            var generateTokenWithAsciiKey = new CustomJwtTokenProvider(kinlyConfiguration).GenerateTokenForCallbackEndpoint("VhVideoApi", TokenExpiresInMinutes);

            return(generateTokenWithAsciiKey);
        }
 public HashGenerator(KinlyConfiguration kinlyConfiguration)
 {
     _kinlyConfiguration = kinlyConfiguration;
 }
 public SelfTestController(IOptions <KinlyConfiguration> kinlyConfiguration,
                           ILogger <SelfTestController> logger)
 {
     _logger             = logger;
     _kinlyConfiguration = kinlyConfiguration.Value;
 }
 public KinlySelfTestHttpClient(HttpClient httpClient, IOptions <KinlyConfiguration> kinlyConfigOptions, ILogger <KinlySelfTestHttpClient> logger)
 {
     _httpClient         = httpClient;
     _kinlyConfigOptions = kinlyConfigOptions.Value;
     _logger             = logger;
 }
 public void SetUp()
 {
     _kinlyConfiguration = new KinlyConfiguration {
         SelfTestApiSecret = "SECRET"
     };
 }