55import io .opentdf .platform .policy .Algorithm ;
66import io .opentdf .platform .wellknownconfiguration .GetWellKnownConfigurationResponse ;
77import io .opentdf .platform .wellknownconfiguration .WellKnownServiceClientInterface ;
8+ import org .assertj .core .api .Assertions ;
89import org .junit .jupiter .api .Test ;
910import org .mockito .Mockito ;
1011
@@ -139,4 +140,50 @@ void testFillingInKeysWithAutoConfigure() {
139140 assertThat (split3KasInfo .Algorithm ).isEqualTo ("rsa:4096" );
140141 assertThat (split3KasInfo .PublicKey ).isEqualTo ("pem3" );
141142 }
143+
144+ @ Test
145+ void returnsOnlyDefaultKasesIfPresent () {
146+ var kas1 = new Config .KASInfo ();
147+ kas1 .URL = "https://kas1.example.com" ;
148+ kas1 .Default = true ;
149+
150+ var kas2 = new Config .KASInfo ();
151+ kas2 .URL = "https://kas2.example.com" ;
152+ kas2 .Default = false ;
153+
154+ var kas3 = new Config .KASInfo ();
155+ kas3 .URL = "https://kas3.example.com" ;
156+ kas3 .Default = true ;
157+
158+ var config = new Config .TDFConfig ();
159+ config .kasInfoList .addAll (List .of (kas1 , kas2 , kas3 ));
160+
161+ List <String > result = Planner .defaultKases (config );
162+
163+ Assertions .assertThat (result ).containsExactlyInAnyOrder ("https://kas1.example.com" , "https://kas3.example.com" );
164+ }
165+
166+ @ Test
167+ void returnsAllKasesIfNoDefault () {
168+ var kas1 = new Config .KASInfo ();
169+ kas1 .URL = "https://kas1.example.com" ;
170+ kas1 .Default = false ;
171+
172+ var kas2 = new Config .KASInfo ();
173+ kas2 .URL = "https://kas2.example.com" ;
174+ kas2 .Default = null ; // not set
175+
176+ var config = new Config .TDFConfig ();
177+ config .kasInfoList .addAll (List .of (kas1 , kas2 ));
178+
179+ List <String > result = Planner .defaultKases (config );
180+ Assertions .assertThat (result ).containsExactlyInAnyOrder ("https://kas1.example.com" , "https://kas2.example.com" );
181+ }
182+
183+ @ Test
184+ void returnsEmptyListIfNoKases () {
185+ var config = new Config .TDFConfig ();
186+ List <String > result = Planner .defaultKases (config );
187+ Assertions .assertThat (result ).isEmpty ();
188+ }
142189}
0 commit comments