public string Validate(bool?withBaseline, BaselineProvider baselineProvider, IEnumerable <Reporter> reporters)
        {
            /* the dashboard api key is required if
             * 1: The dashboard reporter is enabled
             * 2: The dasboard storage location is chosen for the with-baseline feature AND the with-baseline feature is enabled
             */
            var dashboardEnabled = (withBaseline.IsNotNullAndTrue() && baselineProvider == BaselineProvider.Dashboard) || reporters.Any(x => x == Reporter.Dashboard);

            if (!dashboardEnabled)
            {
                return(Default);
            }
            if (string.IsNullOrWhiteSpace(SuppliedInput))
            {
                var environmentApiKey = Environment.GetEnvironmentVariable("STRYKER_DASHBOARD_API_KEY");
                if (!string.IsNullOrWhiteSpace(environmentApiKey))
                {
                    return(environmentApiKey);
                }
                else
                {
                    throw new InputException($"An API key is required when the {Reporter.Dashboard} reporter is turned on! You can get an API key at {DashboardUrlInput.DefaultUrl}");
                }
            }

            return(SuppliedInput);
        }
示例#2
0
 private StrykerOptions(
     string basePath,
     string outputPath,
     IEnumerable <Reporter> reporters,
     string projectUnderTestNameFilter,
     string projectUnderTest,
     int additionalTimeoutMS,
     IEnumerable <Mutator> excludedMutations,
     IEnumerable <Regex> ignoredMethods,
     LogOptions logOptions,
     OptimizationFlags optimizations,
     Threshold thresholds,
     bool devMode,
     string optimizationMode,
     int concurrentTestRunners,
     IEnumerable <FilePattern> filePatterns,
     TestRunner testRunner,
     string solutionPath,
     LanguageVersion languageVersion,
     string gitDiffSource,
     IEnumerable <string> testProjects,
     string azureSAS,
     string azureFileStorageUrl,
     BaselineProvider baselineProvider,
     MutationLevel mutationLevel)
 {
     IgnoredMethods             = ignoredMethods;
     BasePath                   = basePath;
     OutputPath                 = outputPath;
     Reporters                  = reporters;
     ProjectUnderTestNameFilter = projectUnderTestNameFilter;
     ProjectUnderTest           = projectUnderTest;
     AdditionalTimeoutMS        = additionalTimeoutMS;
     ExcludedMutations          = excludedMutations;
     LogOptions                 = logOptions;
     DevMode = devMode;
     ConcurrentTestrunners = concurrentTestRunners;
     Thresholds            = thresholds;
     FilePatterns          = filePatterns;
     TestRunner            = testRunner;
     SolutionPath          = solutionPath;
     LanguageVersion       = languageVersion;
     OptimizationMode      = optimizationMode;
     Optimizations         = optimizations;
     GitDiffTarget         = gitDiffSource;
     TestProjects          = testProjects;
     AzureSAS            = azureSAS;
     AzureFileStorageUrl = azureFileStorageUrl;
     BaselineProvider    = baselineProvider;
     MutationLevel       = mutationLevel;
 }
        public string Validate(BaselineProvider baselineProvider)
        {
            if (baselineProvider == BaselineProvider.AzureFileStorage)
            {
                if (string.IsNullOrWhiteSpace(SuppliedInput))
                {
                    throw new InputException("The azure file storage shared access signature is required when azure file storage is used for dashboard compare.");
                }

                // Normalize the SAS
                return(SuppliedInput.Replace("?sv=", ""));
            }
            return(Default);
        }
示例#4
0
        public string Validate(BaselineProvider baselineProvider)
        {
            if (baselineProvider == BaselineProvider.AzureFileStorage)
            {
                if (SuppliedInput is null)
                {
                    throw new InputException("The Azure File Storage url is required when Azure File Storage is used for dashboard compare.");
                }

                if (!Uri.IsWellFormedUriString(SuppliedInput, UriKind.Absolute))
                {
                    throw new InputException($"The Azure File Storage url is not a valid Uri: {SuppliedInput}");
                }

                return(SuppliedInput);
            }
            return(Default);
        }
示例#5
0
 private StrykerOptions(
     IFileSystem fileSystem,
     ILogger logger,
     string basePath,
     string outputPath,
     IEnumerable <Reporter> reporters,
     string projectUnderTestNameFilter,
     string projectUnderTest,
     int additionalTimeoutMS,
     IEnumerable <Mutator> excludedMutations,
     IEnumerable <Regex> ignoredMethods,
     LogOptions logOptions,
     OptimizationFlags optimizations,
     Threshold thresholds,
     bool devMode,
     string optimizationMode,
     int concurrentTestRunners,
     IEnumerable <FilePattern> filePatterns,
     TestRunner testRunner,
     string solutionPath,
     LanguageVersion languageVersion,
     bool diffEnabled,
     string gitDiffSource,
     IEnumerable <FilePattern> diffIgnoreFiles,
     IEnumerable <string> testProjects,
     string azureSAS,
     string azureFileStorageUrl,
     BaselineProvider baselineProvider,
     MutationLevel mutationLevel,
     bool compareToDashboard,
     string dashboardUrl,
     string dashboardApiKey,
     string projectName,
     string moduleName,
     string projectVersion,
     string fallbackVersion)
 {
     _fileSystem                = fileSystem;
     _logger                    = logger;
     IgnoredMethods             = ignoredMethods;
     BasePath                   = basePath;
     OutputPath                 = outputPath;
     Reporters                  = reporters;
     ProjectUnderTestNameFilter = projectUnderTestNameFilter;
     ProjectUnderTest           = projectUnderTest;
     AdditionalTimeoutMS        = additionalTimeoutMS;
     ExcludedMutations          = excludedMutations;
     LogOptions                 = logOptions;
     DevMode                    = devMode;
     ConcurrentTestrunners      = concurrentTestRunners;
     Thresholds                 = thresholds;
     FilePatterns               = filePatterns;
     TestRunner                 = testRunner;
     SolutionPath               = solutionPath;
     LanguageVersion            = languageVersion;
     OptimizationMode           = optimizationMode;
     Optimizations              = optimizations;
     DiffEnabled                = diffEnabled;
     GitDiffSource              = gitDiffSource;
     DiffIgnoreFiles            = diffIgnoreFiles;
     TestProjects               = testProjects;
     AzureSAS                   = azureSAS;
     AzureFileStorageUrl        = azureFileStorageUrl;
     BaselineProvider           = baselineProvider;
     MutationLevel              = mutationLevel;
     CompareToDashboard         = compareToDashboard;
     DashboardUrl               = dashboardUrl;
     DashboardApiKey            = dashboardApiKey;
     ProjectName                = projectName;
     ModuleName                 = moduleName;
     ProjectVersion             = projectVersion;
     FallbackVersion            = fallbackVersion;
 }