@@ -67,6 +67,13 @@ public ConfigurationHoconAdapterTest()
6767 Environment . SetEnvironmentVariable ( "akka__test_value_4__1" , "one" ) ;
6868 Environment . SetEnvironmentVariable ( "akka__actor__serialization_bindings2__\" System.Object\" " , "hyperion" ) ;
6969
70+ // Issue #631
71+ // Double underscore cases
72+ Environment . SetEnvironmentVariable ( "__MISE_SESSION" , "some-random-string" ) ;
73+ // Quadruple underscore cases
74+ Environment . SetEnvironmentVariable ( "MISE____SESSION" , "some-random-string" ) ;
75+ Environment . SetEnvironmentVariable ( "____MISE_SESSION" , "some-random-string" ) ;
76+
7077 using var stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( ConfigSource ) ) ;
7178 _root = new ConfigurationBuilder ( )
7279 . AddJsonStream ( stream )
@@ -96,6 +103,10 @@ public Task DisposeAsync()
96103 Environment . SetEnvironmentVariable ( "akka__test_value_4__1" , null ) ;
97104 Environment . SetEnvironmentVariable ( "akka__actor__serialization_bindings2__\" System.Object\" " , null ) ;
98105
106+ Environment . SetEnvironmentVariable ( "__MISE_SESSION" , null ) ;
107+ Environment . SetEnvironmentVariable ( "MISE____SESSION" , null ) ;
108+ Environment . SetEnvironmentVariable ( "____MISE_SESSION" , null ) ;
109+
99110 return Task . CompletedTask ;
100111 }
101112
@@ -139,6 +150,11 @@ public void EnvironmentVariableTest()
139150 bindings . ContainsKey ( "System.Object" ) . Should ( ) . BeFalse ( ) ;
140151 bindings . ContainsKey ( "system.object" ) . Should ( ) . BeTrue ( ) ;
141152 bindings [ "system.object" ] . GetString ( ) . Should ( ) . Be ( "hyperion" ) ;
153+
154+ // empty string keyed objects should be accessible by using "__"
155+ config . GetString ( "__.mise-session" ) . Should ( ) . Be ( "some-random-string" ) ;
156+ config . GetString ( "mise.__.session" ) . Should ( ) . Be ( "some-random-string" ) ;
157+ config . GetString ( "__.__.mise-session" ) . Should ( ) . Be ( "some-random-string" ) ;
142158 }
143159
144160 [ Fact ( DisplayName = "Non-normalized adaptor should read environment variable sourced configuration correctly" ) ]
@@ -179,6 +195,11 @@ public void EnvironmentVariableCaseSensitiveTest()
179195 . ToDictionary ( kvp => kvp . Key , kvp => kvp . Value ) ;
180196 bindings . ContainsKey ( "System.Object" ) . Should ( ) . BeTrue ( ) ;
181197 bindings [ "System.Object" ] . GetString ( ) . Should ( ) . Be ( "hyperion" ) ;
198+
199+ // empty string keyed objects should be accessible by using "__"
200+ config . GetString ( "__.MISE-SESSION" ) . Should ( ) . Be ( "some-random-string" ) ;
201+ config . GetString ( "MISE.__.SESSION" ) . Should ( ) . Be ( "some-random-string" ) ;
202+ config . GetString ( "__.__.MISE-SESSION" ) . Should ( ) . Be ( "some-random-string" ) ;
182203 }
183204
184205 [ Fact ( DisplayName = "Non-normalized Adaptor should read quote enclosed key inside JSON settings correctly" ) ]
0 commit comments