Exemple #1
0
        public void ShouldCreateProductPolicyTemplateResourceFromCreatorConfigWithCorrectContent()
        {
            // arrange
            PolicyTemplateCreator policyTemplateCreator = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            CreatorConfig         creatorConfig         = new CreatorConfig()
            {
                products = new List <ProductConfig>()
            };
            ProductConfig product = new ProductConfig()
            {
                displayName          = "displayName",
                description          = "description",
                terms                = "terms",
                subscriptionRequired = true,
                approvalRequired     = true,
                subscriptionsLimit   = 1,
                state                = "state",
                policy               = "http://someurl.com"
            };

            creatorConfig.products.Add(product);
            string[] dependsOn = new string[] { "dependsOn" };

            // act
            PolicyTemplateResource policyTemplateResource = policyTemplateCreator.CreateProductPolicyTemplateResource(product, dependsOn);

            // assert
            Assert.Equal($"[concat(parameters('apimServiceName'), '/{product.displayName}/policy')]", policyTemplateResource.name);
            Assert.Equal("rawxml-link", policyTemplateResource.properties.format);
            Assert.Equal(product.policy, policyTemplateResource.properties.value);
            Assert.Equal(dependsOn, policyTemplateResource.dependsOn);
        }
Exemple #2
0
        public void ShouldCreateAPIPolicyTemplateResourceFromCreatorConfigWithCorrectContent()
        {
            // arrange
            PolicyTemplateCreator policyTemplateCreator = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            CreatorConfig         creatorConfig         = new CreatorConfig()
            {
                apis = new List <APIConfig>()
            };
            APIConfig api = new APIConfig()
            {
                name   = "name",
                policy = "http://someurl.com"
            };

            creatorConfig.apis.Add(api);
            string[] dependsOn = new string[] { "dependsOn" };

            // act
            PolicyTemplateResource policyTemplateResource = policyTemplateCreator.CreateAPIPolicyTemplateResource(api, dependsOn);

            // assert
            Assert.Equal($"[concat(parameters('apimServiceName'), '/{api.name}/policy')]", policyTemplateResource.name);
            Assert.Equal("rawxml-link", policyTemplateResource.properties.format);
            Assert.Equal(api.policy, policyTemplateResource.properties.value);
            Assert.Equal(dependsOn, policyTemplateResource.dependsOn);
        }
        public static ProductTemplateCreator GenerateProductTemplateCreator()
        {
            PolicyTemplateCreator  policyTemplateCreator  = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            ProductTemplateCreator productTemplateCreator = new ProductTemplateCreator(policyTemplateCreator);

            return(productTemplateCreator);
        }
        public static ProductTemplateCreator GenerateProductTemplateCreator()
        {
            PolicyTemplateCreator       policyTemplateCreator               = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            ProductGroupTemplateCreator productGroupTemplateCreator         = new ProductGroupTemplateCreator();
            SubscriptionTemplateCreator productSubscriptionsTemplateCreator = new SubscriptionTemplateCreator();
            ProductTemplateCreator      productTemplateCreator              = new ProductTemplateCreator(policyTemplateCreator, productGroupTemplateCreator, productSubscriptionsTemplateCreator);

            return(productTemplateCreator);
        }
Exemple #5
0
        public void ShouldCreateGlobalServicePolicyTemplateResourceFromCreatorConfigWithCorrectContent()
        {
            // arrange
            PolicyTemplateCreator policyTemplateCreator = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            CreatorConfig         creatorConfig         = new CreatorConfig()
            {
                policy = "http://someurl.com"
            };

            // act
            Template policyTemplate = policyTemplateCreator.CreateGlobalServicePolicyTemplate(creatorConfig);
            PolicyTemplateResource policyTemplateResource = policyTemplate.resources[0] as PolicyTemplateResource;

            // assert
            Assert.Equal($"[concat(parameters('apimServiceName'), '/policy')]", policyTemplateResource.name);
            Assert.Equal("rawxml-link", policyTemplateResource.properties.format);
            Assert.Equal(creatorConfig.policy, policyTemplateResource.properties.value);
        }
Exemple #6
0
        public void ShouldCreateOperationPolicyTemplateResourceFromPairWithCorrectContent()
        {
            // arrange
            PolicyTemplateCreator policyTemplateCreator        = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator();
            KeyValuePair <string, OperationsConfig> policyPair = new KeyValuePair <string, OperationsConfig>("key", new OperationsConfig()
            {
                policy = "http://someurl.com"
            });
            string apiName = "apiName";

            string[] dependsOn = new string[] { "dependsOn" };

            // act
            PolicyTemplateResource policyTemplateResource = policyTemplateCreator.CreateOperationPolicyTemplateResource(policyPair, apiName, dependsOn);

            // assert
            Assert.Equal($"[concat(parameters('apimServiceName'), '/{apiName}/{policyPair.Key}/policy')]", policyTemplateResource.name);
            Assert.Equal("rawxml-link", policyTemplateResource.properties.format);
            Assert.Equal(policyPair.Value.policy, policyTemplateResource.properties.value);
            Assert.Equal(dependsOn, policyTemplateResource.dependsOn);
        }