Esempio n. 1
0
        public async Task NetFramework_TenantFiltering_WrongTenantId()
        {
            Activity sampleActivity = JsonConvert.DeserializeObject <Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));

            HttpActionContext actionContext = new HttpActionContext();

            actionContext.ActionArguments.Add("Activity", sampleActivity);

            TenantFilterAttribute attribute = new TenantFilterAttribute();

            await attribute.OnActionExecutingAsync(actionContext, new System.Threading.CancellationToken());

            Assert.IsNotNull(actionContext.Response);
            Assert.AreEqual(actionContext.Response.StatusCode, System.Net.HttpStatusCode.Forbidden);
        }
Esempio n. 2
0
        public async Task NetFramework_TenantFiltering_AllowedTenantData()
        {
            Activity sampleActivity = JsonConvert.DeserializeObject <Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
            var      channelData    = JsonConvert.DeserializeObject <TeamsChannelData>(sampleActivity.ChannelData.ToString());

            channelData.Tenant.Id      = "a4183ce3-c577-4941-98f4-0787475fc266";
            sampleActivity.ChannelData = JObject.FromObject(channelData);
            HttpActionContext actionContext = new HttpActionContext();

            actionContext.ActionArguments.Add("Activity", sampleActivity);

            TenantFilterAttribute attribute = new TenantFilterAttribute();

            await attribute.OnActionExecutingAsync(actionContext, new System.Threading.CancellationToken());

            Assert.IsNull(actionContext.Response);
        }
Esempio n. 3
0
        public async Task NetFramework_TenantFiltering_MissingTenantData()
        {
            Activity sampleActivity = JsonConvert.DeserializeObject <Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
            var      channelData    = JsonConvert.DeserializeObject <TeamsChannelData>(sampleActivity.ChannelData.ToString());

            channelData.Tenant         = null;
            sampleActivity.ChannelData = JObject.FromObject(channelData);
            HttpActionContext actionContext = new HttpActionContext();

            actionContext.ActionArguments.Add("Activity", JObject.FromObject(sampleActivity));

            TenantFilterAttribute attribute = new TenantFilterAttribute();

            await attribute.OnActionExecutingAsync(actionContext, new System.Threading.CancellationToken());

            Assert.IsNotNull(actionContext.Response);
            Assert.AreEqual(actionContext.Response.StatusCode, System.Net.HttpStatusCode.Forbidden);
        }