Example #1
0
        public static Uri GetBaseSearchUri(
            this TestEnvironment environment,
            ExecutionMode executionMode,
            string searchServiceName)
        {
            EnvironmentNames envName =
                environment.LookupEnvironmentFromBaseUri(executionMode, environment.BaseUri.AbsoluteUri);

            string domain;

            switch (envName)
            {
            case EnvironmentNames.Dogfood:
                domain = "search-dogfood.windows-int.net";
                break;

            case EnvironmentNames.Next:
                domain = "search-next.windows-int.net";
                break;

            case EnvironmentNames.Current:
                domain = "search-current.windows-int.net";
                break;

            case EnvironmentNames.Prod:
            default:
                // Assume PROD if all else fails.
                domain = "search.windows.net";
                break;
            }

            string UriFormat = "https://{0}.{1}/";

            return(new Uri(String.Format(UriFormat, searchServiceName, domain)));
        }
Example #2
0
        List <EnvironmentResource> GetEnvironments(OctopusRepository repository)
        {
            var selectedEnvironments = repository.Environments.FindByNames(EnvironmentNames);

            var missing = EnvironmentNames.Except(selectedEnvironments.Select(e => e.Name), StringComparer.OrdinalIgnoreCase).ToList();

            if (missing.Any())
            {
                throw new ArgumentException($"Could not find the {"environment" + (missing.Count == 1 ? "" : "s")} {string.Join(", ", missing)} on the Octopus server.");
            }

            return(selectedEnvironments);
        }
Example #3
0
        List <EnvironmentResource> GetEnvironments(IOctopusSpaceRepository repository)
        {
            var selectedEnvironments = repository.Environments.FindByNames(EnvironmentNames);

            var missing = EnvironmentNames.Except(selectedEnvironments.Select(e => e.Name), StringComparer.OrdinalIgnoreCase).ToList();

            if (missing.Any())
            {
                throw new ArgumentException(CouldNotFindMessage("environment", missing.ToArray()));
            }

            return(selectedEnvironments);
        }
Example #4
0
        public static void AddMvcService(this IServiceCollection services, IHostingEnvironment hostingEnvironment, bool isAuthEnabled, ILoggerFactory loggerFactory)
        {
            services.AddAntiforgery(options =>
            {
                options.Cookie.Name   = CookieNames.AntiForgeryCookie;
                options.FormFieldName = "_csrfToken";
                options.HeaderName    = "X-XSRF-TOKEN";
            });
            services.Configure <CookieTempDataProviderOptions>(options => options.Cookie.Name = CookieNames.RecruitTempData);
            services.AddSingleton <ITempDataProvider, CookieTempDataProvider>();

            services.AddMvc(opts =>
            {
                if (!hostingEnvironment.IsDevelopment())
                {
                    opts.Filters.Add(new RequireHttpsAttribute());
                }

                if (!isAuthEnabled)
                {
                    opts.Filters.Add(new AllowAnonymousFilter());
                }
                else
                {
                    opts.Filters.Add(new AuthorizeFilter(HasEmployerAccountPolicyName));
                }

                var jsonInputFormatters = opts.InputFormatters.OfType <JsonInputFormatter>();
                foreach (var formatter in jsonInputFormatters)
                {
                    formatter.SupportedMediaTypes
                    .Add(MediaTypeHeaderValue.Parse("application/csp-report"));
                }

                opts.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());

                opts.Filters.Add(typeof(LevyDeclarationCheckFilter), 50);

                if (EnvironmentNames.GetTestEnvironmentNames().Contains(hostingEnvironment.EnvironmentName.ToUpper()) == false)
                {
                    opts.Filters.AddService <CheckEmployerBlockedFilter>();
                }

                opts.Filters.AddService <PlannedOutageResultFilter>();

                opts.AddTrimModelBinderProvider(loggerFactory);
            })
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <Startup>())
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
        protected override async Task ValidateParameters()
        {
            await base.ValidateParameters().ConfigureAwait(false);

            if (string.IsNullOrEmpty(ProjectName))
            {
                throw new CommandException("Please specify a project using the project parameter: --project=MyProject");
            }

            if (!EnvironmentNames.Any())
            {
                throw new CommandException(
                          "Please specify an environment using the environment parameter: --environment=MyEnvironment");
            }
        }
Example #6
0
        protected override void ValidateParameters()
        {
            base.ValidateParameters();

            if (string.IsNullOrEmpty(ProjectName))
            {
                throw new CommandException("Please specify a project using the project parameter: --project=MyProject");
            }

            if (!EnvironmentNames.Any())
            {
                throw new CommandException(
                          "Please specify an environment using the environment parameter: --environment=MyEnvironment");
            }
        }
Example #7
0
        public DeleteAutoDeployOverrideCommand(IOctopusAsyncRepositoryFactory repositoryFactory, ILogger log, IOctopusFileSystem fileSystem, IOctopusClientFactory octopusClientFactory) :
            base(octopusClientFactory, repositoryFactory, log, fileSystem)
        {
            var options = Options.For("Delete auto deploy release override");

            options.Add("project=", "Name of the project", v => ProjectName = v);
            options.Add("environment=",
                        "Name of an environment the override will apply to. Specify this argument multiple times to add multiple environments.",
                        v => EnvironmentNames.Add(v));
            options.Add("tenant=",
                        "[Optional] Name of a tenant the override will apply to. Specify this argument multiple times to add multiple tenants or use `*` wildcard for all tenants.",
                        t => TenantNames.Add(t));
            options.Add("tenanttag=",
                        "[Optional] A tenant tag used to match tenants that the override will apply to. Specify this argument multiple times to add multiple tenant tags",
                        tt => TenantTags.Add(tt));
        }
        public EnvironmentHeader(EnviromentMainForm parent_) : base(parent_)
        {
            this.Font   = Atiran.UI.WindowsForms.FontManager.GetFont("IRANSans", 11.5F, FontStyle.Bold);
            this.Height = 39;
            EnvParent   = parent_;
            this.Dock   = System.Windows.Forms.DockStyle.Top;
            Headertitle = EnvironmentNames.GetTitle(EnvParent.environment);

            if (parent_.environment != Connections.Enums.Definitions.EnvironmentNames.Login)
            {
                this.BackColor = System.Drawing.Color.FromArgb(120, 144, 156);
                FillRightPanel();
                FillLeftPanel();
            }
            parent_.Controls.Add(this);
        }
Example #9
0
        public DeleteAutoDeployOverrideCommand(IOctopusAsyncRepositoryFactory repositoryFactory, IOctopusFileSystem fileSystem, IOctopusClientFactory octopusClientFactory, ICommandOutputProvider commandOutputProvider) :
            base(octopusClientFactory, repositoryFactory, fileSystem, commandOutputProvider)
        {
            var options = Options.For("Delete auto deploy release override");

            options.Add("project=", "Name of the project", v => ProjectName = v);
            options.Add("environment=",
                        "Name of an environment the override will apply to. Specify this argument multiple times to add multiple environments.",
                        v => EnvironmentNames.Add(v));
            options.Add("tenant=",
                        "[Optional] Name of a tenant the override will apply to. Specify this argument multiple times to add multiple tenants or use `*` wildcard for all tenants.",
                        t => TenantNames.Add(t));
            options.Add("tenanttag=",
                        "[Optional] A tenant tag used to match tenants that the override will apply to. Specify this argument multiple times to add multiple tenant tags",
                        tt => TenantTags.Add(tt));

            deletedDeplomentOverrides = new List <Tuple <EnvironmentResource, TenantResource, DeletedOutcome> >();
        }
Example #10
0
        public static bool TryParse(string Environment, out EnvironmentNames Value)
        {
            Value = default(EnvironmentNames);
            if (string.IsNullOrWhiteSpace(Environment))
            {
                return(false);
            }
            string env = Environment.Trim().ToLower();

            foreach (var item in EnvironmentNames.Dev.GetList())
            {
                if (env == item.ToString().ToLower().Trim())
                {
                    Value = item;
                    return(true);
                }
            }
            return(false);
        }
Example #11
0
        public CreateAutoDeployOverrideCommand(IOctopusAsyncRepositoryFactory repositoryFactory, IOctopusFileSystem fileSystem, IOctopusClientFactory clientFactory, ICommandOutputProvider commandOutputProvider) :
            base(clientFactory, repositoryFactory, fileSystem, commandOutputProvider)
        {
            var options = Options.For("Auto deploy release override");

            options.Add <string>("project=", "Name of the project.", v => ProjectName = v);
            options.Add <string>("environment=",
                                 "Name of an environment the override will apply to. Specify this argument multiple times to add multiple environments.",
                                 v => EnvironmentNames.Add(v), allowsMultiple: true);
            options.Add <string>("version=|releaseNumber=", "Release number to use for auto deployments.",
                                 v => ReleaseVersionNumber = v);
            options.Add <string>("tenant=",
                                 "[Optional] Name of a tenant the override will apply to. Specify this argument multiple times to add multiple tenants or use `*` wildcard for all tenants.",
                                 t => TenantNames.Add(t), allowsMultiple: true);
            options.Add <string>("tenantTag=",
                                 "[Optional] A tenant tag used to match tenants that the override will apply to. Specify this argument multiple times to add multiple tenant tags",
                                 tt => TenantTags.Add(tt), allowsMultiple: true);

            createdDeploymentOverides = new List <Tuple <EnvironmentResource, TenantResource, CreatedOutcome> >();
        }
        /// <summary>
        /// Gets the fully-qualified domain name suffix of an Azure Search service for the given test environment and service name.
        /// </summary>
        /// <param name="environment">The test environment.</param>
        /// <param name="searchServiceName">The name of the search service.</param>
        /// <returns>The fully-qualified domain name of the search service in the given environment.</returns>
        public static string GetSearchDnsSuffix(this TestEnvironment environment, string searchServiceName)
        {
            EnvironmentNames envName = LookupEnvironmentFromBaseUri(environment.BaseUri.AbsoluteUri);

            switch (envName)
            {
            case EnvironmentNames.Dogfood:
                return("search-dogfood.windows-int.net");

            case EnvironmentNames.Next:
                return("search-next.windows-int.net");

            case EnvironmentNames.Current:
                return("search-current.windows-int.net");

            case EnvironmentNames.Prod:
            default:
                // Assume PROD if all else fails.
                return("search.windows.net");
            }
        }
Example #13
0
        async Task <List <EnvironmentResource> > GetEnvironments(IOctopusSpaceAsyncRepository repository)
        {
            var selectedEnvironments = new List <EnvironmentResource>();

            foreach (var environmentName in EnvironmentNames)
            {
                var environment = await repository.Environments.FindByName(environmentName).ConfigureAwait(false);

                if (environment != null)
                {
                    selectedEnvironments.Add(environment);
                }
            }

            var missing = EnvironmentNames.Except(selectedEnvironments.Select(e => e.Name), StringComparer.OrdinalIgnoreCase).ToList();

            if (missing.Any())
            {
                throw new ArgumentException(CouldNotFindMessage("environment", missing.ToArray()));
            }

            return(selectedEnvironments);
        }
Example #14
0
 public EnvironmentConnection(EnvironmentNames Environment, string ConnectionString)
 {
     this.Environment      = Environment;
     this.ConnectionString = ConnectionString;
 }
Example #15
0
        public TestEnvironment(IDictionary <string, string> connection)
        {
            this.TokenInfo = new Dictionary <TokenAudience, TokenCredentials>();
            // Instantiate dictionary of parameters
            RawParameters = new Dictionary <string, string>();
            // By default set env to Prod
            this.Endpoints = TestEnvironment.EnvEndpoints[EnvironmentDefault];

            this.BaseUri  = this.Endpoints.ResourceManagementUri;
            this.ClientId = TestEnvironment.ClientIdDefault;
            this.Tenant   = TestEnvironment.AADTenantDefault;

            if (connection != null)
            {
                if (connection.ContainsKey(TestEnvironment.UserIdKey))
                {
                    this.UserName = connection[TestEnvironment.UserIdKey];
                    var splitUser = this.UserName.Split(new [] { '@' }, StringSplitOptions.RemoveEmptyEntries);
                    if (splitUser.Length == 2)
                    {
                        this.Tenant = splitUser[1];
                    }
                }
                if (connection.ContainsKey(TestEnvironment.ServicePrincipalKey))
                {
                    this.ServicePrincipal = connection[TestEnvironment.ServicePrincipalKey];
                }
                if (connection.ContainsKey(TestEnvironment.AADTenantKey))
                {
                    this.Tenant = connection[TestEnvironment.AADTenantKey];
                }
                if (connection.ContainsKey(TestEnvironment.SubscriptionIdKey))
                {
                    this.SubscriptionId = connection[TestEnvironment.SubscriptionIdKey];
                }
                if (connection.ContainsKey(TestEnvironment.ClientIdKey))
                {
                    this.ClientId = connection[TestEnvironment.ClientIdKey];
                }
                if (connection.ContainsKey(TestEnvironment.EnvironmentKey))
                {
                    if (ConnectionStringContainsEndpoint(connection))
                    {
                        throw new ArgumentException("Invalid connection string, can contain endpoints or environment but not both",
                                                    "connection");
                    }

                    var envNameString = connection[TestEnvironment.EnvironmentKey];

                    EnvironmentNames envName;
                    if (!Enum.TryParse <EnvironmentNames>(envNameString, out envName))
                    {
                        throw new Exception(
                                  string.Format("Environment \"{0}\" is not valid", envNameString));
                    }

                    this.Endpoints = TestEnvironment.EnvEndpoints[envName];
                    //need to set the right baseUri
                    this.BaseUri = this.Endpoints.ResourceManagementUri;
                }
                if (connection.ContainsKey(TestEnvironment.BaseUriKey))
                {
                    var baseUriString = connection[TestEnvironment.BaseUriKey];
                    this.BaseUri = new Uri(baseUriString);
                    if (!connection.ContainsKey(TestEnvironment.EnvironmentKey))
                    {
                        EnvironmentNames envName = LookupEnvironmentFromBaseUri(baseUriString);
                        this.Endpoints = TestEnvironment.EnvEndpoints[envName];
                    }
                }
                if (connection.ContainsKey(ConnectionStringFields.AADAuthenticationEndpoint))
                {
                    this.Endpoints.AADAuthUri = new Uri(connection[ConnectionStringFields.AADAuthenticationEndpoint]);
                }
                if (connection.ContainsKey(ConnectionStringFields.GraphUri))
                {
                    this.Endpoints.GraphUri = new Uri(connection[ConnectionStringFields.GraphUri]);
                }
                if (connection.ContainsKey(ConnectionStringFields.GalleryUri))
                {
                    this.Endpoints.GalleryUri = new Uri(connection[ConnectionStringFields.GalleryUri]);
                }
                if (connection.ContainsKey(ConnectionStringFields.IbizaPortalUri))
                {
                    this.Endpoints.IbizaPortalUri = new Uri(connection[ConnectionStringFields.IbizaPortalUri]);
                }
                if (connection.ContainsKey(ConnectionStringFields.RdfePortalUri))
                {
                    this.Endpoints.RdfePortalUri = new Uri(connection[ConnectionStringFields.RdfePortalUri]);
                }
                if (connection.ContainsKey(ConnectionStringFields.DataLakeStoreServiceUri))
                {
                    this.Endpoints.DataLakeStoreServiceUri = new Uri(connection[ConnectionStringFields.DataLakeStoreServiceUri]);
                }
                if (connection.ContainsKey(ConnectionStringFields.DataLakeAnalyticsJobAndCatalogServiceUri))
                {
                    this.Endpoints.DataLakeAnalyticsJobAndCatalogServiceUri = new Uri(connection[ConnectionStringFields.DataLakeAnalyticsJobAndCatalogServiceUri]);
                }
                RawParameters = connection;
            }
        }
 public void GetNonProdEnvironmentNamesShouldNotIncludeProd()
 {
     Regex.IsMatch(EnvironmentNames.GetNonProdEnvironmentNamesCommaDelimited(), @"(?<!PRE)PROD\b").Should().BeFalse();
 }
 public void GetNonProdEnvironmentNamesShouldIncludeEveryNonProdEnvironment()
 {
     EnvironmentNames.GetNonProdEnvironmentNamesCommaDelimited().Should().Be("DEVELOPMENT,AT,TEST,TEST2,DEMO,PREPROD");
 }
Example #18
0
        /// <summary>
        /// Creates comma seperated string of all EnvironmentNames enum values
        /// </summary>
        /// <param name="env"></param>
        /// <returns></returns>
        public static string ListValues(this EnvironmentNames env)
        {
            List <string> enumValues = (from ev in typeof(EnvironmentNames).GetMembers(BindingFlags.Public | BindingFlags.Static) select ev.Name).ToList();

            return(string.Join(",", enumValues.Select((item) => item)));
        }
        internal TestEndpoints(EnvironmentNames testEnvName)
        {
            string _defaultAADTokenAudienceUri      = @"https://management.core.windows.net/";
            string _defaultGraphTokenAudienceUri    = @"https://graph.windows.net/";
            string _defaultPPEGraphTokenAudienceUri = @"https://graph.ppe.windows.net/";

            #region environment switch
            switch (testEnvName)
            {
            case EnvironmentNames.Prod:
            {
                #region
                Name                    = EnvironmentNames.Prod;
                AADAuthUri              = new Uri("https://login.microsoftonline.com");
                GalleryUri              = new Uri("https://gallery.azure.com/");
                GraphUri                = new Uri("https://graph.windows.net/");
                IbizaPortalUri          = new Uri("https://portal.azure.com/");
                RdfePortalUri           = new Uri("http://go.microsoft.com/fwlink/?LinkId=254433");
                ResourceManagementUri   = new Uri("https://management.azure.com/");
                ServiceManagementUri    = new Uri("https://management.core.windows.net");
                AADTokenAudienceUri     = new Uri(_defaultAADTokenAudienceUri);
                GraphTokenAudienceUri   = new Uri(_defaultGraphTokenAudienceUri);
                DataLakeStoreServiceUri = new Uri("https://azuredatalakestore.net");
                DataLakeAnalyticsJobAndCatalogServiceUri = new Uri("https://azuredatalakeanalytics.net");
                break;
                #endregion
            }

            case EnvironmentNames.Dogfood:
            {
                #region
                Name                    = EnvironmentNames.Dogfood;
                AADAuthUri              = new Uri("https://login.windows-ppe.net");
                GalleryUri              = new Uri("https://df.gallery.azure-test.net/");
                GraphUri                = new Uri("https://graph.ppe.windows.net/");
                IbizaPortalUri          = new Uri("http://df.onecloud.azure-test.net");
                RdfePortalUri           = new Uri("https://windows.azure-test.net");
                ResourceManagementUri   = new Uri("https://api-dogfood.resources.windows-int.net/");
                ServiceManagementUri    = new Uri("https://management-preview.core.windows-int.net");
                AADTokenAudienceUri     = new Uri(_defaultAADTokenAudienceUri);
                GraphTokenAudienceUri   = new Uri(_defaultPPEGraphTokenAudienceUri);
                DataLakeStoreServiceUri = new Uri("https://caboaccountdogfood.net");
                DataLakeAnalyticsJobAndCatalogServiceUri = new Uri("https://konaaccountdogfood.net");
                break;
                #endregion
            }

            case EnvironmentNames.Next:
            {
                #region
                Name                    = EnvironmentNames.Next;
                AADAuthUri              = new Uri("https://login.windows-ppe.net");
                GalleryUri              = new Uri("https://next.gallery.azure-test.net/");
                GraphUri                = new Uri("https://graph.ppe.windows.net/");
                IbizaPortalUri          = new Uri("http://next.onecloud.azure-test.net");
                RdfePortalUri           = new Uri("https://auxnext.windows.azure-test.net");
                ResourceManagementUri   = new Uri("https://api-next.resources.windows-int.net/");
                ServiceManagementUri    = new Uri("https://managementnext.rdfetest.dnsdemo4.com");
                AADTokenAudienceUri     = new Uri(_defaultAADTokenAudienceUri);
                GraphTokenAudienceUri   = new Uri(_defaultPPEGraphTokenAudienceUri);
                DataLakeStoreServiceUri = new Uri("https://caboaccountdogfood.net");                  // TODO: change once a "next" environment is published
                DataLakeAnalyticsJobAndCatalogServiceUri = new Uri("https://konaaccountdogfood.net"); // TODO: change once a "next" environment is published
                break;
                #endregion
            }

            case EnvironmentNames.Current:
            {
                #region
                Name                    = EnvironmentNames.Current;
                AADAuthUri              = new Uri("https://login.windows-ppe.net");
                GalleryUri              = new Uri("https://current.gallery.azure-test.net/");
                GraphUri                = new Uri("https://graph.ppe.windows.net/");
                IbizaPortalUri          = new Uri("http://current.onecloud.azure-test.net");
                RdfePortalUri           = new Uri("https://auxcurrent.windows.azure-test.net");
                ResourceManagementUri   = new Uri("https://api-current.resources.windows-int.net/");
                ServiceManagementUri    = new Uri("https://management.rdfetest.dnsdemo4.com");
                AADTokenAudienceUri     = new Uri(_defaultAADTokenAudienceUri);
                GraphTokenAudienceUri   = new Uri(_defaultPPEGraphTokenAudienceUri);
                DataLakeStoreServiceUri = new Uri("https://caboaccountdogfood.net");                  // TODO: change once a "Current" environment is published
                DataLakeAnalyticsJobAndCatalogServiceUri = new Uri("https://konaaccountdogfood.net"); // TODO: change once a "Current" environment is published
                break;
                #endregion
            }

            case EnvironmentNames.Custom:
            {
                #region
                Name = EnvironmentNames.Custom;
                break;
                #endregion
            }
            }
            #endregion
        }
 /// <summary>
 /// Constructor updates endpoint URI that matches Environment names with supplied URI's in connection string
 /// </summary>
 /// <param name="envName">EnvironmentName</param>
 /// <param name="connStr">ConnectionString object</param>
 internal TestEndpoints(EnvironmentNames envName, ConnectionString connStr) : this(envName)
 {
     UpdateEnvironmentEndpoint(connStr);
 }