Commit a99f0b9c authored by Komal Makkar's avatar Komal Makkar
Browse files

added todos for maintainability.

parent 764584bf
Pipeline #16599 failed with stages
in 21 minutes and 21 seconds
......@@ -78,14 +78,14 @@ public class TestPubsubEndpointHMAC extends PubsubEndpointHMACTests {
@Test
@Override
public void should_return401_when_accessingWithEditorCredentials() throws Exception{
ClientResponse response = descriptor.run(getArg(), testUtils.getEditorToken());
ClientResponse response = descriptor.run(getArg(), testUtils.getNoAccessToken());
assertEquals(error( response.getEntity(String.class)), 403, response.getStatus());
}
@Test
@Override
public void should_return401_when_accessingWithAdminCredentials() throws Exception{
ClientResponse response = descriptor.run(getArg(), testUtils.getAdminToken());
ClientResponse response = descriptor.run(getArg(), testUtils.getNoAccessToken());
assertEquals(error( response.getEntity(String.class)), 403, response.getStatus());
}
}
\ No newline at end of file
......@@ -24,10 +24,13 @@ public class AzureTestUtils extends TestUtils {
}
// TODO : Revisit for synchronized block
// TODO : As azure has two tester SP ops, admin and editor are using integration Tests.
// This should be revisited.
@Override
public synchronized String getOpsToken() throws Exception {
if (Strings.isNullOrEmpty(opsToken)) {
opsToken = getIntegrationTesterToken();
opsToken = getToken(System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")),
System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")));
}
return "Bearer " + opsToken;
}
......@@ -35,7 +38,8 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getAdminToken() throws Exception {
if (Strings.isNullOrEmpty(adminToken)) {
adminToken = getNoDataAccessTesterToken();
adminToken = getToken(System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")),
System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")));
}
return "Bearer " + adminToken;
}
......@@ -43,7 +47,8 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getEditorToken() throws Exception {
if (Strings.isNullOrEmpty(editorToken)) {
editorToken = getNoDataAccessTesterToken();
editorToken = getToken(System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")),
System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")));
}
return "Bearer " + editorToken;
}
......@@ -51,21 +56,12 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getNoAccessToken() throws Exception {
if (Strings.isNullOrEmpty(noAccessToken)) {
noAccessToken = getNoDataAccessTesterToken();
noAccessToken = getToken(System.getProperty("NO_DATA_ACCESS_TESTER", System.getenv("NO_DATA_ACCESS_TESTER")),
System.getProperty("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET")));
}
return "Bearer " + noAccessToken;
}
private String getNoDataAccessTesterToken() throws Exception {
return getToken(System.getProperty("NO_DATA_ACCESS_TESTER", System.getenv("NO_DATA_ACCESS_TESTER")),
System.getProperty("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET")));
}
private String getIntegrationTesterToken() throws Exception {
return getToken(System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")),
System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")));
}
private String getToken(String sp_id, String sp_secret) throws Exception {
String tenant_id = System.getProperty("AZURE_AD_TENANT_ID", System.getenv("AZURE_AD_TENANT_ID"));
String app_resource_id = System.getProperty("AZURE_AD_APP_RESOURCE_ID", System.getenv("AZURE_AD_APP_RESOURCE_ID"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment