예제 #1
0
        public void Patching_Builder_Installer_WrongReleaseDate()
        {
            var builder = new PatchBuilder(new TestComponent());

            try
            {
                // ACTION-1
                builder.Install("1.0", null, "MyComp desc");
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-1
                Assert.AreEqual(PatchErrorCode.InvalidDate, e.ErrorCode);
                Assert.AreEqual("MyComp: 1.0", e.Patch.ToString());
            }

            try
            {
                // ACTION-2
                builder.Install("1.0", "wrong", "MyComp desc");
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-2
                Assert.AreEqual(PatchErrorCode.InvalidDate, e.ErrorCode);
                Assert.AreEqual("MyComp: 1.0", e.Patch.ToString());
            }
        }
예제 #2
0
        public void Patching_Builder_Installer_WrongDescription()
        {
            var builder = new PatchBuilder(new TestComponent());

            try
            {
                // ACTION-1
                builder.Install("1.0", "2020-10-20", null);
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-1
                Assert.AreEqual(PatchErrorCode.MissingDescription, e.ErrorCode);
                Assert.AreEqual("MyComp: 1.0", e.Patch.ToString());
            }

            try
            {
                // ACTION-2
                builder.Install("1.0", "2020-10-20", string.Empty);
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-2
                Assert.AreEqual(PatchErrorCode.MissingDescription, e.ErrorCode);
                Assert.AreEqual("MyComp: 1.0", e.Patch.ToString());
            }
        }
예제 #3
0
        public void Patching_Builder_Installer_WrongVersion()
        {
            var builder = new PatchBuilder(new TestComponent());

            try
            {
                // ACTION-1
                builder.Install(null, "2020-10-20", "MyComp desc");
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-1
                Assert.AreEqual(PatchErrorCode.InvalidVersion, e.ErrorCode);
                Assert.AreEqual("MyComp: 0.0", e.Patch.ToString());
            }

            try
            {
                // ACTION-2
                builder.Install("wrong.wrong", "2020-10-20", "MyComp desc");
                Assert.Fail();
            }
            catch (InvalidPatchException e)
            {
                // ASSERT-2
                Assert.AreEqual(PatchErrorCode.InvalidVersion, e.ErrorCode);
                Assert.AreEqual("MyComp: 0.0", e.Patch.ToString());
            }
        }
예제 #4
0
        public override void AddPatches(PatchBuilder builder)
        {
            builder.Install("1.0.0", "2020-06-22", "MS SQL data provider extension for the statistical data handling feature.")
            .DependsOn("SenseNet.Services", "7.7.22")
            .ActionOnBefore(context =>
            {
                var dataStore = Providers.Instance.DataStore;
                if (!(dataStore.DataProvider is RelationalDataProviderBase dataProvider))
                {
                    throw new InvalidOperationException("Cannot install MsSqlStatisticsComponent because it is " +
                                                        $"incompatible with Data provider {dataStore.DataProvider.GetType().FullName}.");
                }


                try
                {
                    using var ctx = dataProvider.CreateDataContext(CancellationToken.None);
                    ctx.ExecuteNonQueryAsync(MsSqlStatisticalDataProvider.CreationScript).GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    context.Log($"Error during installation of MsSqlStatisticsComponent: {ex.Message}");
                    throw;
                }
            });
        }
예제 #5
0
        public void Patching_Builder_Installer_Minimal()
        {
            var builder = new PatchBuilder(new TestComponent());

            // ACTION
            builder.Install("1.0", "2020-10-20", "MyComp desc").Action();

            // ASSERT
            Assert.AreEqual("MyComp: 1.0", PatchesToString(builder));
            var installer = builder.GetPatches()[0] as ComponentInstaller;

            Assert.IsNotNull(installer);
            Assert.IsNull(installer.Dependencies);
            Assert.IsNull(installer.Action);

            // MORE TESTS
            // version: "v1.0"
            builder = new PatchBuilder(new TestComponent());
            builder.Install("v1.0", "2020-10-20", "MyComp desc").Action();
            Assert.AreEqual("MyComp: 1.0", PatchesToString(builder));
            // version: "V1.0"
            builder = new PatchBuilder(new TestComponent());
            builder.Install("V1.0", "2020-10-20", "MyComp desc").Action();
            Assert.AreEqual("MyComp: 1.0", PatchesToString(builder));
        }
        public override void AddPatches(PatchBuilder builder)
        {
            builder.Install("1.0.0", "2021-09-27", "MS SQL implementation of Client store.")
            .DependsOn("SenseNet.Services", "7.7.23")
            .ActionOnBefore(context =>
            {
                if (!(Providers.Instance.DataProvider is RelationalDataProviderBase dataProvider))
                {
                    throw new InvalidOperationException("Cannot install MsSqlClientStoreComponent because it is " +
                                                        $"incompatible with Data provider {Providers.Instance.DataProvider.GetType().FullName}.");
                }

                try
                {
                    using var ctx = dataProvider.CreateDataContext(CancellationToken.None);
                    ctx.ExecuteNonQueryAsync(MsSqlClientStoreDataProviderExtension.DropAndCreateTablesSql)
                    .GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    context.Log($"Error during installation of MsSqlClientStore: {ex.Message}");
                    throw;
                }
            })
            .Action(context =>
            {
                // generate default clients and secrets
                var clientStore   = context.GetService <ClientStore>();
                var clientOptions = context.GetService <IOptions <ClientStoreOptions> >().Value;

                clientStore.EnsureClientsAsync(clientOptions.Authority, clientOptions.RepositoryUrl.RemoveUrlSchema()).GetAwaiter().GetResult();
            });
        }
예제 #7
0
        public void Patching_Builder_HighInstallerLowerPatches()
        {
            var builder = new PatchBuilder(new TestComponent());

            // ACTION
            builder
            .Install("3.0", "2020-10-20", "desc").Action()
            .Patch("1.0", "2.0", "2020-10-20", "desc").Action()
            .Patch("2.0", "3.0", "2020-10-21", "desc").Action();

            // ASSERT
            Assert.AreEqual("MyComp: 3.0 | MyComp: 1.0 <= v < 2.0 --> 2.0 | MyComp: 2.0 <= v < 3.0 --> 3.0",
                            PatchesToString(builder));
        }
예제 #8
0
        public void Patching_Builder_Installer_BeforeAfter()
        {
            var builder = new PatchBuilder(new TestComponent());

            // ACTION
            builder.Install("1.0", "2020-10-20", "MyComp desc")
            .ActionOnBefore().Action();

            // ASSERT
            var installers = builder.GetPatches()
                             .Select(x => (ComponentInstaller)x).ToArray();

            Assert.IsNull(installers[0].ActionBeforeStart);
            Assert.IsNull(installers[0].Action);
        }
예제 #9
0
        public override void AddPatches(PatchBuilder builder)
        {
            var dependencies = new DependencyBuilder(builder)
                               .Dependency("SenseNet.Services", "7.7.9");

            builder.Patch("1.0", "1.1", "2020-02-10", "Feature1's PATCH to v1.1 description")
            .DependsOn(dependencies)
            .Action(context =>
            {
                var oldFolderName = "GyebiTesztel_v1.0";
                var newFolderName = "GyebiTesztel_v1.1";
                var newContent    = Content.Load($"/Root/{newFolderName}");
                if (newContent != null)
                {
                    return;
                }
                var oldContent = Content.Load($"/Root/{oldFolderName}");
                if (oldContent != null)
                {
                    oldContent.ContentHandler.Name = newFolderName;
                    oldContent.Save();
                }
                else
                {
                    var parent = Node.LoadNode("/Root");
                    newContent = Content.CreateNew("SystemFolder", parent, newFolderName);
                    newContent.Save();
                }
            });

            builder.Install("1.1", "2020-02-10", "My feature Feature1 description")
            .DependsOn(dependencies)
            .Action((context) =>
            {
                var folderName = "GyebiTesztel_v1.1";
                var content    = Content.Load($"/Root/{folderName}");
                if (content == null)
                {
                    var parent = Node.LoadNode("/Root");
                    content    = Content.CreateNew("SystemFolder", parent, folderName);
                    content.Save();
                }
            });
        }
        public override void AddPatches(PatchBuilder builder)
        {
            builder.Install("1.0.0", "2020-10-15", "MS SQL data provider extension for the Exclusive lock feature.")
            .ActionOnBefore(context =>
            {
                if (!(DataStore.DataProvider is RelationalDataProviderBase dataProvider))
                {
                    throw new InvalidOperationException("Cannot install MsSqlExclusiveLockComponent because it is " +
                                                        $"incompatible with Data provider {DataStore.DataProvider.GetType().FullName}.");
                }


                try
                {
                    using var ctx = dataProvider.CreateDataContext(CancellationToken.None);
                    ctx.ExecuteNonQueryAsync(MsSqlExclusiveLockDataProvider.CreationScript).GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    context.Log($"Error during installation of MsSqlExclusiveLockComponent: {ex.Message}");
                    throw;
                }
            });
        }
예제 #11
0
        public override void AddPatches(PatchBuilder builder)
        {
            builder
            .Install("0.0.4", "2021-06-09", "sensenet WebHooks")
            .DependsOn("SenseNet.Services", "7.7.22")
            .Action(context =>
            {
                #region String resource

                InstallStringResource("CtdResourcesWebHookSubscription.xml");

                #endregion

                #region Install CTD

                InstallCtd("WebHookSubscriptionCtd.xml");

                #endregion

                #region Content items

                CreateWebHooksContainer();

                #endregion
            });

            builder.Patch("0.0.1", "0.0.3", "2021-03-17", "Upgrades the WebHook component")
            .DependsOn("SenseNet.Services", "7.7.19")
            .Action(context =>
            {
                #region String resources

                var rb = new ResourceBuilder();

                rb.Content("CtdResourcesWebHookSubscription.xml")
                .Class("Ctd-WebHookSubscription")
                .Culture("en")
                .AddResource("DisplayName", "Webhook")
                .Culture("hu")
                .AddResource("DisplayName", "Webhook");

                rb.Apply();

                #endregion

                #region CTD changes

                var cb = new ContentTypeBuilder(context.GetService <ILogger <ContentTypeBuilder> >());

                cb.Type("WebHookSubscription")
                .Icon("Settings")
                .Field("WebHookPayload", "LongText")
                .DisplayName("$Ctd-WebHookSubscription,WebHookPayload-DisplayName")
                .Description("$Ctd-WebHookSubscription,WebHookPayload-Description")
                .VisibleBrowse(FieldVisibility.Show)
                .VisibleEdit(FieldVisibility.Show)
                .VisibleNew(FieldVisibility.Show)
                .FieldIndex(10)
                .ControlHint("sn:WebhookPayload")
                .Field("WebHookFilter")
                .FieldIndex(50)
                .Field("WebHookHeaders")
                .FieldIndex(40)
                .Field("Enabled")
                .FieldIndex(90)
                .Field("IsValid")
                .FieldIndex(30)
                .VisibleBrowse(FieldVisibility.Hide)
                .Field("InvalidFields")
                .RemoveConfiguration("FieldIndex")
                .VisibleBrowse(FieldVisibility.Hide)
                .VisibleEdit(FieldVisibility.Hide)
                .VisibleNew(FieldVisibility.Hide)
                .Field("SuccessfulCalls")
                .FieldIndex(20)
                .Field("WebHookHttpMethod")
                .DefaultValue("POST");

                cb.Apply();

                #endregion

                #region Content items

                CreateWebHooksContainer();

                #endregion
            });

            builder.Patch("0.0.3", "0.0.4", "2021-06-09", "Upgrades the WebHook component")
            .DependsOn("SenseNet.Services", "7.7.22")
            .Action(context =>
            {
                // Do nothing, this is just a version update, because the CTD change (richtext type
                // change of the Description field) is already handled by the Services component patch.
            });
        }