Пример #1
0
        public void ToString_ReturnsUrl_GivenUrl()
        {
            var url = "url";
            var sut = new RepositoryUrl(url);

            Assert.Equal(url, sut.ToString());
        }
Пример #2
0
        public void Equality_RepositoryUrlsEqualEachOther_GivenTwoIdenticalUrls()
        {
            var url      = "url";
            var sut      = new RepositoryUrl(url);
            var expected = new RepositoryUrl(url);

            Assert.Equal(expected, sut);
        }
Пример #3
0
 public DataAnalysisPipeline(
     IFileCopier fileCopier,
     RepositoryUrl repositoryUrl,
     RepositoryDestination repositoryDestination)
 {
     _fileCopier            = fileCopier;
     _repositoryUrl         = repositoryUrl;
     _repositoryDestination = repositoryDestination;
 }
Пример #4
0
        public override int GetHashCode()
        {
            unchecked {
                var hashCode = RepositoryUrl != null?RepositoryUrl.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Params.GetHashCode();
                return(hashCode);
            }
        }
Пример #5
0
        public void Should_PassRepositoryUrlToPipeline_When_UrlGiven()
        {
            var url = new RepositoryUrl("url");
            var sut = new PipelineFactory(Mock.Of <IFileCopier>());

            DataAnalysisPipeline result = (DataAnalysisPipeline)sut.CreateDataAnalysisPipeline(
                url,
                new RepositoryDestination("Destination"));

            Assert.Same(url, result.RepositoryUrl);
        }
Пример #6
0
        public Uri toUri()
        {
            var url = RepositoryUrl
                      .AppendPathSegment("packages")
                      .AppendPathSegment(Id);

            if (Params.HasValue)
            {
                url.SetQueryParam("channel", Params.Value.Channel);
                url.SetQueryParam("platform", Params.Value.Platform);
                url.SetQueryParam("arch", Params.Value.Arch);
                url.SetQueryParam("version", Params.Value.Version);
            }

            return(url.ToUri());
        }
        public CloneGitRepositoryCommand(
            RepositoryUrl repositoryUrl,
            RepositoryDestination repositoryDestination)
        {
            if (repositoryUrl == null)
            {
                throw new ArgumentNullException(nameof(repositoryUrl));
            }

            if (repositoryDestination == null)
            {
                throw new ArgumentNullException(nameof(repositoryDestination));
            }

            _repositoryUrl         = repositoryUrl;
            _repositoryDestination = repositoryDestination;
        }
Пример #8
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            var url = RepositoryUrl.Text;

            if (!url.EndsWith("/"))
            {
                url += "/";
            }

            var dialog = new TaskDialog()
            {
                Caption         = Application.ProductName,
                InstructionText = "入力された URL を確認しています...",
                StandardButtons = TaskDialogStandardButtons.Cancel,
                ProgressBar     = new TaskDialogProgressBar()
                {
                    State = TaskDialogProgressBarState.Marquee
                },
                OwnerWindowHandle = Handle,
            };

            dialog.Opened += async(_sender, _e) => {
                var wres   = TaskDialogResult.None;
                var status = await Program.CheckRepositoryUrlAsync(url);

                if (status == Program.CheckStatus.OK)
                {
                    wres = TaskDialogResult.Ok;
                }
                else
                {
                    wres = TaskDialogResult.Cancel;
                }
                dialog.Close(wres);

                if (status == Program.CheckStatus.Empty || status == Program.CheckStatus.Invalid)
                {
                    new TaskDialog()
                    {
                        Caption           = Application.ProductName,
                        InstructionText   = "URL が正しくありません",
                        Text              = "入力された URL の形式が正しくありません。入力内容を確認してください。",
                        Icon              = TaskDialogStandardIcon.Warning,
                        OwnerWindowHandle = dialog.OwnerWindowHandle,
                    }.Show();
                }
                else if (status == Program.CheckStatus.NotFound)
                {
                    new TaskDialog()
                    {
                        Caption           = Application.ProductName,
                        InstructionText   = "リポジトリが見つかりませんでした",
                        Text              = "入力された URL には Mod 定義ファイルが存在しません。",
                        Icon              = TaskDialogStandardIcon.Warning,
                        OwnerWindowHandle = dialog.OwnerWindowHandle,
                    }.Show();
                }
                else if (status == Program.CheckStatus.MiscError)
                {
                    new TaskDialog()
                    {
                        Caption           = Application.ProductName,
                        InstructionText   = "エラーが発生しました",
                        Text              = "不明なエラーが発生しました。",
                        Icon              = TaskDialogStandardIcon.Error,
                        OwnerWindowHandle = dialog.OwnerWindowHandle,
                    }.Show();
                    wres = TaskDialogResult.Cancel;
                }
            };
            var result = dialog.Show();

            if (result == TaskDialogResult.Ok)
            {
                var config = Config.Load();
                config.RepositoryUrl = url;
                config.Save();

                DialogResult = DialogResult.OK;
                Close();
            }

            RepositoryUrl.Focus();
            RepositoryUrl.SelectAll();
        }
Пример #9
0
        public void Url_EqualsGivenValue_GivenUrl(string url)
        {
            var sut = new RepositoryUrl(url);

            Assert.Equal(url, sut.Url);
        }
        public PipelineFactoryBuilder SetRepositoryUrl(string repositoryUrl)
        {
            _repositoryUrl = new RepositoryUrl(repositoryUrl);

            return(this);
        }
Пример #11
0
        public ActionResult Authenticate(int issueId)
        {
            //Authentication
            string username = Request["username"] ?? string.Empty;

            string password = Request["password"] ?? string.Empty;

            string repositoryUrl = Request["repositoryurl"] ?? string.Empty;

            string message = string.Empty;

            bool success = true;

            string dataView = string.Empty;

            if (username.IsEmpty() || password.IsEmpty() || repositoryUrl.IsEmpty())
            {
                message = "Please make sure Username, Password and Url are not empty";
                success = false;
            }

            if (success)
            {
                UserWidgetDataDetails userData = new UserWidgetDataDetails();

                userData.Username = username.Trim();

                userData.Password = SecretsHelper.Encrypt(password.Trim(), SecretsHelper.EncryptionKey);

                userData.RepositoryUrl = repositoryUrl.Trim();

                SaveLoginDetails(CurrentUser, userData, GeminiContext);

                TFSPicker tfsPicker = new TFSPicker();

                try
                {
                    ItemWidgetArguments args = new ItemWidgetArguments(UserContext, GeminiContext, Cache, System.Web.HttpContext.Current.Request, CurrentIssue);

                    tfsPicker.AuthenticateUser(args);

                    UserWidgetDataDetails loginDetails = tfsPicker.getLoginDetails();

                    TFSPicker.ConnectByImplementingCredentialsProvider connect = new TFSPicker.ConnectByImplementingCredentialsProvider();

                    ICredentials iCred = new NetworkCredential(loginDetails.Username, loginDetails.Password);

                    connect.setLoginDetails(loginDetails.Username, loginDetails.Password, loginDetails.RepositoryUrl);

                    connect.GetCredentials(new Uri(loginDetails.RepositoryUrl), iCred);

                    TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(loginDetails.RepositoryUrl));


                    configurationServer.Credentials = iCred;

                    if (TFSPicker.IsBasicAuth)
                    {
                        configurationServer.ClientCredentials = new TfsClientCredentials(new BasicAuthCredential(iCred));
                    }
                    else
                    {
                        configurationServer.ClientCredentials = new TfsClientCredentials(new WindowsCredential(iCred));
                    }

                    try
                    {
                        configurationServer.EnsureAuthenticated();
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(1000);
                        configurationServer             = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(loginDetails.RepositoryUrl));
                        configurationServer.Credentials = iCred;

                        if (TFSPicker.IsBasicAuth)
                        {
                            configurationServer.ClientCredentials = new TfsClientCredentials(new BasicAuthCredential(iCred));
                        }
                        else
                        {
                            configurationServer.ClientCredentials = new TfsClientCredentials(new WindowsCredential(iCred));
                        }
                        configurationServer.EnsureAuthenticated();
                    }
                }
                catch (Exception ex)
                {
                    var logindetails = GeminiContext.UserWidgetStore.Get <UserWidgetDataDetails>(CurrentUser.Entity.Id, Constants.AppId, Constants.ControlId);

                    if (logindetails != null)
                    {
                        GeminiContext.UserWidgetStore.Delete(logindetails.Id);
                    }

                    success = false;

                    message = ex.Message;

                    GeminiApp.LogException(new Exception(ex.Message)
                    {
                        Source = "TFS Picker"
                    }, false);

                    return(JsonSuccess(new { success = success, message = message }));
                }

                tfsPicker.setLoginDetails(userData.Username, password.Trim(), userData.RepositoryUrl);

                WidgetResult result = new WidgetResult();

                List <string> tfsDetails = new List <string>();

                IssueWidgetData <List <string> > data = GeminiContext.IssueWidgetStore.Get <List <string> >(issueId, Constants.AppId, Constants.ControlId);

                if (data != null && data.Value != null && data.Value.Count > 0)
                {
                    tfsDetails = data.Value;
                }

                List <WorkItem> details = new List <WorkItem>();

                foreach (var tfs in tfsDetails)
                {
                    try
                    {
                        string url;

                        UserWidgetDataDetails loginDetails = tfsPicker.getLoginDetails();

                        if (Username.IsEmpty())
                        {
                            Username = loginDetails.Username;
                        }

                        if (Password.IsEmpty())
                        {
                            Password = loginDetails.Password;
                        }

                        if (RepositoryUrl.IsEmpty())
                        {
                            RepositoryUrl = loginDetails.RepositoryUrl;
                        }

                        var item = GetItem(tfs, out url);

                        if (item != null)
                        {
                            details.Add(item);
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;

                        message = ex.Message;

                        GeminiApp.LogException(new Exception(ex.Message)
                        {
                            Source = "TFS Picker"
                        }, false);
                    }
                }
            }

            return(JsonSuccess(new { success = success, message = message }));
        }