Fix test cases for device status filter

rm-10378
Pramila Niroshan 1 year ago
parent bc9121e3e6
commit 723f544369

@ -19,6 +19,8 @@
package io.entgra.device.mgt.core.device.mgt.core.search;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.BeforeClass;
@ -38,9 +40,11 @@ public class DeviceDetails extends BaseDeviceManagementTest {
@Override
public void init() throws Exception {
DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService);
DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService);
DeviceStatusManagementService deviceStatusManagementService = new DeviceStatusManagementServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceStatusManagementService(deviceStatusManagementService);
}
@Test

@ -18,6 +18,9 @@
package io.entgra.device.mgt.core.device.mgt.core.service;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
import io.entgra.device.mgt.core.device.mgt.core.config.ui.UIConfigurationManager;
import org.apache.commons.collections.map.SingletonMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -61,6 +64,7 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.sql.Timestamp;
@ -78,6 +82,8 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
private static final String ALTERNATE_DEVICE_ID = "1128";
private static final String DEVICE_TYPE = "RANDOM_DEVICE_TYPE";
private final DeviceDetailsDAO deviceDetailsDAO = DeviceManagementDAOFactory.getDeviceDetailsDAO();
private static final String MDM_CONFIG_LOCATION = "src" + File.separator + "test" + File.separator + "resources" +
File.separator + "config" + File.separator + "operation" + File.separator + "mdm-ui-config.xml";
DeviceManagementProviderService deviceMgtService;
@ -96,6 +102,7 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null);
deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE,
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME));
UIConfigurationManager.getInstance().initConfig(MDM_CONFIG_LOCATION);
}
private RegistryService getRegistryService() throws RegistryException {
@ -204,8 +211,11 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
@Test(dependsOnMethods = {"testSuccessfulDeviceEnrollment"})
public void testReEnrollmentofSameDeviceUnderSameUser() throws DeviceManagementException {
public void testReEnrollmentofSameDeviceUnderSameUser() throws DeviceManagementException, MetadataManagementException {
if (!isMock()) {
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
.getInstance().getDeviceStatusManagementService();
deviceStatusManagementService.addDefaultDeviceStatusFilterIfNotExist(MultitenantConstants.SUPER_TENANT_ID);
Device device = TestDataHolder.generateDummyDeviceData(new DeviceIdentifier(DEVICE_ID, DEVICE_TYPE));
boolean enrollment = deviceMgtService.enrollDevice(device);
Assert.assertTrue(enrollment);

@ -0,0 +1,410 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
~
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<UIConfiguration>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>true</EnableSSO>
<!-- session time out in seconds -->
<SessionTimeOut>3600</SessionTimeOut>
<!-- maximum number of login cache entries -->
<LoginCacheCapacity>10000</LoginCacheCapacity>
<!-- hubspot account info for live chat -->
<HubspotChat>
<EnableHubspot>false</EnableHubspot>
<TrackingUrl>tracking_url</TrackingUrl>
<!-- access token - whenever the access token will be rotated, needs to be changed this with the new token -->
<AccessToken>access_token</AccessToken>
<SenderActorId>sender_actorId</SenderActorId>
</HubspotChat>
<Billing>
<HideBillGenerationInSuperTenant>false</HideBillGenerationInSuperTenant>
<HideBillGenerationInSubTenant>true</HideBillGenerationInSubTenant>
<HideTotalCalculationInSuperTenant>false</HideTotalCalculationInSuperTenant>
<HideTotalCalculationInSubTenant>true</HideTotalCalculationInSubTenant>
<HideDomainSelectionInSuperTenant>false</HideDomainSelectionInSuperTenant>
<HideDomainSelectionInSubTenant>true</HideDomainSelectionInSubTenant>
</Billing>
<DeviceInfoConfigurations>
<DeviceInfoItem>
<DefinedValue>name</DefinedValue>
<DisplayValue>label_device</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>type</DefinedValue>
<DisplayValue>label_type</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>owner</DefinedValue>
<DisplayValue>label_owner</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>serial</DefinedValue>
<DisplayValue>label_serialNumber</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>ownership</DefinedValue>
<DisplayValue>label_ownership</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>status</DefinedValue>
<DisplayValue>label_status</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>dateOfLastUpdate</DefinedValue>
<DisplayValue>label_last_updated</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>actions</DefinedValue>
<DisplayValue>label_actions</DisplayValue>
<Type>default</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>batteryLevel</DefinedValue>
<DisplayValue>label_battery_leve</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>deviceModel</DefinedValue>
<DisplayValue>label_deviceModel</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>osVersion</DefinedValue>
<DisplayValue>label_os_version</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>vendor</DefinedValue>
<DisplayValue>label_vendor</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>availableRAMMemory</DefinedValue>
<DisplayValue>label_available_ram_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>connectionType</DefinedValue>
<DisplayValue>label_connection_type</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>cpuUsage</DefinedValue>
<DisplayValue>label_cpu_usage</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>externalAvailableMemory</DefinedValue>
<DisplayValue>label_external_available_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>externalTotalMemory</DefinedValue>
<DisplayValue>label_external_tot_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>internalAvailableMemory</DefinedValue>
<DisplayValue>label_internal_available_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>internalTotalMemory</DefinedValue>
<DisplayValue>label_internal_tot_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>osBuildDate</DefinedValue>
<DisplayValue>label_os_build_date</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>pluggedIn</DefinedValue>
<DisplayValue>label_plugged_in</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>ssid</DefinedValue>
<DisplayValue>label_ssid</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>totalRAMMemory</DefinedValue>
<DisplayValue>label_tot_ram_memory</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
<DeviceInfoItem>
<DefinedValue>updatedTime</DefinedValue>
<DisplayValue>label_updated_time</DisplayValue>
<Type>deviceInfo</Type>
</DeviceInfoItem>
</DeviceInfoConfigurations>
<DeviceStatusConfigurations>
<EnableDeviceStatusCheck>true</EnableDeviceStatusCheck>
<DeviceStatusItem>
<Type>android</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
<DeviceStatusItem>
<Type>ios</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
<DeviceStatusItem>
<Type>windows</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
</DeviceStatusConfigurations>
<AppRegistration>
<Tags>
<Tag>analytics_management</Tag>
<Tag>application_management</Tag>
<Tag>device_management</Tag>
<Tag>subscription_management</Tag>
<Tag>review_management</Tag>
</Tags>
<AllowToAllDomains>true</AllowToAllDomains>
</AppRegistration>
<Scopes>
<Scope>grafana:api:view</Scope>
<Scope>am:store:app:review:view</Scope>
<Scope>am:store:app:review:update</Scope>
<Scope>am:pub:sp:app:view</Scope>
<Scope>am:pub:sp:create</Scope>
<Scope>am:pub:sp:attach</Scope>
<Scope>am:pub:sp:detach</Scope>
<Scope>am:pub:sp:connect</Scope>
<Scope>am:pub:app:view</Scope>
<Scope>am:pub:app:update</Scope>
<Scope>am:store:app:view</Scope>
<Scope>am:store:app:modify</Scope>
<Scope>am:store:app:sub:install</Scope>
<Scope>am:store:app:sub:uninstall</Scope>
<Scope>am:admin:pub:app:review:view</Scope>
<Scope>am:admin:pub:app:update</Scope>
<Scope>am:admin:store:app:review:update</Scope>
<Scope>am:admin:store:app:sub:view</Scope>
<Scope>am:admin:store:app:sub:modify</Scope>
<Scope>dm:device-type:view</Scope>
<Scope>and:enterprise:modify</Scope>
<Scope>and:enterprise:view</Scope>
<Scope>dm:sign-csr</Scope>
<Scope>dm:admin:devices:view</Scope>
<Scope>dm:devices:status:change</Scope>
<Scope>rm:roles:add</Scope>
<Scope>rm:users:add</Scope>
<Scope>rm:roles:update</Scope>
<Scope>rm:roles:permissions:view</Scope>
<Scope>rm:roles:details:view</Scope>
<Scope>rm:roles:view</Scope>
<Scope>rm:roles:combined:add</Scope>
<Scope>rm:roles:delete</Scope>
<Scope>dm:activity:get</Scope>
<Scope>dm:devices:delete</Scope>
<Scope>dm:devices:app:view</Scope>
<Scope>dm:devices:policy:view</Scope>
<Scope>dm:devices:compliance:view</Scope>
<Scope>dm:devices:features:view</Scope>
<Scope>dm:devices:ops:view</Scope>
<Scope>dm:devices:search</Scope>
<Scope>dm:devices:details</Scope>
<Scope>dm:devices:update</Scope>
<Scope>dm:devices:view</Scope>
<Scope>dm:devices:enrollment-guide:view</Scope>
<Scope>dm:conf:view</Scope>
<Scope>dm:conf:manage</Scope>
<Scope>pm:policies:remove</Scope>
<Scope>pm:policies:priorities:update</Scope>
<Scope>pm:policies:deactivate</Scope>
<Scope>pm:policies:details:view</Scope>
<Scope>pm:policies:add</Scope>
<Scope>pm:policies:activate</Scope>
<Scope>pm:policies:update</Scope>
<Scope>pm:policies:change</Scope>
<Scope>dm:policies:view</Scope>
<Scope>um:users:add</Scope>
<Scope>um:users:details:view</Scope>
<Scope>um:users:count</Scope>
<Scope>um:users:delete</Scope>
<Scope>um:roles:view</Scope>
<Scope>um:users:user-details:view</Scope>
<Scope>um:users:cred:change</Scope>
<Scope>um:users:search</Scope>
<Scope>um:users:is-exist</Scope>
<Scope>um:users:update</Scope>
<Scope>um:users:invite</Scope>
<Scope>um:admin:users:view</Scope>
<Scope>dm:admin:enrollment:update</Scope>
<Scope>gm:devices:view</Scope>
<Scope>gm:groups:update</Scope>
<Scope>gm:groups:add</Scope>
<Scope>gm:groups:device:view</Scope>
<Scope>gm:devices:count</Scope>
<Scope>gm:devices-types:view</Scope>
<Scope>gm:groups:remove</Scope>
<Scope>gm:groups:view</Scope>
<Scope>gm:groups:groups-view</Scope>
<Scope>gm:roles:share</Scope>
<Scope>gm:groups:count</Scope>
<Scope>gm:roles:view</Scope>
<Scope>gm:devices:remove</Scope>
<Scope>gm:devices:add</Scope>
<Scope>gm:devices:assign</Scope>
<Scope>dm:device-type:conf:view</Scope>
<Scope>dm:device-type:features:view</Scope>
<Scope>dm:device-type:view</Scope>
<Scope>am:admin:app:install</Scope>
<Scope>am:admin:app:uninstall</Scope>
<Scope>gm:admin:groups:count</Scope>
<Scope>gm:admin:groups:view</Scope>
<Scope>gm:admin:groups:add</Scope>
<Scope>dm:notif:mark-checked</Scope>
<Scope>dm:notifications:view</Scope>
<Scope>cm:cert:delete</Scope>
<Scope>cm:cert:details:get</Scope>
<Scope>cm:cert:view</Scope>
<Scope>cm:cert:add</Scope>
<Scope>cm:cert:verify</Scope>
<Scope>dm:admin</Scope>
<Scope>dm:device-type:deploy</Scope>
<Scope>dm:device-type:event:modify</Scope>
<Scope>dm:device-type:event:view</Scope>
<Scope>dm:admin:device-type:modify</Scope>
<Scope>dm:admin:device-type:view</Scope>
<Scope>dm:admin:device-type:conf:add</Scope>
<Scope>dm:device:enroll</Scope>
<Scope>dm:geo:an:view</Scope>
<Scope>dm:geo:alerts:manage</Scope>
<Scope>dm:admin:devices:permanent-delete</Scope>
<Scope>and:conf:manage</Scope>
<Scope>and:conf:view</Scope>
<Scope>um:users:permission:view</Scope>
<Scope>ios:conf:view</Scope>
<Scope>ios:conf:manage</Scope>
<Scope>ios:dep:view</Scope>
<Scope>ios:dep:add</Scope>
<Scope>win:conf:view</Scope>
<Scope>win:conf:manage</Scope>
<Scope>and:ops:lock-devices</Scope>
<Scope>and:ops:unlock-devices</Scope>
<Scope>and:ops:location</Scope>
<Scope>and:ops:clear-password</Scope>
<Scope>and:ops:control-camera</Scope>
<Scope>and:ops:enterprise-wipe</Scope>
<Scope>and:ops:wipe</Scope>
<Scope>and:ops:ring</Scope>
<Scope>and:ops:app-list</Scope>
<Scope>and:ops:reboot</Scope>
<Scope>and:ops:change-LockTask</Scope>
<Scope>and:ops:mute</Scope>
<Scope>and:ops:conf-display-msg</Scope>
<Scope>and:ops:send-app-restrictions</Scope>
<Scope>and:ops:file-transfer</Scope>
<Scope>and:ops:set-webclip</Scope>
<Scope>and:ops:password-policy</Scope>
<Scope>and:ops:change-lock-code</Scope>
<Scope>and:ops:upgrade-firmware</Scope>
<Scope>and:ops:send-notif</Scope>
<Scope>dm:geo:geo-fence:manage</Scope>
<Scope>dm:whitelable:view</Scope>
<Scope>dm:whitelable:update</Scope>
<Scope>dm:metadata:view</Scope>
<Scope>dm:metadata:create</Scope>
<Scope>dm:metadata:update</Scope>
<Scope>and:ops:add-google-acc</Scope>
<Scope>and:ops:authenticate-acc</Scope>
<Scope>and:ops:update-default-sim</Scope>
<Scope>and:ops:add-google-acc</Scope>
<Scope>and:ops:device-info</Scope>
<Scope>win:ops:lock-devices</Scope>
<Scope>win:devices:enroll</Scope>
<Scope>win:ops:disenroll</Scope>
<Scope>win:ops:wipe</Scope>
<Scope>win:ops:ring</Scope>
<Scope>win:ops:lock-reset</Scope>
<Scope>win:ops:reboot</Scope>
<Scope>win:ops:location</Scope>
<Scope>admin:tenant:view</Scope>
<Scope>dm:admin:devices:usage:view</Scope>
<Scope>and:ops:clear-app</Scope>
<Scope>and:ops:suspend-package</Scope>
<Scope>and:ops:alternate-install</Scope>
<Scope>ios:ops:lock</Scope>
<Scope>ios:ops:location</Scope>
<Scope>ios:ops:ring</Scope>
<Scope>ios:ops:clear-passcode</Scope>
<Scope>ios:ops:enterprise-wipe</Scope>
<Scope>ios:ops:notif</Scope>
<Scope>ios:ops:wipe</Scope>
<Scope>ios:ops:boolean-setting</Scope>
<Scope>ios:ops:wallpaper</Scope>
<Scope>ios:ops:app-attributes</Scope>
<Scope>ios:ops:app-conf</Scope>
<Scope>mac:ops:restart</Scope>
<Scope>mac:ops:shutdown</Scope>
<Scope>am:store:vpp:user:modify</Scope>
<Scope>am:store:vpp:user:view</Scope>
<Scope>am:store:vpp:assets:modify</Scope>
<Scope>am:store:vpp:assets:view</Scope>
<Scope>and:devices:enroll</Scope>
<Scope>ios:devices:enroll</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>device-mgt</Issuer>
</SSOConfiguration>
</UIConfiguration>

@ -670,3 +670,15 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING (
TRACCAR_USER_ID INT DEFAULT 0
);
-- END OF DM_EXT_PERMISSION_MAPPING TABLE--
-- METADATA TABLE --
CREATE TABLE IF NOT EXISTS DM_METADATA (
METADATA_ID INT AUTO_INCREMENT NOT NULL,
DATA_TYPE VARCHAR(16) NOT NULL,
METADATA_KEY VARCHAR(128) NOT NULL,
METADATA_VALUE TEXT NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (METADATA_ID),
CONSTRAINT METADATA_KEY_TENANT_ID UNIQUE (METADATA_KEY, TENANT_ID)
);
-- END OF METADATA TABLE --

Loading…
Cancel
Save