Exemplo n.º 1
0
        public void GetDeviceDetailsByAssetUID_ApplicationToken_OtherThanKiewit_NoAccess()
        {
            var deviceUid = Guid.NewGuid();
            List <AssetDevicePropertiesV2> retList = new List <AssetDevicePropertiesV2>();

            retList.Add(new AssetDevicePropertiesV2 {
                DeviceUID = deviceUid, DeviceType = "PL641", DeviceState = 1
            });
            _deviceService.GetDevicePropertiesV2ByAssetGuid(Arg.Any <Guid>()).Returns(retList);
            _deviceService.GetCustomersForApplication(Arg.Any <string>()).Returns(new List <Guid> {
                Guid.NewGuid()
            });;

            _target.ControllerContext.HttpContext.Request.Headers["UserUID_APIRequest"] = Guid.NewGuid().ToString();

            var aa = TPaaSJWT.GenerateFakeApplicationJWT("MasterDataManagement");

            var result = _target.GetDeviceDetailsByAssetUID(deviceUid, aa.EncodedJWT);


            //Assert
            Assert.Equal(typeof(BadRequestObjectResult), result.GetType());
            _deviceService.Received(0).GetDevicePropertiesV2ByAssetGuid(Arg.Any <Guid>());
            Assert.Equal("Application does not have Access. Please contact your API administrator.", ((BadRequestObjectResult)result).Value);
        }
Exemplo n.º 2
0
        public void GetDeviceDetailsByAssetUID_ApplicationToken_Kiewit_Success()
        {
            var assetUID = Guid.NewGuid();
            List <AssetDevicePropertiesV2> retList = new List <AssetDevicePropertiesV2>();

            retList.Add(new AssetDevicePropertiesV2 {
                DeviceUID = assetUID, DeviceType = "PL641", DeviceState = 1
            });
            _deviceService.GetDevicePropertiesV2ByAssetGuid(Arg.Any <Guid>()).Returns(retList);
            _deviceService.GetCustomersForApplication(Arg.Any <string>()).Returns(new List <Guid> {
                new Guid("E6E2F851-44C5-E311-AA77-00505688274D")
            });

            _target.ControllerContext.HttpContext.Request.Headers["UserUID_APIRequest"] = Guid.NewGuid().ToString();

            var aa = TPaaSJWT.GenerateFakeApplicationJWT("MasterDataManagement");

            var result = _target.GetDeviceDetailsByAssetUID(assetUID, aa.EncodedJWT);


            //Assert
            Assert.Equal(typeof(OkObjectResult), result.GetType());
            Assert.IsType <OkObjectResult>(result);
            _deviceService.Received(1).GetDevicePropertiesV2ByAssetGuid(Arg.Any <Guid>());
        }
Exemplo n.º 3
0
        public void CanGenerateFakeApplicationJWTFromAcceptanceTests()
        {
            var jwt = TPaaSJWT.GenerateFakeApplicationJWT("MyApplication");

            Assert.Equal("MyApplication", jwt.ApplicationName);
            Assert.False(jwt.IsApplicationUserToken);
            Assert.True(jwt.IsApplicationToken);
        }