From 0077c67e0b8ab4330a37856946c685725cb0586c Mon Sep 17 00:00:00 2001 From: Joshua Komonen <68486286+jkomonen@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:12:26 -0400 Subject: [PATCH 1/4] wipes profile section when bmx write --use-credential-process is ran --- src/D2L.Bmx/WriteHandler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/D2L.Bmx/WriteHandler.cs b/src/D2L.Bmx/WriteHandler.cs index d424b03a..daba6590 100644 --- a/src/D2L.Bmx/WriteHandler.cs +++ b/src/D2L.Bmx/WriteHandler.cs @@ -70,6 +70,11 @@ bool useCredentialProcess if( !data.Sections.ContainsSection( sectionName ) ) { data.Sections.AddSection( sectionName ); } + var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); + if (defaultCredentialsFile.Sections.ContainsSection( profile ) ) { + defaultCredentialsFile.Sections.RemoveSection( profile ); + parser.WriteFile(SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile); + } data[sectionName]["credential_process"] = "bmx print --format json --cache --non-interactive" + $" --org \"{oktaApi.Org}\"" From 2dc61761faac952e3b9c2331e7596250b76a5920 Mon Sep 17 00:00:00 2001 From: Joshua Komonen <68486286+jkomonen@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:26:23 -0400 Subject: [PATCH 2/4] checked if file exists --- src/D2L.Bmx/WriteHandler.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/D2L.Bmx/WriteHandler.cs b/src/D2L.Bmx/WriteHandler.cs index daba6590..e6f2418c 100644 --- a/src/D2L.Bmx/WriteHandler.cs +++ b/src/D2L.Bmx/WriteHandler.cs @@ -70,10 +70,12 @@ bool useCredentialProcess if( !data.Sections.ContainsSection( sectionName ) ) { data.Sections.AddSection( sectionName ); } - var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); - if (defaultCredentialsFile.Sections.ContainsSection( profile ) ) { - defaultCredentialsFile.Sections.RemoveSection( profile ); - parser.WriteFile(SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile); + if (File.Exists(SharedCredentialsFile.DefaultFilePath)) { + var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); + if ( defaultCredentialsFile.Sections.ContainsSection( profile ) ) { + defaultCredentialsFile.Sections.RemoveSection( profile ); + parser.WriteFile( SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile ); + } } data[sectionName]["credential_process"] = "bmx print --format json --cache --non-interactive" From 6b2d6c141211f348a6c65b06e4310c7414b21c2e Mon Sep 17 00:00:00 2001 From: Joshua Komonen <68486286+jkomonen@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:46:24 -0400 Subject: [PATCH 3/4] fixed formatting --- src/D2L.Bmx/WriteHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/D2L.Bmx/WriteHandler.cs b/src/D2L.Bmx/WriteHandler.cs index e6f2418c..2dc93b2f 100644 --- a/src/D2L.Bmx/WriteHandler.cs +++ b/src/D2L.Bmx/WriteHandler.cs @@ -70,7 +70,7 @@ bool useCredentialProcess if( !data.Sections.ContainsSection( sectionName ) ) { data.Sections.AddSection( sectionName ); } - if (File.Exists(SharedCredentialsFile.DefaultFilePath)) { + if ( File.Exists( SharedCredentialsFile.DefaultFilePath ) ) { var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); if ( defaultCredentialsFile.Sections.ContainsSection( profile ) ) { defaultCredentialsFile.Sections.RemoveSection( profile ); From 9c61ffb228699e0f79180a1cde15f01f2a2c47a8 Mon Sep 17 00:00:00 2001 From: DotNet Format Bot Date: Thu, 6 Jun 2024 13:47:14 +0000 Subject: [PATCH 4/4] auto format --- src/D2L.Bmx/WriteHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/D2L.Bmx/WriteHandler.cs b/src/D2L.Bmx/WriteHandler.cs index 2dc93b2f..de0287dc 100644 --- a/src/D2L.Bmx/WriteHandler.cs +++ b/src/D2L.Bmx/WriteHandler.cs @@ -70,9 +70,9 @@ bool useCredentialProcess if( !data.Sections.ContainsSection( sectionName ) ) { data.Sections.AddSection( sectionName ); } - if ( File.Exists( SharedCredentialsFile.DefaultFilePath ) ) { + if( File.Exists( SharedCredentialsFile.DefaultFilePath ) ) { var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); - if ( defaultCredentialsFile.Sections.ContainsSection( profile ) ) { + if( defaultCredentialsFile.Sections.ContainsSection( profile ) ) { defaultCredentialsFile.Sections.RemoveSection( profile ); parser.WriteFile( SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile ); }