示例#1
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            FssJwtToken = await authTokenProvider.GetFssToken();

            DataHelper   = new DataHelper();
            ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl);
            ScsJwtToken  = await authTokenProvider.GetScsToken();

            ProductVersionData = new List <ProductVersionModel>();
            ////Invalid Edition Number
            ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416040", 11, 1));
            ApiEssResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken : EssJwtToken);

            //Get the BatchId
            var batchId = await ApiEssResponse.GetBatchId();

            CleanUpBatchIdList.Add(batchId);
            DownloadedFolderPath = await FileContentHelper.CreateExchangeSetFile(ApiEssResponse, FssJwtToken);
        }
示例#2
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient   = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient           = new FssApiClient();
            ProductIdentifierModel = new ProductIdentifierModel();
            DataHelper             = new DataHelper();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            FssJwtToken = await authTokenProvider.GetFssToken();
        }
示例#3
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            EssJwtTokenNoRole = await authTokenProvider.GetEssTokenNoAuth();

            EssJwtCustomizedToken = authTokenProvider.GenerateCustomToken();
            FssJwtToken           = await authTokenProvider.GetFssToken();
        }
示例#4
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider         authTokenProvider    = new AuthTokenProvider();
            AzureB2CAuthTokenProvider b2cAuthTokenProvider = new AzureB2CAuthTokenProvider();

            EssB2CToken = await b2cAuthTokenProvider.GetToken();

            FssJwtToken = await authTokenProvider.GetFssToken();

            EssB2CCustomizedToken = b2cAuthTokenProvider.GenerateCustomToken();
            DataHelper            = new DataHelper();
        }
示例#5
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            FssJwtToken = await authTokenProvider.GetFssToken();

            DataHelper   = new DataHelper();
            ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl);
            ScsJwtToken  = await authTokenProvider.GetScsToken();
        }
示例#6
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            FssJwtToken = await authTokenProvider.GetFssToken();

            DataHelper = new DataHelper();

            var ApiEssResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(new List <string>() { "DE260001" }, accessToken : EssJwtToken);

            Assert.AreEqual(200, (int)ApiEssResponse.StatusCode, $"Incorrect status code is returned {ApiEssResponse.StatusCode}, instead of the expected status 200.");
        }
        protected HttpClient CreateHttpClient()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:62598/api/")
            };

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept
            .Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var authToken = AuthTokenProvider?.ProvideAuthToken();

            if (!authToken.IsNullOrEmpty())
            {
                client.DefaultRequestHeaders.Authorization =
                    AuthenticationHeaderValue.Parse(authToken);
            }

            return(client);
        }
        /// <inheritdoc />
        public async Task OnGameInitialized()
        {
            //We need to connect the hub to the social backend
            ResolveServiceEndpointResponse endpointResponse = await ServiceDiscoveryService.DiscoverService(new ResolveServiceEndpointRequest(ClientRegionLocale.US, "SocialService"))
                                                              .ConfigureAwait(false);

            if (!endpointResponse.isSuccessful)
            {
                throw new InvalidOperationException($"Failed to query for SocialService. Reason: {endpointResponse.ResultCode}");
            }

            string hubConnectionString = $@"{endpointResponse.Endpoint.EndpointAddress}:{endpointResponse.Endpoint.EndpointPort}/realtime/textchat";

            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"Social HubConnection String: {hubConnectionString}");
            }

            //TODO: Handle failed service disc query
            HubConnection connection = new HubConnectionBuilder()
                                       .WithUrl(hubConnectionString, options =>
            {
                options.Headers.Add(SocialNetworkConstants.CharacterIdRequestHeaderName, PlayerDetails.LocalPlayerGuid.EntityId.ToString());
                options.AccessTokenProvider = () => Task.FromResult(AuthTokenProvider.Retrieve());
            })
                                       .AddJsonProtocol()
                                       .Build();

            foreach (var i in InitializableSocialServices)
            {
                i.Connection = connection;
            }

            //Just start the service when the game initializes
            //This will make it so that the signalR clients will start to recieve messages.
            await connection.StartAsync()
            .ConfigureAwait(false);
        }
示例#9
0
        public async Task SetupAsync()
        {
            Config = new TestConfiguration();
            ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress);
            FssApiClient         = new FssApiClient();
            AuthTokenProvider authTokenProvider = new AuthTokenProvider();

            EssJwtToken = await authTokenProvider.GetEssToken();

            FssJwtToken = await authTokenProvider.GetFssToken();

            DataHelper   = new DataHelper();
            ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl);
            ScsJwtToken  = await authTokenProvider.GetScsToken();

            ApiEssResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetProductIdentifiers(), accessToken : EssJwtToken);

            //Get the BatchId
            var batchId = await ApiEssResponse.GetBatchId();

            CleanUpBatchIdList.Add(batchId);
            DownloadedFolderPath = await FileContentHelper.CreateExchangeSetFile(ApiEssResponse, FssJwtToken);
        }
示例#10
0
        protected override void OnLocalPlayerSpawned(LocalPlayerSpawnedEventArgs args)
        {
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    //We need to connect the hub to the social backend
                    ResolveServiceEndpointResponse endpointResponse = await ServiceDiscoveryService.DiscoverService(new ResolveServiceEndpointRequest(ClientRegionLocale.US, GladMMONetworkConstants.SOCIAL_SERVICE_NAME))
                                                                      .ConfigureAwaitFalse();

                    if (!endpointResponse.isSuccessful)
                    {
                        throw new InvalidOperationException($"Failed to query for SocialService. Reason: {endpointResponse.ResultCode}");
                    }

                    string hubConnectionString = $@"{endpointResponse.Endpoint.EndpointAddress}:{endpointResponse.Endpoint.EndpointPort}/realtime/social";

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"Social HubConnection String: {hubConnectionString}");
                    }

                    //TODO: Handle failed service disc query
                    HubConnection connection = new HubConnectionBuilder()
                                               .WithUrl(hubConnectionString, options =>
                    {
                        options.Headers.Add(SocialNetworkConstants.CharacterIdRequestHeaderName, PlayerDetails.LocalPlayerGuid.EntityId.ToString());
                        options.AccessTokenProvider = () => Task.FromResult(AuthTokenProvider.Retrieve());
                    })
                                               .AddJsonProtocol()
                                               .Build();

                    //Register the reciever interface instance for the Connection Hub
                    connection.RegisterClientInterface <IRemoteSocialHubClient>(RemoteSocialClient);

                    foreach (var initable in ConnectionHubInitializable)
                    {
                        initable.Connection = connection;
                    }

                    //Just start the service when the game initializes
                    //This will make it so that the signalR clients will start to recieve messages.
                    await connection.StartAsync()
                    .ConfigureAwaitFalseVoid();

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"Connected to realtime Social Service.");
                    }

                    OnRealtimeSocialServiceConnected?.Invoke(this, EventArgs.Empty);
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to connect to Social Service: {e.ToString()}");
                    }

                    throw;
                }
            });
        }
示例#11
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            ProxiedHttpMethod method;

            switch (request.Method.Method)
            {
            case "POST":
                method = ProxiedHttpMethod.Post;
                break;

            case "PUT":
                method = ProxiedHttpMethod.Put;
                break;

            case "PATCH":
                method = ProxiedHttpMethod.Patch;
                break;

            default:
                throw new InvalidOperationException($"Cannot handle MethodType: {request.Method.Method}");
            }

            ProxiedHttpRequestModel proxiedRequestModel = new ProxiedHttpRequestModel(method, await request.Content.ReadAsStringAsync(), $"{AuthTokenProvider.RetrieveType()} {AuthTokenProvider.Retrieve()}", request.RequestUri.AbsolutePath);

            try
            {
                await AzureServiceBusClient.SendAsync(new Message(UTF8Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(proxiedRequestModel))));
            }
            catch (Exception e)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error($"Failed to send proxied Azure Service Bus HTTP Message. Reason: {e.ToString()}");
                }

                return(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent($"Client Exception: {e.ToString()}")
                });
            }

            //Indicate accepted since it's not technically handled.
            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }