예제 #1
0
        private static void CreateUser(YouTrackClient youTrackClient)
        {
            IUserRepository userRepository = youTrackClient.GetUserRepository();

            CreateUserGroup(userRepository);
            CreateUser(userRepository);
        }
예제 #2
0
        private static void CreateUser(YouTrackClient youTrackClient)
        {
            IUserRepository userRepository = youTrackClient.GetUserRepository();

            CreateUserGroup(userRepository);
            CreateUser(userRepository);
        }
예제 #3
0
        public async Task TestCreate()
        {
            var messageHandler = GetAuthenticatedMessageHandler();

            var uri = new Uri($"{BaseAddress}{YoutrackDirectory.Issues}");

            messageHandler.AddFakeResponse(uri, new HttpResponseMessage(HttpStatusCode.Accepted));

            var clientFactory = new HttpClientFactory(messageHandler);

            var client = clientFactory.Create(BaseAddress);


            var user = new User
            {
                Login    = "******",
                Password = "******".ToSecureString()
            };

            var youTrackClient = new YouTrackClient(client, user);


            var issuesApi = new IssuesApi(youTrackClient);

            var issue = new Issue
            {
                Project     = "TestProject",
                Description = "An issues has occured",
                Summary     = "Some issue"
            };

            await issuesApi.CreateAsync(issue);
        }
예제 #4
0
        public async Task TestFailedLogin()
        {
            var mockReponseHandler = new MockResponseHandler();

            var uri = new Uri($"{BaseAddress}{YoutrackDirectory.Authentication}");

            mockReponseHandler.AddFakeResponse(uri, new HttpResponseMessage(HttpStatusCode.Unauthorized));

            var clientFactory = new HttpClientFactory(mockReponseHandler);

            var client = clientFactory.Create(BaseAddress);


            var user = new User
            {
                Login    = "******",
                Password = "******".ToSecureString()
            };

            var loginClient = new YouTrackClient(client, user);

            var success = await loginClient.AuthenticateAsync(user);

            Assert.IsFalse(success);
        }
예제 #5
0
        private static void Main(string[] args)
        {
            YouTrackClient youTrackClient = Login();

            CreateUser(youTrackClient);
            CreateProject(youTrackClient);

            Console.WriteLine("Done! Press any key to continue...");
            Console.ReadKey();
        }
예제 #6
0
        private static YouTrackClient Login()
        {
            Console.Write("Username with admin rights (root): ");
            string readLine = Console.ReadLine();
            string username = String.IsNullOrEmpty(readLine) ? "root" : readLine;

            Console.Write("Password: "******"http://localhost:80", username, password);
            return youTrackClient;
        }
        public override async Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(IIssueSourceEnumerationContext context)
        {
            var credentials = this.TryGetCredentials();

            var filter = this.Filter ?? string.Empty;

            if (!string.IsNullOrEmpty(this.ReleaseNumber))
            {
                filter = $"{filter} Fix version: {{{this.ReleaseNumber}}}";
            }

            using (var client = new YouTrackClient(credentials))
            {
                return(await client.IssuesByProjectAsync(this.ProjectName, filter).ConfigureAwait(false));
            }
        }
예제 #8
0
        private static YouTrackClient Login()
        {
            Console.Write("Username with admin rights (root): ");
            string readLine = Console.ReadLine();
            string username = String.IsNullOrEmpty(readLine) ? "root" : readLine;

            Console.Write("Password: "******"http://localhost:80", username, password);

            return(youTrackClient);
        }
예제 #9
0
        public async Task TestLogin()
        {
            var mockReponseHandler = new MockResponseHandler();

            mockReponseHandler.AddAuthenticationResponseHandler(BaseAddress);

            var clientFactory = new HttpClientFactory(mockReponseHandler);

            var client = clientFactory.Create(BaseAddress);


            var user = new User
            {
                Login    = "******",
                Password = "******".ToSecureString()
            };

            var loginClient = new YouTrackClient(client, user);

            var success = await loginClient.AuthenticateAsync(user);

            Assert.IsTrue(success);
        }
예제 #10
0
        private static void CreateProject(YouTrackClient youTrackClient)
        {
            IProjectRepository projectRepository = youTrackClient.GetProjectRepository();
            IIssueRepository   issueRepository   = youTrackClient.GetIssueRepository();

            if (ProjectExists(projectRepository))
            {
                if (!SubsystemExists(projectRepository))
                {
                    AddSubsystem(projectRepository);
                }

                if (!IssueExists(projectRepository))
                {
                    CreateInitialIssue(issueRepository);
                }
            }
            else
            {
                CreateSandboxProject(projectRepository);
                AddSubsystem(projectRepository);
                CreateInitialIssue(issueRepository);
            }
        }
예제 #11
0
        private CurrentSprintModel GetYouTrack(int sprintNumber = int.MinValue)
        {
            var client = new YouTrackClient();

            client.Auth();

            var agileSettings = client.GetSettings();
            //TODO: This ordering will not work correctly because it will order by string but we really want it ordered by
            //the sprint number
            var allSprintIds = agileSettings.Sprints.OrderByDescending(x => x.Id).ToArray();

            var    now            = DateTime.Now;
            Sprint currentSprint  = null;
            Sprint previousSprint = null;
            Sprint nextSprint     = null;

            // in YouTrack our sprints kinda go from monday to thursday
            // doing a bit of magic here to fix the mess...
            foreach (var sprint in allSprintIds.Select(x => client.GetSprint(x.Id)))
            {
                var sprNum = GetSprintNumber(sprint);

                //if it could not be parsed, ignore
                if (sprNum == 0)
                {
                    continue;
                }

                //if we are looking for a particular sprint
                if (sprintNumber != int.MinValue)
                {
                    if (sprNum == sprintNumber)
                    {
                        currentSprint = sprint;
                    }
                    else if (sprNum < sprintNumber && previousSprint == null)
                    {
                        previousSprint = sprint;
                    }
                    else if (sprNum > sprintNumber)
                    {
                        nextSprint = sprint;
                    }
                }
                else
                {
                    //we are determining the current by date

                    var start = sprint.Start.Date;
                    while (start.DayOfWeek != DayOfWeek.Monday)
                    {
                        start = start.AddDays(-1);
                    }
                    var finish = sprint.Finish.AddHours(12).Date;
                    while (finish.DayOfWeek != DayOfWeek.Sunday)
                    {
                        finish = finish.AddDays(1);
                    }
                    finish = finish.AddDays(1).AddSeconds(-1);

                    if (finish < now && (previousSprint == null || previousSprint.Start < start))
                    {
                        previousSprint = sprint;
                    }
                    if (start <= now && finish >= now)
                    {
                        currentSprint = sprint;
                    }
                    if (start > now && (nextSprint == null || nextSprint.Start > start))
                    {
                        nextSprint = sprint;
                    }
                }

                //exit if all is assigned so we don't keep looking up data
                if (previousSprint != null && currentSprint != null && nextSprint != null)
                {
                    break;
                }
            }

            var model = currentSprint == null ? null : new CurrentSprintModel
            {
                Name   = currentSprint.Version,
                Number = GetSprintNumber(currentSprint),
                Start  = currentSprint.Start.Date,
                Finish = currentSprint.Finish.AddHours(12).Date,

                PreviousSprint = previousSprint == null ? null : new SprintModel
                {
                    Name   = previousSprint.Version,
                    Number = GetSprintNumber(previousSprint),
                    Start  = previousSprint.Start.Date,
                    Finish = previousSprint.Finish.AddHours(12).Date
                },

                NextSprint = nextSprint == null ? null : new SprintModel
                {
                    Name   = nextSprint.Version,
                    Number = GetSprintNumber(nextSprint),
                    Start  = nextSprint.Start.Date,
                    Finish = nextSprint.Finish.AddHours(12).Date
                }
            };

            if (model != null)
            {
                model.Issues = client.GetProgress(model.Number);
            }

            return(model);
        }
예제 #12
0
        private static void CreateProject(YouTrackClient youTrackClient)
        {
            IProjectRepository projectRepository = youTrackClient.GetProjectRepository();
            IIssueRepository issueRepository = youTrackClient.GetIssueRepository();

            if(ProjectExists(projectRepository))
            {
                if (!SubsystemExists(projectRepository))
                {
                    AddSubsystem(projectRepository);
                }

                if (!IssueExists(projectRepository))
                {
                    CreateInitialIssue(issueRepository);
                }
            }
            else
            {
                CreateSandboxProject(projectRepository);
                AddSubsystem(projectRepository);
                CreateInitialIssue(issueRepository);
            }
        }