Ejemplo n.º 1
0
            public void Should_Use_Default_Tool_Path_If_None_Is_Specified()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/tools/signtool.exe", result.Path.FullPath);
            }
Ejemplo n.º 2
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /t \"https://t.com/\" /f \"/Working/cert.pfx\" /p secret \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 3
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run("./a.dll", null));

                // Then
                Assert.IsArgumentNullException(result, "settings");
            }
Ejemplo n.º 4
0
            public void Should_Throw_If_Assembly_Path_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(null, new SignToolSignSettings()));

                // Then
                Assert.IsArgumentNullException(result, "assemblyPath");
            }
Ejemplo n.º 5
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_RFC6131_Timestamp_Uri_And_Sha256_Timestamp_Algorithm()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.TimeStampDigestAlgorithm = SignToolDigestAlgorithm.Sha256;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /tr \"https://t.com/\" /td sha256 /f \"/Working/cert.pfx\" /p secret \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 6
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_CertPath_And_No_Password()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.Password = null;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /t \"https://t.com/\" /f \"/Working/cert.pfx\" \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 7
0
            public void Should_Not_Throw_If_Password_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.Password = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.Null(result);
            }
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Store_Name()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.StoreName = "Special Test Store";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /s \"Special Test Store\" \"/Working/a.dll\"", result.Args);
            }
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Use_Machine_Store()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.UseMachineStore = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /sm \"/Working/a.dll\"", result.Args);
            }
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Sha256_Digest_Algorithm()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.DigestAlgorithm = SignToolDigestAlgorithm.Sha256;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /fd sha256 /f \"/Working/cert.pfx\" /p secret \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 11
0
            public void Should_Throw_If_Environment_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Environment = null;

                // When
                var result = Record.Exception(() => fixture.CreateRunner());

                // Then
                Assert.IsArgumentNullException(result, "environment");
            }
Ejemplo n.º 12
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_DescriptionUri()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.DescriptionUri = new Uri("https://example.com");

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /t \"https://t.com/\" /f \"/Working/cert.pfx\" /p secret /du \"https://example.com/\" \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 13
0
            public void Should_Use_Default_Tool_Path_If_None_Is_Specified()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                // When
                fixture.RunTool();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(p => p.FullPath == "/Working/Default/tool.exe"),
                    Arg.Any <ProcessSettings>());
            }
Ejemplo n.º 14
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                // When
                fixture.RunTool();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(), Arg.Is <ProcessSettings>(p =>
                                                                   p.Arguments.Render() == "SIGN /t \"https://t.com/\" /f \"/Working/cert.pfx\" /p secret \"/Working/a.dll\""));
            }
Ejemplo n.º 15
0
            public void Should_Throw_If_File_System_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.FileSystem = null;

                // When
                var result = Record.Exception(() => fixture.CreateRunner());

                // Then
                Assert.IsArgumentNullException(result, "fileSystem");
            }
Ejemplo n.º 16
0
            public void Should_Throw_If_Assembly_Path_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.AssemblyPath = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "assemblyPath");
            }
Ejemplo n.º 17
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "settings");
            }
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Description()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.Description = "DescriptionTest";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /d \"DescriptionTest\" \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 19
0
            public void Should_Throw_If_Process_Runner_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.ProcessRunner = null;

                // When
                var result = Record.Exception(() => fixture.CreateRunner());

                // Then
                Assert.IsArgumentNullException(result, "processRunner");
            }
Ejemplo n.º 20
0
            public void Should_Use_Provided_Tool_Path_If_Specified()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.ToolPath = "/Working/other/signtool.exe";
                fixture.GivenSettingsToolPathExist();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/other/signtool.exe", result.Path.FullPath);
            }
Ejemplo n.º 21
0
            public void Should_Throw_If_Password_Is_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.Password = null;

                // When
                var result = Record.Exception(() => fixture.RunTool());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: Password is required but not specified.", result.Message);
            }
Ejemplo n.º 22
0
            public void Should_Throw_If_No_Timestamp_Server_URL_Has_Been_Specified()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.TimeStampUri = null;

                // When
                var result = Record.Exception(() => fixture.RunTool());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: Timestamp server URL is required but not specified.", result.Message);
            }
Ejemplo n.º 23
0
            public void Should_Throw_If_Assembly_Do_Not_Exist()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.FileSystem.GetFile("/Working/a.dll").Delete();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: The assembly '/Working/a.dll' does not exist.", result?.Message);
            }
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Additional_Cert()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.FileSystem.CreateFile("/Working/ac.cer");
                fixture.Settings.AdditionalCertPath = "/Working/ac.cer";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /ac \"/Working/ac.cer\" \"/Working/a.dll\"", result.Args);
            }
Ejemplo n.º 25
0
            public void Should_Throw_If_Certificate_File_Do_Not_Exist()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.FileSystem.GetFile("/Working/cert.pfx").Delete();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: The certificate '/Working/cert.pfx' do not exist.", result.Message);
            }
Ejemplo n.º 26
0
            public void Should_Throw_If_Certificate_Path_And_Thumbprint_Are_Both_Specified()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.CertThumbprint = "123";

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: Certificate path and Certificate thumbprint cannot be specified together.", result?.Message);
            }
Ejemplo n.º 27
0
            public void Should_Throw_If_Assembly_Do_Not_Exist()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.AssemblyFile.Exists.Returns(false);

                // When
                var result = Record.Exception(() => fixture.RunTool());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: The assembly '/Working/a.dll' do not exist.", result.Message);
            }
            public void Should_Throw_If_Additional_Certificate_File_Does_Not_Exist()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.AdditionalCertPath = "/Working/ac.cer";

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: The additional certificate '/Working/ac.cer' does not exist.", result?.Message);
            }
Ejemplo n.º 29
0
            public void Should_Throw_If_Certificate_Path_And_Thumbprint_Are_Null()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.CertPath       = null;
                fixture.Settings.CertThumbprint = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SignTool SIGN: One of Certificate path or Certificate thumbprint is required but neither are specified.", result?.Message);
            }
Ejemplo n.º 30
0
            public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Thumbprint()
            {
                // Given
                var fixture = new SignToolSignRunnerFixture();

                fixture.Settings.CertPath       = null;
                fixture.Settings.Password       = null;
                fixture.Settings.CertThumbprint = "ThumbprintTest";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("SIGN /t \"https://t.com/\" /sha1 \"ThumbprintTest\" \"/Working/a.dll\"", result.Args);
            }