Skip to content

Commit

Permalink
unit tests - adding azuresettings
Browse files Browse the repository at this point in the history
  • Loading branch information
thepirat000 committed Dec 17, 2023
1 parent c19d866 commit 0b83a3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# Azure keys
AzureSettings.cs

# User-specific files
*.suo
*.user
Expand Down Expand Up @@ -261,14 +258,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
/AuditFw.pptx
/AuditFw.pptx
/AuditFw.pptx

Docs/
/src/Newtonsoft.Json.dll
/src/UpgradeVersion.exe
/src/StrongName/Audit.NET.snk
/test/Audit.TestRunnerFull
/test/Audit.Integration.AspNet
/test/Audit.Integration.AspNet.Runner
/src/StrongName/Audit.NET.snk
26 changes: 26 additions & 0 deletions test/AzureSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;

namespace Audit.IntegrationTest
{
public static class AzureSettings
{
public static string AzureBlobServiceUrl => GetFromEnv("AZUREBLOBSERVICEURL");
public static string AzureBlobAccountName => GetFromEnv("AZUREBLOBACCOUNTNAME");
public static string AzureBlobAccountKey => GetFromEnv("AZUREBLOBACCOUNTKEY");
public static string AzureBlobCnnString => GetFromEnv("AZUREBLOBCNNSTRING");
public static string AzureTableCnnString => GetFromEnv("AZURETABLECNNSTRING");
public static string AzureDocDbUrl => GetFromEnv("AZUREDOCDBURL");
public static string AzureDocDbAuthKey => GetFromEnv("AZUREDOCDBAUTHKEY");
public static string BlobAccountName => GetFromEnv("BLOBACCOUNTNAME");
public static string BlobTenantId => GetFromEnv("BLOBTENANTID");
public static string ElasticSearchUrl => "http://127.0.0.1:9200";
public static string PostgreSqlConnectionString => "Server=localhost;Port=5432;User Id=postgres;Password=admin;Database=postgres;";

private static string GetFromEnv(string key, string @default = null)
{
var varName = "AUDIT_NET_" + key.ToUpper();
var value = Environment.GetEnvironmentVariable(varName) ?? @default ?? throw new Exception($"No environment variable or default set for variable '{key}'");
return value;
}
}
}

0 comments on commit 0b83a3e

Please sign in to comment.