mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
merging menaka's commit
This commit is contained in:
parent
2c17bafdf1
commit
134200375a
@ -27,15 +27,10 @@ import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
|
|||||||
*/
|
*/
|
||||||
public class OAuthUtil {
|
public class OAuthUtil {
|
||||||
|
|
||||||
public static String getScopes(String backendHTTPURL, String backendHTTPSURL) throws Exception {
|
|
||||||
return getOAuthTokenPair(backendHTTPURL, backendHTTPSURL).get(Constants.SCOPE).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getOAuthToken(String backendHTTPURL, String backendHTTPSURL) throws Exception {
|
public static String getOAuthToken(String backendHTTPURL, String backendHTTPSURL)
|
||||||
return getOAuthTokenPair(backendHTTPURL, backendHTTPSURL).get(Constants.OAUTH_ACCESS_TOKEN).toString();
|
throws Exception {
|
||||||
}
|
Thread.sleep(10000);
|
||||||
|
|
||||||
public static JSONObject getOAuthTokenPair(String backendHTTPURL, String backendHTTPSURL) throws Exception {
|
|
||||||
String AuthString = "Basic YWRtaW46YWRtaW4=";
|
String AuthString = "Basic YWRtaW46YWRtaW4=";
|
||||||
RestClient client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, AuthString);
|
RestClient client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, AuthString);
|
||||||
HttpResponse oAuthData = client.post(Constants.APIApplicationRegistration.API_APP_REGISTRATION_ENDPOINT,
|
HttpResponse oAuthData = client.post(Constants.APIApplicationRegistration.API_APP_REGISTRATION_ENDPOINT,
|
||||||
|
|||||||
@ -54,6 +54,8 @@ public class MobileDeviceManagementWithNoDevices extends TestBase {
|
|||||||
@BeforeClass(alwaysRun = true, groups = { Constants.MobileDeviceManagement.MOBILE_DEVICE_MANAGEMENT_GROUP})
|
@BeforeClass(alwaysRun = true, groups = { Constants.MobileDeviceManagement.MOBILE_DEVICE_MANAGEMENT_GROUP})
|
||||||
public void initTest() throws Exception {
|
public void initTest() throws Exception {
|
||||||
|
|
||||||
|
super.init(TestUserMode.SUPER_TENANT_ADMIN);
|
||||||
|
Thread.sleep(10000);
|
||||||
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPSURL, backendHTTPSURL);
|
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPSURL, backendHTTPSURL);
|
||||||
this.client = new IOTHttpClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
|
this.client = new IOTHttpClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
|
||||||
}
|
}
|
||||||
@ -65,9 +67,5 @@ public class MobileDeviceManagementWithNoDevices extends TestBase {
|
|||||||
Assert.assertEquals(Constants.MobileDeviceManagement.NO_DEVICE, response.getBody());
|
Assert.assertEquals(Constants.MobileDeviceManagement.NO_DEVICE, response.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkScopes(String permissionsList) throws Exception {
|
|
||||||
String tokenString = OAuthUtil.getScopes(backendHTTPSURL, backendHTTPSURL);
|
|
||||||
return tokenString.contains(permissionsList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user