1010import org .junit .jupiter .api .Test ;
1111import org .junit .jupiter .api .extension .ExtendWith ;
1212import org .junit .jupiter .params .ParameterizedTest ;
13+ import org .junit .jupiter .params .provider .Arguments ;
14+ import org .junit .jupiter .params .provider .MethodSource ;
1315import org .junit .jupiter .params .provider .ValueSource ;
1416import org .mockito .Mock ;
1517import org .mockito .junit .jupiter .MockitoExtension ;
2022import java .nio .charset .StandardCharsets ;
2123import java .util .Arrays ;
2224import java .util .Base64 ;
25+ import java .util .stream .Stream ;
2326
2427import static org .junit .jupiter .api .Assertions .*;
2528import static org .mockito .ArgumentMatchers .any ;
@@ -62,7 +65,7 @@ public void setup() throws AttestationException {
6265 }
6366
6467 @ ParameterizedTest
65- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
68+ @ MethodSource ( "argumentProvider" )
6669 public void testHappyPath (String azureProtocol ) throws AttestationException {
6770 var provider = new AzureCCCoreAttestationService (alwaysPassTokenValidator , alwaysPassPolicyValidator , azureProtocol );
6871 provider .registerEnclave (ENCLAVE_ID );
@@ -73,7 +76,7 @@ public void testHappyPath(String azureProtocol) throws AttestationException {
7376 }
7477
7578 @ ParameterizedTest
76- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
79+ @ MethodSource ( "argumentProvider" )
7780 public void testSignatureCheckFailed_ClientError (String azureProtocol ) throws AttestationException {
7881 var errorStr = "token signature validation failed" ;
7982 when (alwaysFailTokenValidator .validate (any (), any ())).thenThrow (new AttestationClientException (errorStr , AttestationFailure .BAD_PAYLOAD ));
@@ -87,7 +90,7 @@ public void testSignatureCheckFailed_ClientError(String azureProtocol) throws At
8790 }
8891
8992 @ ParameterizedTest
90- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
93+ @ MethodSource ( "argumentProvider" )
9194 public void testSignatureCheckFailed_ServerError (String azureProtocol ) throws AttestationException {
9295 when (alwaysFailTokenValidator .validate (any (), any ())).thenThrow (new AttestationException ("unknown server error" ));
9396 var provider = new AzureCCCoreAttestationService (alwaysFailTokenValidator , alwaysPassPolicyValidator , azureProtocol );
@@ -99,7 +102,7 @@ public void testSignatureCheckFailed_ServerError(String azureProtocol) throws At
99102 }
100103
101104 @ ParameterizedTest
102- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
105+ @ MethodSource ( "argumentProvider" )
103106 public void testPolicyCheckSuccess_ClientError (String azureProtocol ) throws AttestationException {
104107 var errorStr = "policy validation failed" ;
105108 when (alwaysFailPolicyValidator .validate (any (), any ())).thenThrow (new AttestationClientException (errorStr , AttestationFailure .BAD_PAYLOAD ));
@@ -113,7 +116,7 @@ public void testPolicyCheckSuccess_ClientError(String azureProtocol) throws Atte
113116 }
114117
115118 @ ParameterizedTest
116- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
119+ @ MethodSource ( "argumentProvider" )
117120 public void testPolicyCheckFailed_ServerError (String azureProtocol ) throws AttestationException {
118121 when (alwaysFailPolicyValidator .validate (any (), any ())).thenThrow (new AttestationException ("unknown server error" ));
119122 var provider = new AzureCCCoreAttestationService (alwaysFailTokenValidator , alwaysFailPolicyValidator , azureProtocol );
@@ -125,7 +128,7 @@ public void testPolicyCheckFailed_ServerError(String azureProtocol) throws Attes
125128 }
126129
127130 @ ParameterizedTest
128- @ ValueSource ( strings = { "azure-cc" , "azure-cc-aks" } )
131+ @ MethodSource ( "argumentProvider" )
129132 public void testEnclaveNotRegistered (String azureProtocol ) throws AttestationException {
130133 var provider = new AzureCCCoreAttestationService (alwaysFailTokenValidator , alwaysPassPolicyValidator , azureProtocol );
131134 attest (provider , ar -> {
@@ -141,4 +144,11 @@ private static void attest(ICoreAttestationService provider, Handler<AsyncResult
141144 PUBLIC_KEY .getBytes (StandardCharsets .UTF_8 ),
142145 handler );
143146 }
147+
148+ static Stream <Arguments > argumentProvider () {
149+ return Stream .of (
150+ Arguments .of ("azure-cc" ),
151+ Arguments .of ("azure-cc-aks" )
152+ );
153+ }
144154}
0 commit comments