예제 #1
0
 public AccountService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLocation = serviceLocation;
     _http            = http;
 }
예제 #2
0
 public UserFriendlyNotFoundMiddeware(
     RequestDelegate next,
     ServiceLocation serviceLocation)
 {
     _next            = next;
     _serviceLocation = serviceLocation;
 }
예제 #3
0
        public MasterService(IDistributionConfiguration config, LoggingContext loggingContext, string buildId)
        {
            Contract.Requires(config != null && config.BuildRole == DistributedBuildRoles.Master);
            Contract.Ensures(m_remoteWorkers != null);

            m_isGrpcEnabled = config.IsGrpcEnabled;

            // Create all remote workers
            m_buildServicePort = config.BuildServicePort;
            m_remoteWorkers    = new RemoteWorker[config.BuildWorkers.Count];

            m_loggingContext     = loggingContext;
            DistributionServices = new DistributionServices(buildId);

            for (int i = 0; i < m_remoteWorkers.Length; i++)
            {
                var configWorker    = config.BuildWorkers[i];
                var workerId        = i + 1; // 0 represents the local worker.
                var serviceLocation = new ServiceLocation {
                    IpAddress = configWorker.IpAddress, Port = configWorker.BuildServicePort
                };
                m_remoteWorkers[i] = new RemoteWorker(m_isGrpcEnabled, loggingContext, (uint)workerId, this, serviceLocation);
            }

            if (m_isGrpcEnabled)
            {
                m_masterServer = new Grpc.GrpcMasterServer(loggingContext, this, buildId);
            }
            else
            {
#if !DISABLE_FEATURE_BOND_RPC
                m_masterServer = new InternalBond.BondMasterServer(loggingContext, this);
#endif
            }
        }
예제 #4
0
        public void FindMetaEA_WithVersion_FoundMultiple_ExcMessage()
        {
            // Arrange
            string          name            = "BSKlantBeheer";
            string          profile         = "Development";
            decimal?        version         = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name    = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock <IServiceLocationDatamapper>(MockBehavior.Strict);

            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
            .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            try
            {
                // Act
                var result = target.FindMetadataEndpointAddress(serviceLocation);
                Assert.Fail();
            }
            catch (FaultException <FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Count);
                Assert.AreEqual("Multiple location services found instead of one", ex.Detail.Details[0].Message);
            }
        }
예제 #5
0
 public KahlaDbContext(
     DbContextOptions <KahlaDbContext> options,
     ServiceLocation serviceLocation)
     : base(options)
 {
     _serviceLocation = serviceLocation;
 }
예제 #6
0
 public DeveloperApiService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLocation = serviceLocation;
     _http            = http;
 }
예제 #7
0
        public void FindMetaEA_WithVersion_FoundSingle()
        {
            // Arrange
            string          name            = "BSKlantBeheer";
            string          profile         = "Development";
            decimal?        version         = 1.0m;
            string          expected        = "http://localhost:30412/BSKlantbeheer/mex";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name    = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock <IServiceLocationDatamapper>(MockBehavior.Strict);

            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version)).Returns(expected);
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            mock.Verify(m => m.FindMetadataEndpointAddress(name, profile, version), Times.Once);
            Assert.AreEqual(expected, result);
        }
        public void FindMetaEA_WithVersion_FoundMultiple_ExcMessage()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
                .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            try
            {
                // Act
                var result = target.FindMetadataEndpointAddress(serviceLocation);
                Assert.Fail();
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Count);
                Assert.AreEqual("Multiple location services found instead of one", ex.Detail.Details[0].Message);
            }
        }
        /// <summary>
        /// A method used to get the target service url by specified service location.
        /// </summary>
        /// <param name="serviceLocation">A parameter represents the service location where host the MS-COPYS service.</param>
        /// <returns>A return value represents the service URL.</returns>
        private string GetTargetServiceUrl(ServiceLocation serviceLocation)
        {
            string targetServiceUrl;

            switch (serviceLocation)
            {
            case ServiceLocation.SourceSUT:
            {
                targetServiceUrl = Common.GetConfigurationPropertyValue("TargetServiceUrlOfSourceSUT", this.Site);
                break;
            }

            case ServiceLocation.DestinationSUT:
            {
                targetServiceUrl = Common.GetConfigurationPropertyValue("TargetServiceUrlOfDestinationSUT", this.Site);
                break;
            }

            default:
            {
                throw new InvalidOperationException("The test suite only support [SourceSUT] and [DestinationSUT] types ServiceLocation.");
            }
            }

            return(targetServiceUrl);
        }
예제 #10
0
 public AppsController(
     UserManager <DeveloperUser> userManager,
     SignInManager <DeveloperUser> signInManager,
     ILoggerFactory loggerFactory,
     DeveloperDbContext dbContext,
     ServiceLocation serviceLocation,
     StorageService storageService,
     OSSApiService ossApiService,
     AppsContainer appsContainer,
     CoreApiService coreApiService,
     IConfiguration configuration,
     SitesService siteService)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _logger          = loggerFactory.CreateLogger <AppsController>();
     _dbContext       = dbContext;
     _serviceLocation = serviceLocation;
     _storageService  = storageService;
     _ossApiService   = ossApiService;
     _appsContainer   = appsContainer;
     _coreApiService  = coreApiService;
     _configuration   = configuration;
     _siteService     = siteService;
 }
예제 #11
0
 public SitesService(
     HTTPService http,
     ServiceLocation serviceLocation)
 {
     _http            = http;
     _serviceLocation = serviceLocation;
 }
예제 #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RemoteWorker(
            bool isGrpcEnabled,
            LoggingContext appLoggingContext,
            uint workerId,
            MasterService masterService,
            ServiceLocation serviceLocation)
            : base(workerId, name: I($"#{workerId} ({serviceLocation.IpAddress}::{serviceLocation.Port})"))
        {
            m_isGrpcEnabled           = isGrpcEnabled;
            m_appLoggingContext       = appLoggingContext;
            m_masterService           = masterService;
            m_buildRequests           = new BlockingCollection <ValueTuple <PipCompletionTask, SinglePipBuildRequest> >();
            m_attachCompletion        = TaskSourceSlim.Create <bool>();
            m_executionBlobCompletion = TaskSourceSlim.Create <bool>();

            m_serviceLocation = serviceLocation;

            if (isGrpcEnabled)
            {
                m_workerClient = new Grpc.GrpcWorkerClient(m_appLoggingContext, masterService.DistributionServices.BuildId, serviceLocation.IpAddress, serviceLocation.Port);
            }
            else
            {
#if !DISABLE_FEATURE_BOND_RPC
                m_workerClient = new InternalBond.BondWorkerClient(m_appLoggingContext, Name, serviceLocation.IpAddress, serviceLocation.Port, masterService.DistributionServices, OnActivateConnection, OnDeactivateConnection, OnConnectionTimeOut);
#endif
            }

            // Depending on how long send requests take. It might make sense to use the same thread between all workers.
            m_sendThread = new Thread(SendBuildRequests);
        }
        private async Task <bool> IsHealthy(ServiceLocation serviceLocation,
                                            TimeSpan workerResponseTimeout)
        {
            bool isHealthy = false;

            try
            {
                Channel channel = GetChannel(serviceLocation);

                isHealthy = await IsHealthy(serviceLocation, channel, workerResponseTimeout);
            }
            catch (TimeoutException)
            {
                _logger.LogDebug(
                    "Service location {serviceLocation} took longer than {timeout}s. It is ignored.",
                    serviceLocation, workerResponseTimeout.TotalSeconds);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e,
                                   "Error checking service health / load report for {serviceLocation}",
                                   serviceLocation);

                _lastException = e;
            }

            return(isHealthy);
        }
예제 #14
0
 public ApiController(
     UserManager <KahlaUser> userManager,
     SignInManager <KahlaUser> signInManager,
     KahlaDbContext dbContext,
     PushKahlaMessageService pushService,
     IConfiguration configuration,
     AuthService <KahlaUser> authService,
     ServiceLocation serviceLocation,
     OAuthService oauthService,
     ChannelService channelService,
     StorageService storageService,
     AppsContainer appsContainer,
     UserService userService)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _dbContext       = dbContext;
     _pusher          = pushService;
     _configuration   = configuration;
     _authService     = authService;
     _serviceLocation = serviceLocation;
     _oauthService    = oauthService;
     _channelService  = channelService;
     _storageService  = storageService;
     _appsContainer   = appsContainer;
     _userService     = userService;
 }
 public ConfirmationEmailSender(
     ServiceLocation serviceLocation,
     AiurEmailSender emailSender)
 {
     _serviceLocation = serviceLocation;
     _emailSender     = emailSender;
 }
        protected override void Initialize()
        {
            browser = new ServiceBrowser();
            browser.ServiceAdded += delegate(object o, ServiceBrowseEventArgs args)
            {
                Console.WriteLine("Found Service: {0}", args.Service.Name);
                args.Service.Resolved += delegate(object o2, ServiceResolvedEventArgs args2)
                {
                    lock (resolveLock)
                    {
                        IResolvableService s = (IResolvableService)args2.Service;

                        ServiceLocation loc = new ServiceLocation(s.HostEntry.AddressList[0], s.Port, s.FullName);
                        Logger.Info("A new ethernet interface was found");
                        SmartScopeInterfaceEthernet ethif = new SmartScopeInterfaceEthernet(loc.ip, loc.port, OnInterfaceDisconnect);
                        if (ethif.Connected)
                        {
                            createdInterfaces.Add(loc, ethif);
                            if (onConnect != null)
                            {
                                onConnect(ethif, true);
                            }
                        }
                        else
                        {
                            Logger.Info("... but could not connect to ethernet interface");
                        }
                    }
                };
                args.Service.Resolve();
            };

            browser.Browse(Net.Net.SERVICE_TYPE, Net.Net.REPLY_DOMAIN);
        }
예제 #17
0
        public void FindMetaEA_EmptyName_ExcMessage()
        {
            // Arrange
            string name = "";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);

            var target = new ServiceLocatorService(mock.Object);

            // Act
            try
            {
                var result = target.FindMetadataEndpointAddress(serviceLocation);
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Count);
                Assert.AreEqual("Name or Profile is null", ex.Detail.Details[0].Message);
            }
        }
        public async Task ShouldCreateScheduleWhenRequested()
        {
            var scheduleWebApiClient = new JsonServiceClient(ScheduleWebApiBaseUrl);

            var maintenanceWindowServiceLocation = new ServiceLocation
            {
                Location = new Uri("http://localhost:5678")
            };

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/MaintenanceWindowService"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindowServiceLocation));

            var maintenanceWindows = Any.Instance <MaintenanceWindow>();

            _mockServer.Given(
                Request.Create().UsingGet().WithPath("/Planned"))
            .RespondWith(
                Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindows));

            var workloadItems = new List <WorkloadItem>
            {
                Any.Instance <WorkloadItem>(),
                Any.Instance <WorkloadItem>()
            };
            var createScheduleRequest = new CreateScheduleRequest
            {
                WorkloadItems = workloadItems
            };

            var result = await scheduleWebApiClient.PostAsync(createScheduleRequest).ConfigureAwait(false);

            result.Id.Should().NotBe(Guid.Empty);
        }
예제 #19
0
 public UserService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLocation = serviceLocation;
     _http            = http;
 }
예제 #20
0
 public AuthController(
     ServiceLocation serviceLocation,
     IWebHostEnvironment env,
     AuthService <KahlaUser> authService,
     UserManager <KahlaUser> userManager,
     SignInManager <KahlaUser> signInManager,
     UserService userService,
     AppsContainer appsContainer,
     KahlaPushService pusher,
     ChannelService channelService,
     VersionChecker version,
     KahlaDbContext dbContext,
     IOptions <List <DomainSettings> > optionsAccessor,
     AiurCache cache)
 {
     _serviceLocation = serviceLocation;
     _env             = env;
     _authService     = authService;
     _userManager     = userManager;
     _signInManager   = signInManager;
     _userService     = userService;
     _appsContainer   = appsContainer;
     _pusher          = pusher;
     _channelService  = channelService;
     _version         = version;
     _dbContext       = dbContext;
     _cache           = cache;
     _appDomains      = optionsAccessor.Value;
 }
예제 #21
0
        public void FindMetaEA_WithVersion_FoundMultiple()
        {
            // Arrange
            string          name            = "BSKlantBeheer";
            string          profile         = "Development";
            decimal?        version         = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name    = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock <IServiceLocationDatamapper>(MockBehavior.Strict);

            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
            .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
예제 #22
0
 public PushMessageService(
     HTTPService httpService,
     ServiceLocation serviceLocation)
 {
     _httpService     = httpService;
     _serviceLocation = serviceLocation;
 }
예제 #23
0
 public TokenService(
     HTTPService http,
     ServiceLocation serviceLocation)
 {
     _http            = http;
     _serviceLocation = serviceLocation;
 }
예제 #24
0
 public AuthController(
     ServiceLocation serviceLocation,
     IConfiguration configuration,
     IHostingEnvironment env,
     AuthService <ApplicationUser> authService,
     OAuthService oauthService,
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     UserService userService,
     AppsContainer appsContainer,
     ChatPushService pusher,
     ChannelService channelService,
     VersionChecker version,
     ApplicationDbContext dbContext,
     ThirdPartyPushService thirdPartyPushService)
 {
     _serviceLocation       = serviceLocation;
     _configuration         = configuration;
     _env                   = env;
     _authService           = authService;
     _oauthService          = oauthService;
     _userManager           = userManager;
     _signInManager         = signInManager;
     _userService           = userService;
     _appsContainer         = appsContainer;
     _pusher                = pusher;
     _channelService        = channelService;
     _version               = version;
     _dbContext             = dbContext;
     _thirdPartyPushService = thirdPartyPushService;
 }
예제 #25
0
 public OSSApiService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLocation = serviceLocation;
     _http            = http;
 }
예제 #26
0
 public AuthController(
     ServiceLocation serviceLocation,
     IConfiguration configuration,
     IHostingEnvironment env,
     AuthService <KahlaUser> authService,
     OAuthService oauthService,
     UserManager <KahlaUser> userManager,
     SignInManager <KahlaUser> signInManager,
     UserService userService,
     AppsContainer appsContainer,
     KahlaPushService pusher,
     ChannelService channelService,
     VersionChecker version,
     KahlaDbContext dbContext,
     IMemoryCache cache)
 {
     _serviceLocation = serviceLocation;
     _configuration   = configuration;
     _env             = env;
     _authService     = authService;
     _oauthService    = oauthService;
     _userManager     = userManager;
     _signInManager   = signInManager;
     _userService     = userService;
     _appsContainer   = appsContainer;
     _pusher          = pusher;
     _channelService  = channelService;
     _version         = version;
     _dbContext       = dbContext;
     _cache           = cache;
 }
예제 #27
0
 public FoldersService(
     HTTPService http,
     ServiceLocation serviceLocation)
 {
     _http            = http;
     _serviceLocation = serviceLocation;
 }
예제 #28
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Pid != null)
         {
             hashCode = hashCode * 59 + Pid.GetHashCode();
         }
         if (Title != null)
         {
             hashCode = hashCode * 59 + Title.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (BundleLocation != null)
         {
             hashCode = hashCode * 59 + BundleLocation.GetHashCode();
         }
         if (ServiceLocation != null)
         {
             hashCode = hashCode * 59 + ServiceLocation.GetHashCode();
         }
         if (Properties != null)
         {
             hashCode = hashCode * 59 + Properties.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #29
0
        public void FindMetaEA_NoProfile_ExcMessage()
        {
            // Arrange
            string          name            = "BSKlantBeheer";
            string          profile         = null;
            decimal?        version         = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name    = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock <IServiceLocationDatamapper>(MockBehavior.Strict);

            var target = new ServiceLocatorService(mock.Object);

            // Act
            try
            {
                var result = target.FindMetadataEndpointAddress(serviceLocation);
            }
            catch (FaultException <FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Count);
                Assert.AreEqual("Name or Profile is null", ex.Detail.Details[0].Message);
            }
        }
 public DebugApiController(
     UserManager <KahlaUser> userManager,
     SignInManager <KahlaUser> signInManager,
     KahlaDbContext dbContext,
     PushKahlaMessageService pushService,
     IConfiguration configuration,
     AuthService <KahlaUser> authService,
     ServiceLocation serviceLocation,
     OAuthService oauthService,
     ChannelService channelService,
     StorageService storageService,
     AppsContainer appsContainer,
     UserService userService) : base(
         userManager,
         signInManager,
         dbContext,
         pushService,
         configuration,
         authService,
         serviceLocation,
         oauthService,
         channelService,
         storageService,
         appsContainer,
         userService)
 {
 }
예제 #31
0
 public SecretService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLoation = serviceLocation;
     _http           = http;
 }
 public ChannelService(
     ServiceLocation serviceLocation,
     HTTPService http)
 {
     _serviceLocation = serviceLocation;
     _http            = http;
 }
예제 #33
0
        public string FindMetadataEndpointAddress(ServiceLocation serviceLocation)
        {
            FunctionalErrorList errorList = new FunctionalErrorList();
            if (serviceLocation != null)
            {
                if (String.IsNullOrEmpty(serviceLocation.Name) || String.IsNullOrEmpty(serviceLocation.Profile))
                {
                    errorList.Add(new FunctionalErrorDetail
                    {
                        Message = "Name or Profile is null"
                    });
                    throw new FaultException<FunctionalErrorList>(errorList);
                }

                try
                {
                    if (serviceLocation.Version == null)
                    {
                        return _datamapper.FindMetadataEndpointAddress(serviceLocation.Name, serviceLocation.Profile);
                    }
                    return _datamapper.FindMetadataEndpointAddress(serviceLocation.Name, serviceLocation.Profile, serviceLocation.Version);
                }
                catch (MultipleRecordsFoundException ex)
                {
                    errorList.Add(new FunctionalErrorDetail
                    {
                        Message = ex.Message,
                        Data = ex.Data
                    });
                }
                catch (NoRecordsFoundException ex)
                {
                    errorList.Add(new FunctionalErrorDetail
                    {
                        Message = ex.Message,
                        Data = ex.Data
                    });
                }
                catch (VersionedRecordFoundException ex)
                {
                    errorList.Add(new FunctionalErrorDetail
                    {
                        Message = ex.Message,
                        Data = ex.Data
                    });
                }
            }

            if (errorList.HasErrors)
            {
                throw new FaultException<FunctionalErrorList>(errorList);
            }

            return null;
        }
 private static List<DarwinServiceLocation> createDarwinServiceLocationArray(ServiceLocation[] serviceLocation)
 {
     List<DarwinServiceLocation> result = new List<DarwinServiceLocation>();
     if (serviceLocation == null)
         return result;
     foreach (ServiceLocation location in serviceLocation)
     {
         DarwinServiceLocation toAdd = new DarwinServiceLocation(
             location.locationName, location.crs, location.via, location.futureChangeTo, location.assocIsCancelled);
         result.Add(toAdd);
     }
     return result;
 }
예제 #35
0
        public void Integration_FindMetaEA_WithVersion()
        {
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = "BSCurusadministatie",
                Profile = "Production"
            };

            IServiceLocatorService proxy = _factory.CreateChannel();

            string uri = proxy.FindMetadataEndpointAddress(serviceLocation);

            Assert.AreEqual("http://infosupport.intranet/CAS/mex", uri);
        }
예제 #36
0
        public void Integration_FindMetaEA_WithoutVersion_Integration()
        {
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = "PcSPlanningmaken",
                Profile = "Acceptation",
                Version = 1.0M
            };

            IServiceLocatorService proxy = _factory.CreateChannel();

            string uri = proxy.FindMetadataEndpointAddress(serviceLocation);

            Assert.AreEqual("http://infosupport.test/CAS/metadata", uri);
        }
        public void Register(ServiceLocation.IServiceLocationRuntimeManager manager, ServiceLocation.IServiceLocator locator)
        {
            if (ReferenceEquals(manager, null))
            {
                throw new ArgumentNullException("manager");
            }
            if (ReferenceEquals(locator, null))
            {
                throw new ArgumentNullException("locator");
            }

            var runtimeManager = new ServiceLocationRuntimeManager();
            manager.RegisterInstance<IServiceLocationRuntimeManager>(runtimeManager);
            manager.RegisterType<IServiceLocationSimulationManager, ServiceLocationSimulationManager>();
            manager.RegisterType<IServiceLocationIndividualTestManager, ServiceLocationIndividualTestManager>();
            manager.RegisterInstance(ServiceLocator.Instance);
            var sweeper = locator.Locate<IServiceLocationAssemblySweep>();
            sweeper.RegisterRegistrarProxy<IServiceLocationRegistrar>(new InternalServiceLocationRegistrarProxyFactory(runtimeManager, ServiceLocator.Instance));
        }
        public void FindMetaEA_WithoutVersion_FoundNone()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile))
                .Throws(new NoRecordsFoundException("No location services found"));
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
예제 #39
0
        public void FindMetaEA_EmptyProfile()
        {
            // Arrange
            string name = "BSBeheerService";
            string profile = "";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);

            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
        public void FindMetaEA_WithVersion_FoundMultiple()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
                .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
        public void FindMetaEA_WithVersion_FoundSingle()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            string expected = "http://localhost:30412/BSKlantbeheer/mex";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version)).Returns(expected);
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            mock.Verify(m => m.FindMetadataEndpointAddress(name, profile, version), Times.Once);
            Assert.AreEqual(expected, result);
        }
 public void Register(ServiceLocation.IServiceLocationRuntimeManager manager, ServiceLocation.IServiceLocator locator)
 {
     this.registrar.Register(this.manager, this.locator);
 }
        /// <summary>
        /// Switch the target service location. The adapter will send the MS-COPYS message to specified service location.
        /// </summary>
        /// <param name="serviceLocation">A parameter represents the service location which host the MS-COPYS service.</param>
        public void SwitchTargetServiceLocation(ServiceLocation serviceLocation)
        {
            if (null == this.copySoapService)
            {
                throw new InvalidOperationException(@"The adapter is not initialized, should call the ""IMS_COPYSAdapter.Initialize"" method to initialize adapter or call the ""ITestSite.GetAdapter"" method to get the initialized adapter instance.");
            }

           if (serviceLocation == this.currentServiceLocation)
           {
               return;
           }

           this.currentServiceLocation = serviceLocation;
           this.copySoapService.Url = this.GetTargetServiceUrl(this.currentServiceLocation);
        }
예제 #44
0
        private Uri GetServiceLocation(
                ServiceType serviceType, ServiceLocation serviceLocation, string issuanceLicense)
        {
            uint serviceUrlLength = 0;
            StringBuilder serviceUrl = null;

            int hr = SafeNativeMethods.DRMGetServiceLocation(
                _hSession, (uint)serviceType, (uint)serviceLocation, issuanceLicense, ref serviceUrlLength, null);

            if (hr == (int)RightsManagementFailureCode.UseDefault)
            {
                // there is a special case in which this error code means that application supposed to use the default nul URL 
                return null;
            }

            Errors.ThrowOnErrorCode(hr);

            checked
            {
                serviceUrl = new StringBuilder((int)serviceUrlLength);
            }

            hr = SafeNativeMethods.DRMGetServiceLocation(
                _hSession, (uint)serviceType, (uint)serviceLocation, issuanceLicense, ref serviceUrlLength, serviceUrl);

            Errors.ThrowOnErrorCode(hr);

            return new Uri(serviceUrl.ToString());
        }
        public void FindMetaEA_WithoutVersion_FoundVersion_ExcMessage()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile
            };

            var mock = new Mock<IServiceLocationDatamapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile))
                .Throws(new VersionedRecordFoundException(
                    "The location service found has a version, so specify the version"));
            var target = new ServiceLocatorService(mock.Object);

            try
            {
                // Act
                var result = target.FindMetadataEndpointAddress(serviceLocation);
                Assert.Fail();
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Count);
                Assert.AreEqual("The location service found has a version, so specify the version", ex.Detail.Details[0].Message);
            }
        }
예제 #46
0
        private async Task<List<ServiceLocation>> DiscoverClusterServices()
        {
            var services = new List<ServiceLocation>();
            var applications = await fabClient.QueryManager.GetApplicationListAsync();
            foreach (var application in applications)
            {
                foreach (var service in await fabClient.QueryManager.GetServiceListAsync(application.ApplicationName))
                {
                    var serviceLocation = new ServiceLocation(application, service);
                    var serviceHealthResponse = await fabClient
                                            .HealthManager
                                            .GetServiceHealthAsync(serviceLocation.FabricAddress);

                    serviceLocation.ServiceHealth = serviceHealthResponse.AggregatedHealthState.ToString();

                    services.Add(serviceLocation);
                }
            }
            return services;
        }
        /// <summary>
        /// A method used to get the target service url by specified service location.
        /// </summary>
        /// <param name="serviceLocation">A parameter represents the service location where host the MS-COPYS service.</param>
        /// <returns>A return value represents the service URL.</returns>
        private string GetTargetServiceUrl(ServiceLocation serviceLocation)
        {
            string targetServiceUrl;
            switch (serviceLocation)
            {
                case ServiceLocation.SourceSUT:
                    {
                        targetServiceUrl = Common.GetConfigurationPropertyValue("TargetServiceUrlOfSourceSUT", this.Site);
                        break;
                    }

                case ServiceLocation.DestinationSUT:
                    {
                        targetServiceUrl = Common.GetConfigurationPropertyValue("TargetServiceUrlOfDestinationSUT", this.Site);
                        break;
                    }

                default:
                    {
                        throw new InvalidOperationException("The test suite only support [SourceSUT] and [DestinationSUT] types ServiceLocation.");
                    }
            }

            return targetServiceUrl;
        }
예제 #48
0
        public void FindMetaEA_NoName()
        {
            // Arrange
            string name = null;
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDatamapper>();
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
예제 #49
0
        public async Task<string> ResolveEndpoint(HttpContext request)
        {
            //Parse the request to get service location
            var targetServiceLocation = new ServiceLocation(request);

            ThrowIfServiceNotPresent(targetServiceLocation.FabricAddress.ToString());

            var possibleEndpoints = await GetEndpointModel(targetServiceLocation.FabricAddress.ToString());

            return possibleEndpoints.InternalEndpointRandom;
        }
예제 #50
0
        /// <summary>
        /// GetFakeServiceLocation - return fake ServiceLocation
        /// </summary>
        /// <param name="expectedFacilityAddress"></param>
        /// <param name="localServicePathList"></param>
        /// <param name="subscriberID"></param>
        /// <returns></returns>
        public ServiceLocation GetFakeServiceLocation(FacilityAddress expectedFacilityAddress, List<ServicePath> localServicePathList, string subscriberID)
        {
            var expectedServiceLocation = new ServiceLocation
            {
                Address = expectedFacilityAddress,
                TN = "1231231234",
                PlantStatus = "C",
                ProvisionedDataSpeed = "Parent_ProvisionedSpeed",
                MaxAttainableSpeed = "CopperFacilityData_MaxAttainableSpeed",
                ServicePathList = localServicePathList,
                AssociatedSubscriberId = subscriberID,
                LocationId = string.Empty
            };

            return expectedServiceLocation;
        }