コード例 #1
0
        public void Part2_Input_111122_ShouldBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

            // Act
            var result = subject.IsValidPart2("111122");

            // Assert
            Assert.True(result);
        }
コード例 #2
0
        public void Part2_Input_123444_ShouldNotBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

            // Act
            var result = subject.IsValidPart2("123444");

            // Assert
            Assert.False(result);
        }
コード例 #3
0
        public void Part1_Input_223450_ShouldNotBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

            // Act
            var result = subject.IsValidPart1("223450");

            // Assert
            Assert.False(result);
        }
コード例 #4
0
        public async Task Part1_ConcrateExcerciseRetro()
        {
            // Arrange
            string input   = "128392-643281";
            var    subject = new SecureContainer();

            // Act
            var result = await subject.SolvePart1Async(input.ToMemoryStream());

            // Assert
            Assert.Equal(2050.ToString(), result);
        }
コード例 #5
0
        /// <summary>Erstellt eine neue Updatekonfiguration mit den aktuellen Daten aus dem Projekt.</summary>
        protected byte[] buildConfiguration()
        {
            var configuration = new updateConfiguration {
                projectId       = Session.currentProject.projectId,
                PublicKey       = Session.currentProject.keyPair.publicKey,
                applicationName = Session.currentProject.projectName
            };

            if (Session.currentProject.updateLogEnabled && Session.currentProject.updateLogUser.Verified)
            {
                configuration.linkedUpdateLogAccount = new updateLogLinkedAccount
                {
                    serverUrl = Session.currentProject.updateLogUser.serverUrl
                }
            }
            ;
            else
            {
                configuration.linkedUpdateLogAccount = null;
            }

            configuration.generateNativeImages  = Session.currentProject.generateNativeImages;
            configuration.startParameterSuccess = Session.currentProject.updateParameterSuccess;
            configuration.startParameterFailed  = Session.currentProject.updateParameterFailed;
            configuration.setupId = Session.currentProject.updateSetupId;

            //Updatepakete hinzufügen
            foreach (var package in updatePackages)
            {
                configuration.updatePackages.Add(package);
            }

            //Konfiguration signieren und speichern
            var configurationContainer = new SecureContainer {
                Content = Serializer.Serialize(configuration)
            };

            configurationContainer.Signature = RSA.Sign(configurationContainer.Content, Session.currentProject.keyPair.privateKey);
            return(configurationContainer.Save());
        }
コード例 #6
0
        private void downloadConfig()
        {
            //Updatekonfiguration herunterladen
            byte[] rawUpdateConfiguration =
                webclient.DownloadData(internalHelper.prepareUpdateLocation(_controllerInstance.updateLocation) + "update.xml");
            var sContainer = new SecureContainer();

            sContainer.Load(rawUpdateConfiguration);
            currentConfiguration = Serializer.Deserialize(sContainer.Content);

            //Signatur der Updatekonfiguration überprüfen

            /*string publicKey = (string.IsNullOrEmpty(_controllerInstance.publicKey) ? currentConfiguration.PublicKey : _controllerInstance.publicKey);
             * if (!Core.RSA.validateSign(sContainer.Content, sContainer.Signature, publicKey))
             *      throw new Exception(Language.GetString("searchProvider_invalidSignatureException"));*/

            //Sende Statistiken über die Updateanfrage
            var log = new updateLogRequest(_controllerInstance, currentConfiguration);

            lock (log)
                log.sendRequest(0);
        }
コード例 #7
0
        private updateConfiguration downloadConfiguration(string updateUrl)
        {
            string completeUrl = updateUrl;

            //Fix missing Url parts
            if (!completeUrl.EndsWith("/"))
            {
                completeUrl = completeUrl + "/";
            }
            completeUrl = completeUrl + "update.xml";

            //Download Configuration
            var client = Session.createWebClient();

            byte[] configurationData = client.DownloadData(completeUrl);

            var container = new SecureContainer();

            container.Load(configurationData);

            //Deserialize and Load Configuration
            return(updateSystemDotNet.Core.Serializer.Deserialize(container.Content));
        }
コード例 #8
0
        public void PasswordDoesNotHaveOnlyTwoAdjacentDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsFalse(secureContainer.IsValid(password, maxTwoAdjacent: true));
        }
コード例 #9
0
        public void PasswordHasOnlyTwoAdjacentDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsTrue(secureContainer.IsValid(password, maxTwoAdjacent: true));
        }
コード例 #10
0
        public void PasswordDecreases(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsFalse(secureContainer.IsValid(password, maxTwoAdjacent: false));
        }
コード例 #11
0
        public void PasswordIsSixDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsTrue(secureContainer.IsValid(password, maxTwoAdjacent: false));
        }
コード例 #12
0
        public void NotPartOfGroup(int value, bool expected)
        {
            var actual = SecureContainer.NotPartOfGroup(value);

            Assert.Equal(expected, actual);
        }
コード例 #13
0
        public void NeverDecrease(int value, bool expected)
        {
            var actual = SecureContainer.NeverDecrease(value);

            Assert.Equal(expected, actual);
        }
コード例 #14
0
        public void TwoAdjacentDigits(int value, bool expected)
        {
            var actual = SecureContainer.HasTwoAdjacentDigits(value);

            Assert.Equal(expected, actual);
        }
コード例 #15
0
 public VenusFuelContainer()
 {
     _secureContainer = new SecureContainer();
 }