Exemple #1
0
        public void UpdateServiceInstance()
        {
            UpdateServiceInstanceCommand command = new UpdateServiceInstanceCommand(new Dictionary <string, string>
            {
                { "id", ServiceInstanceID },
                { "f", @"TestFiles\fakeservice-newplan.json" }
            }, new ServiceInstanceSchemaChecker("http://localhost:8088"));

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(SuccessConclusion));

            ListEntitiesCommand <ServiceInstance> readCommand = new ListEntitiesCommand <ServiceInstance>("service-instance");

            readCommand.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var readConclusion = readCommand.Run();

            Assert.IsInstanceOfType(readConclusion, typeof(MultiOutputConclusion));
            var services = ((MultiOutputConclusion)readConclusion).GetObjectList <ServiceInstance>();

            Assert.IsNotNull(services);
            Assert.IsTrue(services.Count >= 1);
            Assert.IsNotNull(services.FirstOrDefault(s => s.ServiceId == "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66"));
            Assert.IsNotNull(services.FirstOrDefault(s => s.PlanId == "0f4008b5-XXXX-XXXX-XXXX-dace631cd648"));
            Assert.IsNotNull(services.FirstOrDefault(s => s.InstanceId == ServiceInstanceID));
        }
Exemple #2
0
        public async Task <List <Tuple <string, string> > > GetBindingCredential(string instanceId, string bindingId, string parameters, CancellationToken cancellationToken)
        {
            var state = await this.StateManager.TryGetStateAsync <MyState>(instanceId, cancellationToken);

            if (state.HasValue)
            {
                if (state.Value.Credential != null)
                {
                    return(makeTupleList(state.Value.Credential));
                }
                else
                {
                    string address = await resolveCatalogServiceAddress();

                    CreateBindingCommand command = new CreateBindingCommand(new Dictionary <string, string>
                    {
                        { "instance-id", instanceId },
                        { "id", bindingId },
                        { "f", parameters }
                    }, new ServiceInstanceSchemaChecker(address));
                    command.InjectSwitch("CatalogServiceEndpoint", address);
                    command.Run();

                    ListEntitiesCommand <BindingwithResult> listCommand = new ListEntitiesCommand <BindingwithResult>("binding");
                    listCommand.InjectSwitch("CatalogServiceEndpoint", address);
                    var conclusion = listCommand.Run();
                    var bindings   = ((MultiOutputConclusion)conclusion).GetObjectList <BindingwithResult>();
                    if (bindings.Count > 0 && bindings[0].Result != null && !string.IsNullOrEmpty(bindings[0].Result.Credentials))
                    {
                        var newState = new MyState
                        {
                            ServiceId  = state.Value.ServiceId,
                            PlanId     = state.Value.PlanId,
                            InstanceId = instanceId,
                            BindingId  = bindingId,
                            Credential = bindings[0].Result.Credentials
                        };
                        await this.StateManager.SetStateAsync <MyState>(instanceId, newState, cancellationToken);

                        return(makeTupleList(bindings[0].Result.Credentials));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public void Catalog()
        {
            ListEntitiesCommand <Service> command = new ListEntitiesCommand <Service>("service-class");

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(MultiOutputConclusion));
            var services = ((MultiOutputConclusion)conclusion).GetObjectList <Service>();

            Assert.IsNotNull(services);
            Assert.AreEqual(1, services.Count);
            Assert.AreEqual("acb56d7c-XXXX-XXXX-XXXX-feb140a59a66", services[0].Id);
        }
Exemple #4
0
        public void GetBrokers()
        {
            ListEntitiesCommand <Broker> command = new ListEntitiesCommand <Broker>("broker");

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(MultiOutputConclusion));
            var brokers = ((MultiOutputConclusion)conclusion).GetObjectList <Broker>();

            Assert.IsNotNull(brokers);
            Assert.IsTrue(brokers.Count == 1);
            Assert.AreEqual(brokers[0].Url, "http://localhost:3000");
        }
Exemple #5
0
        public void GetBinding()
        {
            ListEntitiesCommand <BindingwithResult> command = new ListEntitiesCommand <BindingwithResult>("binding");

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(MultiOutputConclusion));
            var bindings = ((MultiOutputConclusion)conclusion).GetObjectList <BindingwithResult>();

            Assert.IsNotNull(bindings);
            Assert.IsTrue(bindings.Count >= 1);
            Assert.IsNotNull(bindings.FirstOrDefault(s => s.Binding.ServiceId == "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66"));
            Assert.IsNotNull(bindings.FirstOrDefault(s => s.Binding.BindingId == BindingID));
        }
Exemple #6
0
        public void GetServiceInstances()
        {
            ListEntitiesCommand <ServiceInstance> command = new ListEntitiesCommand <ServiceInstance>("service-instance");

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(MultiOutputConclusion));
            var services = ((MultiOutputConclusion)conclusion).GetObjectList <ServiceInstance>();

            Assert.IsNotNull(services);
            Assert.IsTrue(services.Count >= 1);
            Assert.IsNotNull(services.FirstOrDefault(s => s.ServiceId == "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66"));
            Assert.IsNotNull(services.FirstOrDefault(s => s.PlanId == "d3031751-XXXX-XXXX-XXXX-a42377d3320e"));
            Assert.IsNotNull(services.FirstOrDefault(s => s.InstanceId == ServiceInstanceID));
        }
Exemple #7
0
        public async Task <BindingwithResult> GetBinding(string bindingId, CancellationToken cancellationToken)
        {
            var instanceId = await this.StateManager.GetStateAsync <string>("InstanceId", cancellationToken);

            if (string.IsNullOrEmpty(bindingId))
            {
                bindingId = Guid.NewGuid().ToString("N");
            }
            var binding = await this.StateManager.TryGetStateAsync <BindingwithResult>(bindingId, cancellationToken);

            if (binding.HasValue)
            {
                return(binding.Value);
            }
            else
            {
                CreateBindingCommand command = new CreateBindingCommand(new Dictionary <string, string>
                {
                    { "instance-id", instanceId },
                    { "id", bindingId },
                    { "f", string.Format(@"{
                            ""service_id"": ""{0}"",
                            ""plan_id"": ""{1}""
                            }", "A", "B") }
                }, new ServiceInstanceSchemaChecker("http://localhost:8088"));
                ListEntitiesCommand <BindingwithResult> listCommand = new ListEntitiesCommand <BindingwithResult>("binding");
                listCommand.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
                var conclusion = listCommand.Run();
                var bindings   = ((MultiOutputConclusion)conclusion).GetObjectList <BindingwithResult>();
                if (bindings.Count > 0)
                {
                    await this.StateManager.SetStateAsync <BindingwithResult>(bindingId, bindings[0], cancellationToken);

                    return(bindings[0]);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #8
0
        public void Deprovisioning()
        {
            DeleteServiceInstanceCommand command = new DeleteServiceInstanceCommand();

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            command.InjectSwitch("id", ServiceInstanceID);
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(SuccessConclusion));

            ListEntitiesCommand <ServiceInstance> readCommand = new ListEntitiesCommand <ServiceInstance>("service-instance");

            readCommand.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var readConclusion = readCommand.Run();

            Assert.IsInstanceOfType(readConclusion, typeof(MultiOutputConclusion));
            var services = ((MultiOutputConclusion)readConclusion).GetObjectList <ServiceInstance>();

            Assert.IsNotNull(services);
            Assert.IsNull(services.FirstOrDefault(s => s.InstanceId == ServiceInstanceID));
        }
Exemple #9
0
        public void Unbind()
        {
            DeleteBindingCommand command = new DeleteBindingCommand();

            command.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            command.InjectSwitch("id", BindingID);
            var conclusion = command.Run();

            Assert.IsInstanceOfType(conclusion, typeof(SuccessConclusion));

            ListEntitiesCommand <BindingwithResult> readCommand = new ListEntitiesCommand <BindingwithResult>("binding");

            readCommand.InjectSwitch("CatalogServiceEndpoint", "http://localhost:8088");
            var readConclusion = readCommand.Run();

            Assert.IsInstanceOfType(readConclusion, typeof(MultiOutputConclusion));
            var bindings = ((MultiOutputConclusion)readConclusion).GetObjectList <BindingwithResult>();

            Assert.IsNotNull(bindings);
            Assert.IsNull(bindings.FirstOrDefault(s => s.Binding.BindingId == BindingID));
        }
 public async Task <IEnumerable <T> > Handle(ListEntitiesCommand <T> request, CancellationToken cancellationToken)
 {
     return(await _repo.ListAsync());
 }