Beispiel #1
0
        public async Task CustomerProjectValidation_HappyPath_CacheSimulation()
        {
            var log = serviceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <ValidationTests>();

            var projectProxy = new Mock <IProjectProxy>();
            var projectData  = new ProjectData {
                ProjectUID = projectUid, CustomerUID = custUid
            };
            var projects = new List <ProjectData> {
                projectData
            };

            var customHeaders = new HeaderDictionary();

            projectProxy.SetupSequence(ps => ps.GetProjects(It.IsAny <string>(), customHeaders))
            .ReturnsAsync(new List <ProjectData>())
            .ReturnsAsync(projects);

            FilterPrincipal principal = new FilterPrincipal(new System.Security.Claims.ClaimsIdentity(),
                                                            custUid, string.Empty, string.Empty, false, projectProxy.Object, customHeaders);

            var actual = await principal.GetProject(projectUid);

            Assert.Equal(projectData, actual);
        }
Beispiel #2
0
        public async Task CustomerProjectValidation_NoAssociation()
        {
            var log = serviceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <ValidationTests>();

            var projectProxy  = new Mock <IProjectProxy>();
            var customHeaders = new HeaderDictionary();

            projectProxy.Setup(ps => ps.GetProjectForCustomer(It.IsAny <string>(), It.IsAny <string>(), customHeaders))
            .ReturnsAsync((ProjectData)null);

            FilterPrincipal principal = new FilterPrincipal(new System.Security.Claims.ClaimsIdentity(),
                                                            custUid, string.Empty, string.Empty, false, projectProxy.Object, customHeaders);

            var ex = await Assert.ThrowsAsync <ServiceException>(() => principal.GetProject(projectUid));

            Assert.Contains("-5", ex.GetContent);
            Assert.Contains("Missing Project or project does not belong to customer", ex.GetContent);
        }