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

Extracting some methods.

parent a8d3edb3
......@@ -27,8 +27,7 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getOpsToken() throws Exception {
if (Strings.isNullOrEmpty(opsToken)) {
opsToken = getToken(System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")),
System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")));
opsToken = getIntegrationTesterToken();
}
return "Bearer " + opsToken;
}
......@@ -36,8 +35,7 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getAdminToken() throws Exception {
if (Strings.isNullOrEmpty(adminToken)) {
adminToken = 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")));
adminToken = getNoDataAccessToken();
}
return "Bearer " + adminToken;
}
......@@ -45,8 +43,7 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getEditorToken() throws Exception {
if (Strings.isNullOrEmpty(editorToken)) {
editorToken = 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")));
editorToken = getNoDataAccessToken();
}
return "Bearer " + editorToken;
}
......@@ -54,12 +51,21 @@ public class AzureTestUtils extends TestUtils {
@Override
public synchronized String getNoAccessToken() throws Exception {
if (Strings.isNullOrEmpty(noAccessToken)) {
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")));
noAccessToken = getNoDataAccessToken();
}
return "Bearer " + noAccessToken;
}
private String getNoDataAccessToken() 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