File tree Expand file tree Collapse file tree
src/NuGetGallery.Services/Configuration
tests/NuGetGallery.Facts/App_Start Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public class ConfigurationService : IGalleryConfigurationService
3131 private readonly Lazy < FeatureConfiguration > _lazyFeatureConfiguration ;
3232 private readonly Lazy < IServiceBusConfiguration > _lazyServiceBusConfiguration ;
3333 private readonly Lazy < IPackageDeleteConfiguration > _lazyPackageDeleteConfiguration ;
34+ private readonly HashSet < string > _NotInjectedSettingNames = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) {
35+ SettingPrefix + "SqlServer" ,
36+ SettingPrefix + "SqlServerReadOnlyReplica" ,
37+ SettingPrefix + "SupportRequestSqlServer" ,
38+ SettingPrefix + "ValidationSqlServer" } ;
3439
3540 public ISecretInjector SecretInjector { get ; set ; }
3641
@@ -120,7 +125,7 @@ public async Task<string> ReadSettingAsync(string settingName)
120125 {
121126 var value = ReadRawSetting ( settingName ) ;
122127
123- if ( ! string . IsNullOrEmpty ( value ) )
128+ if ( ! string . IsNullOrEmpty ( value ) && ! _NotInjectedSettingNames . Contains ( settingName ) )
124129 {
125130 value = await SecretInjector . InjectAsync ( value ) ;
126131 }
Original file line number Diff line number Diff line change @@ -187,6 +187,33 @@ public async Task WhenSettingIsNotEmptySecretInjectorIsRan()
187187 // Assert
188188 Assert . Equal ( "somevalueparsed" , result ) ;
189189 }
190+
191+ [ Theory ]
192+ [ InlineData ( "Gallery.SqlServer" ) ]
193+ [ InlineData ( "Gallery.SqlServerReadOnlyReplica" ) ]
194+ [ InlineData ( "Gallery.SupportRequestSqlServer" ) ]
195+ [ InlineData ( "Gallery.ValidationSqlServer" ) ]
196+ [ InlineData ( "Gallery.sqlserver" ) ]
197+ [ InlineData ( "Gallery.sqlserverreadonlyreplica" ) ]
198+ [ InlineData ( "Gallery.supportrequestsqlserver" ) ]
199+ [ InlineData ( "Gallery.validationsqlserver" ) ]
200+ public async Task GivenNotInjectedSettingNameSecretInjectorIsNotRan ( string settingName )
201+ {
202+ // Arrange
203+ var secretInjectorMock = new Mock < ISecretInjector > ( ) ;
204+ secretInjectorMock . Setup ( x => x . InjectAsync ( It . IsAny < string > ( ) ) )
205+ . Returns < string > ( s => Task . FromResult ( s + "parsed" ) ) ;
206+
207+ var configurationService = new TestableConfigurationService ( secretInjectorMock . Object ) ;
208+ configurationService . CloudSettingStub = "somevalue" ;
209+
210+ // Act
211+ string result = await configurationService . ReadSettingAsync ( settingName ) ;
212+
213+ // Assert
214+ secretInjectorMock . Verify ( x => x . InjectAsync ( It . IsAny < string > ( ) ) , Times . Never ) ;
215+ Assert . Equal ( "somevalue" , result ) ;
216+ }
190217 }
191218 }
192219}
You can’t perform that action at this time.
0 commit comments