public async Task BindUnchanged()
        {
            var request = new ServiceBindingRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceBinding();

            SetupMock(x => x.BindAsync(new ServiceBindingContext("123", "456"), request), response);
            var result = await Client.ServiceInstancesBlocking["123"].ServiceBindings["456"].BindAsync(request);

            result.Should().BeEquivalentTo(response);
        }
        public async Task BindCompleted()
        {
            var request = new ServiceBindingRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var syntheticResponse = new ServiceBinding
            {
                RouteServiceUrl = new Uri("http://example.com")
            };
            var response = new ServiceBindingAsyncOperation().Complete(syntheticResponse);

            SetupMock(x => x.BindAsync(new ServiceBindingContext("123", "456"), request), response);
            var result = await Client.ServiceInstancesPolling["123"].ServiceBindings["456"].BindAsync(request);

            result.Should().BeEquivalentTo(syntheticResponse);
        }
Beispiel #3
0
        public async Task Bind()
        {
            var request = new ServiceBindingRequest
            {
                ServiceId    = "abc",
                PlanId       = "xyz",
                BindResource = new()
                {
                    AppGuid = "123-456"
                }
            };
            var response = new ServiceBinding();

            Mock.Setup(x => x.BindAsync(new("123", "456"), request))
            .ReturnsAsync(response);
            var result = await Client.ServiceInstancesBlocking["123"].ServiceBindings["456"].BindAsync(request);

            result.Should().BeEquivalentTo(response);
        }
        public async Task BindDeferred()
        {
            var request = new ServiceBindingRequest
            {
                ServiceId    = "abc",
                PlanId       = "xyz",
                BindResource = new()
                {
                    AppGuid = "123-456"
                }
            };
            var response = new ServiceBindingAsyncOperation
            {
                Operation = "my operation"
            };
            var operation = new LastOperationResource
            {
                State       = LastOperationResourceState.Succeeded,
                Description = "done"
            };
            var resource = new ServiceBindingResource
            {
                RouteServiceUrl = new Uri("http://example.com")
            };
            var syntheticResponse = new ServiceBinding
            {
                RouteServiceUrl = new Uri("http://example.com")
            };

            Mock.Setup(x => x.BindAsync(new("123", "456"), request))
            .ReturnsAsync(response);
            Mock.Setup(x => x.GetLastOperationAsync(new("123", "456"), "abc", "xyz", "my operation"))
            .ReturnsAsync(operation);
            Mock.Setup(x => x.FetchAsync("123", "456"))
            .ReturnsAsync(resource);
            var result = await Client.ServiceInstancesPolling["123"].ServiceBindings["456"].BindAsync(request);

            result.Should().BeEquivalentTo(syntheticResponse);
        }
Beispiel #5
0
        public async Task <ServiceBinding> BindAsync(ServiceBindingRequest request)
        {
            var response = await _inner.BindAsync(request);

            if (string.IsNullOrEmpty(response.Operation))
            {
                return(response.Result);
            }

            await LastOperationWaitAsync(request.ServiceId, request.PlanId, response.Operation);

            var resource = await FetchAsync();

            var result = new ServiceBinding
            {
                Credentials     = resource.Credentials,
                RouteServiceUrl = resource.RouteServiceUrl,
                SyslogDrainUrl  = resource.SyslogDrainUrl
            };

            result.VolumeMounts.AddRange(resource.VolumeMounts);
            return(result);
        }