Exemple #1
0
        public void RequestWithEnvironment_Specified()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoEnvironment")), "Gate with no environment restrictions should be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ReqEnvironment")), "Gate with environment restrictions should be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("DogfoodApps")), "Gate with environment restrictions and no client version restrictions should be applicable");
        }
Exemple #2
0
        public void IsGateApplicable_GateWithDates_ReturnCorrectly()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("CorrectDate")), "Gate with correct dates should be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("BeforeStartDate")), "Gate Before Start Date should  ot be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("AfterEndDate")), "Gate after end date should not be applicable");
        }
Exemple #3
0
        public void RequestWithCloudContext_Specified()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 8, cloudContext: new HashSet <string> {
                "Public"
            });
            GateContext context = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.CloudContextPublic")), "Gate with cloud context restrictions should be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.CloudContextSovereign")), "Gate with different cloud context restrictions should not be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("DogfoodApps")), "Gate without a cloud context should be applicable");
        }
Exemple #4
0
        public void IsGateApplicable_GateWithAppAudienceGroup_ReturnsNotApplicable()
        {
            HashSet <string> audienceGroups = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
            {
                "AppLoop"
            };

            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.0.0.0", "en-us", null, 0, audienceGroups);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoEnvironment")), "Gate should not be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.LoopUser")), "Gate should not be applicable for audience group.");
        }
Exemple #5
0
        public void IsGateApplicable_GateRequestWithRequestedGates_ReturnsApplicable()
        {
            HashSet <string> requestedGates = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
            {
                "MyProduct.Test.DogfoodUsers",
                "MyProduct.Test.LiveIdUser",
            };

            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0, null, requestedGates);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.NoUsers")), "Gate disabled for all users should not be applicable");
            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.OrgIdUser")), "Gate enabled for OrgId users should not be applicable");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.DogfoodUsers")), "Requested gate enabled for Dogfood users should be applicable.");
            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.LiveIdUser")), "Requested gate enabled for LiveId users should be applicable.");
        }
Exemple #6
0
        public void IsGateApplicable_RequestNotMadeFromBrowserWithGateBlockingBrowsers_ReturnsApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest("BrowserFive", -1);
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedBrowsers.Browsers")),
                        "If request is not made from a browser and gate is blocking access for certain browsers, context should return applicable");
        }
Exemple #7
0
        public void IsGateApplicable_ForNoServiceDescribedInGateOnRetailerService_ReturnsGateToBeNotApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ServicesWithOutAnyService")),
                         "Gate should not be applicable when service tag doesn't have any service");
        }
Exemple #8
0
        public void IsGateApplicable_OnSupplyChainServiceWithNoneServiceFlag_ReturnsGateToBeNotApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceFive"), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                         "Gate should be not applicable for supplychain service as service flag is set to none.");
        }
Exemple #9
0
        public void IsGateApplicable_OnDataStoreService_ReturnsGateToBeApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceFour"), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                        "Gate should be applicable for datastore service.");
        }
Exemple #10
0
        public void IsGateApplicable_GateWithNonCompatibleBlockedBrowserVersion_ReturnsApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedBrowsers.NonCompatibleBrowserVersion")),
                        "Gate having non compatible blocked browser version should be applicable.");
        }
Exemple #11
0
        public void IsGateApplicable_GateWithCompatibleBlockedBrowserAndVersion_ReturnsNotApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedBrowsers.Browsers")),
                         "Gate having compatible blocked browser should not be applicable.");
        }
Exemple #12
0
        public void IsGateApplicable_GateWithBlockedBrowserButNoVersion_ReturnsNotApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedBrowsers.NoBlockedBrowserVersion")),
                         "Gate having no browser version constraint should be not applicable as the browser is blocked for all versions.");
        }
Exemple #13
0
        public void IsGateApplicable_RequestNotMadeFromBrowserWithGateExpectingBrowsers_ReturnsNotApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest("BrowserFive", -1);
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BrowserType.Browsers")),
                         "If request is not made from a browser and gate is active only for certain browsers, context should return not applicable");
        }
Exemple #14
0
        public void IsGateApplicable_WhenGateIsDisabled_ReturnFalse()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.DisabledGate")),
                         "Gate is disabled through the enabled flag in the xml.");
        }
Exemple #15
0
        public void IsGateApplicable_GateWithBrowserButNoVersion_ReturnsApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();
            GateContext          context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BrowserType.NoBrowserVersion")),
                        "Gate having no browser version constraint should be applicable.");
        }
Exemple #16
0
        public void IsGateApplicable_OnCoSubRetailerCanaryService_ReturnsGateToBeApplicable()
        {
            IGatedRequest gateRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", null, 0);
            GateContext   context     = new GateContext(gateRequest, new UnitTestMachineInformation("ServiceTwo", true), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.Services")),
                        "Gate should not be applicable for cosubretailer canary service.");
        }
Exemple #17
0
        public void IsGateApplicable_EnablingDisabledGateThroughSettingsForApplicableGate_ReturnsTrue()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext(), null,
                                                         new UnitTestGateSettings(null, null, new List <string> {
                "MyProduct.Test.ApplicableDisabledGate"
            }));

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.ApplicableDisabledGate")),
                        "Disabled gate enabled through settings and after applicablity check is returned as applicable.");
        }
Exemple #18
0
        public void IsGateApplicable_GateWithDisabledSetting_ReturnFalse()
        {
            IGatedRequest gatedRequest = SetupGatedRequest("ClientOne", "16.3.0.0", "en-us", "PreProduction", 0);
            GateContext   context      = new GateContext(gatedRequest, new UnitTestMachineInformation(), new DefaultExperimentContext(), null,
                                                         new UnitTestGateSettings(null, new List <string> {
                "MyProduct.Test.EnabledGate"
            }));

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.EnabledGate")),
                         "Gate explicitly disabled should not be applicable.");
        }
Exemple #19
0
        public void IsGateApplicable_RequestWithNoParametersAndGateWithBlockedQueryParameters_ReturnsApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >();

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.WithBlockedQueryParameters")),
                        "Gate having some BlockedQueryParameters constraint should be applicable when the request has no query parameters.");
        }
Exemple #20
0
        public void IsGateApplicable_GateWithEmptyValueBlockedQueryParameterConstraint_ReturnsApplicableAsItIsSkipped()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >()
            {
                { "name", new HashSet <string>()
                  {
                      "value"
                  } }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.WithEmptyValue")),
                        "Gate having BlockedQueryParameters constraint with an empty value is ignored");
        }
Exemple #21
0
        public void IsGateApplicable_GateWithSomeBlockedQueryParameterConstraints_ReturnsNotApplicableWhenUseingValueWildCard()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >()
            {
                { "name3", new HashSet <string>()
                  {
                      "value"
                  } }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.WithBlockedQueryParameters")),
                         "Gate having BlockedQueryParameters constraint with a wild card should block all requests with that query parameter name");
        }
Exemple #22
0
        public void IsGateApplicable_GateWithSomeBlockedQueryParameterConstraints_ReturnsApplicableWhenBlockedParametersAreNotPresent()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >()
            {
                { "name1", new HashSet <string>()
                  {
                      "value1"
                  } }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.WithBlockedQueryParameters")),
                        "Gate having BlockedQueryParameters constraint but not matched in the request should be applicable");
        }
Exemple #23
0
        public void IsGateApplicable_WithUserNotInGroupOrgIdList_ReturnsGateNotApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest
            {
                Users = new[]
                {
                    new GatedUser {
                        IsDogfoodUser = false, UserIdentifier = "*****@*****.**"
                    }
                }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.GroupOrgId")),
                         "Gate should not be applicable for user not in the group OrgId list.");
        }
Exemple #24
0
        public void IsGateApplicable_WithUserInSpecificOrgIdList_ReturnsGateApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest
            {
                Users = new[]
                {
                    new GatedUser {
                        IsDogfoodUser = false, UserIdentifier = "*****@*****.**"
                    }
                }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.SpecificOrgId")),
                        "Gate should be applicable for user in the specific OrgId list.");
        }
Exemple #25
0
        public void IsGateApplicable_GateWithSomeBlockedQueryParameterConstraints_ReturnsNotApplicableWhenBlockedParameterPresentWithDifferentCasing()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >()
            {
                { "nAMe2", new HashSet <string>()
                  {
                      "vaLue2"
                  } }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.False(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.WithBlockedQueryParameters")),
                         "Gate having BlockedQueryParameters constraint with different casing to the query parameter in the request should be not applicable.");
        }
Exemple #26
0
        public void IsGateApplicable_GateWithEmptyBlockedQueryParameterConstraints_ReturnsApplicable()
        {
            UnitTestGatedRequest request = new UnitTestGatedRequest();

            request.QueryParameters = new Dictionary <string, HashSet <string> >()
            {
                { "name1", new HashSet <string>()
                  {
                      "value1"
                  } }, { "name2", new HashSet <string>()
                         {
                             "value2"
                         } }
            };

            GateContext context = new GateContext(request, new UnitTestMachineInformation(), new DefaultExperimentContext());

            Assert.True(context.IsGateApplicable(m_dataset.GetGate("MyProduct.Test.BlockedQueryParameters.EmptyBlockedQueryParameters")),
                        "Gate having empty BlockedQueryParameters constraint should be applicable.");
        }