public void Part2_Input_111122_ShouldBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

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

            // Assert
            Assert.True(result);
        }
        public void Part2_Input_123444_ShouldNotBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

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

            // Assert
            Assert.False(result);
        }
        public void Part1_Input_223450_ShouldNotBeValid()
        {
            // Arrange
            var subject = new SecureContainer();

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

            // Assert
            Assert.False(result);
        }
        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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
        public void PasswordDoesNotHaveOnlyTwoAdjacentDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsFalse(secureContainer.IsValid(password, maxTwoAdjacent: true));
        }
        public void PasswordHasOnlyTwoAdjacentDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsTrue(secureContainer.IsValid(password, maxTwoAdjacent: true));
        }
        public void PasswordDecreases(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsFalse(secureContainer.IsValid(password, maxTwoAdjacent: false));
        }
        public void PasswordIsSixDigits(int password)
        {
            var secureContainer = new SecureContainer();

            Assert.IsTrue(secureContainer.IsValid(password, maxTwoAdjacent: false));
        }
Exemplo n.º 12
0
        public void NotPartOfGroup(int value, bool expected)
        {
            var actual = SecureContainer.NotPartOfGroup(value);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 13
0
        public void NeverDecrease(int value, bool expected)
        {
            var actual = SecureContainer.NeverDecrease(value);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 14
0
        public void TwoAdjacentDigits(int value, bool expected)
        {
            var actual = SecureContainer.HasTwoAdjacentDigits(value);

            Assert.Equal(expected, actual);
        }
 public VenusFuelContainer()
 {
     _secureContainer = new SecureContainer();
 }