diff --git a/.github/workflows/DeleteSObject_build_and_test_on_main.yml b/.github/workflows/DeleteSObject_build_and_test_on_main.yml index 7cbb0ed..ea9aeb1 100644 --- a/.github/workflows/DeleteSObject_build_and_test_on_main.yml +++ b/.github/workflows/DeleteSObject_build_and_test_on_main.yml @@ -17,9 +17,11 @@ jobs: env_var_name_2: Salesforce_Password env_var_name_3: Salesforce_Security_Token env_var_name_4: Salesforce_ClientID + env_var_name_5: Salesforce_Username secrets: badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} env_var_value_1: ${{ secrets.SALESFORCE_CLIENT_SECRET }} env_var_value_2: ${{ secrets.SALESFORCE_PASSWORD }} env_var_value_3: ${{ secrets.SALESFORCE_SECURITY_TOKEN }} env_var_value_4: ${{ secrets.SALESFORCE_CLIENTID }} + env_var_value_5: ${{ secrets.SALESFORCE_USERNAME }} diff --git a/.github/workflows/DeleteSObject_build_and_test_on_push.yml b/.github/workflows/DeleteSObject_build_and_test_on_push.yml index f74b80e..9ccd4f6 100644 --- a/.github/workflows/DeleteSObject_build_and_test_on_push.yml +++ b/.github/workflows/DeleteSObject_build_and_test_on_push.yml @@ -17,6 +17,7 @@ jobs: env_var_name_2: Salesforce_Password env_var_name_3: Salesforce_Security_Token env_var_name_4: Salesforce_ClientID + env_var_name_5: Salesforce_Username secrets: badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} test_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }} @@ -24,3 +25,4 @@ jobs: env_var_value_2: ${{ secrets.SALESFORCE_PASSWORD }} env_var_value_3: ${{ secrets.SALESFORCE_SECURITY_TOKEN }} env_var_value_4: ${{ secrets.SALESFORCE_CLIENTID }} + env_var_value_5: ${{ secrets.SALESFORCE_USERNAME }} diff --git a/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/Frends.Salesforce.DeleteSObject.Tests.csproj b/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/Frends.Salesforce.DeleteSObject.Tests.csproj index 6c5242b..3162f79 100644 --- a/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/Frends.Salesforce.DeleteSObject.Tests.csproj +++ b/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/Frends.Salesforce.DeleteSObject.Tests.csproj @@ -6,6 +6,7 @@ + diff --git a/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/UnitTests.cs b/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/UnitTests.cs index 54dfcd1..80dd6da 100644 --- a/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/UnitTests.cs +++ b/Frends.Salesforce.DeleteSObject/Frends.Salesforce.DeleteSObject.Tests/UnitTests.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Net.Http; +using System.IO; using System.Threading; using System.Threading.Tasks; using Frends.Salesforce.DeleteSObject.Definitions; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; +using dotenv.net; using RestSharp; using JsonSerializer = System.Text.Json.JsonSerializer; @@ -18,9 +20,9 @@ public class UnitTests private readonly string _password = Environment.GetEnvironmentVariable("Salesforce_Password"); private readonly string _securityToken = Environment.GetEnvironmentVariable("Salesforce_Security_Token"); private readonly string _clientID = Environment.GetEnvironmentVariable("Salesforce_ClientID"); + private readonly string _username = Environment.GetEnvironmentVariable("Salesforce_Username"); - private readonly string _domain = @"https://hiqfinlandoy2-dev-ed.my.salesforce.com"; - private readonly string _username = "testuser@test.fi"; + private readonly string _domain = @"https://frends2-dev-ed.develop.my.salesforce.com"; private readonly string _authurl = @"https://login.salesforce.com/services/oauth2/token"; private readonly CancellationToken _cancellationToken = new(); @@ -29,6 +31,17 @@ public class UnitTests readonly string _name = "Test" + DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Millisecond; + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + // load envs + var root = Directory.GetCurrentDirectory(); + var projDir = Directory.GetParent(root)?.Parent?.Parent?.FullName; + DotEnv.Load( + options: new DotEnvOptions( + envFilePaths: new[] { $"{projDir}{Path.DirectorySeparatorChar}.env.local" })); + } + [TestInitialize] public async Task TestInitialize() {