Exemple #1
0
        public static void BaseScore_correctly_calculated(NvdData nvdData)
        {
            // Arrange
            CvssV2BaseScore cvssV2BaseScore = CvssV2BaseScore.FromVectorString(nvdData.CvssV2VectorString);

            // Act
            var score = cvssV2BaseScore.Score;

            // Assert
            Assert.Equal(double.Parse(nvdData.CvssV2BaseScore), score);
        }
Exemple #2
0
        public static void FromVectorString_sets_Authentication(NvdData nvdData)
        {
            // Arrange
            CvssV2BaseScore cvssV2BaseScore;

            // Act
            cvssV2BaseScore = CvssV2BaseScore.FromVectorString(nvdData.CvssV2VectorString);

            // Assert
            Assert.Equal(nvdData.CvssV2Authentication, cvssV2BaseScore.Authentication.ToString().ToUpperInvariant());
        }
Exemple #3
0
        public static void FromVectorString_sets_AvailabilityImpact(NvdData nvdData)
        {
            // Arrange
            CvssV2BaseScore cvssV2BaseScore;

            // Act
            cvssV2BaseScore = CvssV2BaseScore.FromVectorString(nvdData.CvssV2VectorString);

            // Assert
            Assert.Equal(nvdData.CvssV2AvailabilityImpact, cvssV2BaseScore.AvailabilityImpact.ToString().ToUpperInvariant());
        }
Exemple #4
0
        public static void FromVectorString_sets_AccessComplexity(NvdData nvdData)
        {
            // Arrange
            CvssV2BaseScore cvssV2BaseScore;

            // Act
            cvssV2BaseScore = CvssV2BaseScore.FromVectorString(nvdData.CvssV2VectorString);

            // Assert
            Assert.Equal(nvdData.CvssV2AccessComplexity, cvssV2BaseScore.AccessComplexity.ToString().ToUpperInvariant());
        }
Exemple #5
0
        public static void ToVectorString_matches(NvdData nvdData)
        {
            // Arrange
            CvssV2BaseScore cvssV2BaseScore = CvssV2BaseScore.FromVectorString(nvdData.CvssV2VectorString);

            // Act
            var vectorString = cvssV2BaseScore.ToVectorString();

            // Assert
            Assert.Equal(nvdData.CvssV2VectorString, vectorString);
        }
Exemple #6
0
        public static void FromVectorString_throws_if_whitespace()
        {
            // Arrange
            Exception exception;

            // Act
            exception = Record.Exception(() => CvssV2BaseScore.FromVectorString("   "));

            // Assert
            Assert.NotNull(exception);
            Assert.IsType <ArgumentException>(exception);
        }
Exemple #7
0
        public static void FromVectorString_throws_if_does_contain_all_required_metrics(string vectorString)
        {
            // Arrange
            Exception exception;

            // Act
            exception = Record.Exception(() => CvssV2BaseScore.FromVectorString(vectorString));

            // Assert
            Assert.NotNull(exception);
            Assert.IsType <ArgumentException>(exception);
        }
Exemple #8
0
        public static void BaseScore_returns_minus_one_when_missing_required_metric(string propertyName)
        {
            // Arrange
            CvssV2BaseScore cvssV3BaseScore = CvssV2BaseScore.FromVectorString("(AV:N/AC:L/Au:N/C:N/I:P/A:P)");
            var             propertyInfo    = cvssV3BaseScore.GetType().GetProperty(propertyName);

            propertyInfo.SetValue(cvssV3BaseScore, null);

            // Act
            var score = cvssV3BaseScore.Score;

            // Assert
            Assert.Equal(-1.0, score);
        }