public void VeracodeConfiguration_GetCredentials() { var configuration = VeracodeEnvHelper.GetConfiguration(); Assert.AreEqual(test_id, configuration.ApiId); Assert.AreEqual(test_key, configuration.ApiKey); }
static void Main(string[] args) { IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)) #if DEBUG .AddJsonFile($"appsettings.Development.json", false) #else .AddJsonFile("appsettings.json", false) #endif .Build(); var serviceCollection = new ServiceCollection(); var profileName = Configuration.GetValue <string>("VeracodeProfileName"); var veracodeCredFilePath = Configuration.GetValue <string>("VeracodeFileLocation"); var useEnvironmentVariables = Configuration.GetValue <bool>("UseEnvironmentVariables"); if (useEnvironmentVariables || String.IsNullOrWhiteSpace(veracodeCredFilePath)) { serviceCollection.AddTransient(options => Microsoft.Extensions.Options.Options.Create( VeracodeEnvHelper.GetConfiguration())); } else { serviceCollection.AddTransient(options => Microsoft.Extensions.Options.Options.Create( VeracodeFileHelper.GetConfiguration(veracodeCredFilePath, profileName))); } serviceCollection.AddScoped <IVeracodeRepository, VeracodeRepository>(); serviceCollection.AddScoped <IVeracodeService, VeracodeService>(); serviceCollection.AddScoped <IDscLogic, DscLogic>(); serviceCollection.AddLogging(loggingBuilder => { loggingBuilder.AddNLog("nlog.config"); }); _serviceProvider = serviceCollection.BuildServiceProvider(); _logger = _serviceProvider.GetService <ILogger <Program> >(); _dscLogic = _serviceProvider.GetService <IDscLogic>(); Parser.Default.ParseArguments < TestOptions, ScanOptions, ConfigureOptions, EvaluateOptions, MitigationOptions, DeleteOptions>(args) .MapResult( (TestOptions options) => Test(options), (ScanOptions options) => Scan(options), (ConfigureOptions options) => Configure(options), (EvaluateOptions options) => Evaluate(options), (MitigationOptions options) => MitigationTemplates(options), (DeleteOptions options) => Delete(options), errs => HandleParseError(errs)); }