示例#1
0
        /// <summary>
        /// Extracts the required resources for integration testing.
        /// </summary>
        public static void ExtractRequiredResources()
        {
            Assembly thisAssembly = Assembly.GetExecutingAssembly();
            string   sourceName   = "IntegrationTesting.EmbeddedResources.";

            // Checks if the target folder exists:
            if (!Directory.Exists(_localPath))
            {
                Directory.CreateDirectory(_localPath);
            }

            // Extract the test project file:
            TestProjectFile = _localPath + _TestProjectFileName;
#if RVT2010
            sourceName += _TestProjectSrc2010;
#elif RVT2011
            sourceName += _TestProjectSrc2011;
#elif RVT2012
            sourceName += _TestProjectSrc2012;
#elif RVT2013
            sourceName += _TestProjectSrc2013;
#endif
            if (!File.Exists(TestProjectFile))
            {
                File.Create(TestProjectFile).Close();
                ACLHelper.ExtractResourceFileFromAssembly(thisAssembly, sourceName, TestProjectFile);
            }
        }
示例#2
0
        public ActionResult NewSuperUser(NewSuperUserDTO input)
        {
            // Check that the API KEY is correct to the one supplied in environment files
            if (!ValidAPIKey(input.APIKey))
            {
                return(StatusCode(StatusCodes.Status403Forbidden, new GenericReturnMessageDTO {
                    Status = 403, Message = ErrorMessages.APIKeyIncorrect
                }));
            }

            if (input.Host == null)
            {
                input.Host = "*";
            }

            var superUserEntries = new List <AccessControlEntryDTO>()
            {
                // This one gives the user access to all topics in the cluster as there is wildcard matching on topic and host (if host hasn't been defined)
                new AccessControlEntryDTO
                {
                    PrincipalName  = input.PrincipalName,
                    ResourceType   = ResourceType.Topic,
                    PatternType    = PatternType.Literal,
                    ResourceName   = "*",
                    Operation      = OperationType.All,
                    PermissionType = PermissionType.Allow,
                    Host           = input.Host
                },
                // This one gives the user acccess to create topics in the cluster
                new AccessControlEntryDTO
                {
                    PrincipalName  = input.PrincipalName,
                    ResourceType   = ResourceType.Cluster,
                    PatternType    = PatternType.Literal,
                    ResourceName   = "kafka-cluster",
                    Operation      = OperationType.Create,
                    PermissionType = PermissionType.Allow,
                    Host           = input.Host
                },
                // This one makes sure that the users group doesn't matter. No matter what group the user is in, they will still be able to access all topics and create topics
                new AccessControlEntryDTO
                {
                    PrincipalName  = input.PrincipalName,
                    ResourceType   = ResourceType.Group,
                    PatternType    = PatternType.Literal,
                    ResourceName   = "*",
                    Operation      = OperationType.All,
                    PermissionType = PermissionType.Allow,
                    Host           = input.Host
                }
            };

            ACLHelper.AddEntries(superUserEntries);

            return(StatusCode(StatusCodes.Status201Created, new GenericReturnMessageDTO
            {
                Status = 201,
                Message = SuccessMessages.SuperUserCreated
            }));
        }