From c113e4f5c3aa492da28526b9929a8d0f33ef449d Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Wed, 3 Apr 2019 15:35:58 +0200 Subject: [PATCH 01/15] Update version number --- src/YouTrackSharp/YouTrackSharp.csproj | 4 ++-- tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/YouTrackSharp/YouTrackSharp.csproj b/src/YouTrackSharp/YouTrackSharp.csproj index 5ce7bbc4..bacd5056 100644 --- a/src/YouTrackSharp/YouTrackSharp.csproj +++ b/src/YouTrackSharp/YouTrackSharp.csproj @@ -8,8 +8,8 @@ https://github.com/JetBrains/YouTrackSharp/blob/master/LICENSE.txt https://github.com/JetBrains/YouTrackSharp/ YouTrack JetBrains SDK - 2018.4.0 - 2018.4.0 + 2019.1.0 + 2019.1.0 A .NET Library to talk to JetBrains YouTrack. JetBrains JetBrains diff --git a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj index dbd87a42..bff07d9a 100644 --- a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj +++ b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj @@ -1,8 +1,8 @@  netcoreapp2.0 - 2018.4.0 - 2018.4.0 + 2019.1.0 + 2019.1.0 JetBrains JetBrains YouTrackSharp From a76e40019a1754380bebb362688249ab1288b343 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Wed, 3 Apr 2019 15:50:44 +0200 Subject: [PATCH 02/15] Drop username/password connection --- .../UsernamePasswordConnection.cs | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 src/YouTrackSharp/UsernamePasswordConnection.cs diff --git a/src/YouTrackSharp/UsernamePasswordConnection.cs b/src/YouTrackSharp/UsernamePasswordConnection.cs deleted file mode 100644 index 65eb3db7..00000000 --- a/src/YouTrackSharp/UsernamePasswordConnection.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; - -namespace YouTrackSharp -{ - /// - /// A class that represents a connection against a YouTrack server instance and provides - /// an authenticated that uses a username/password combination. - /// - public class UsernamePasswordConnection : Connection - { - private HttpClient _httpClient; - private bool _authenticated; - - private readonly string _username; - private readonly string _password; - - private Action _configureHandler; - - /// - /// Creates an instance of the class. - /// - /// YouTrack server instance URL that will be connected against. - /// The username to be used when authenticating. - /// The password to be used when authenticating. - /// - /// The was null, empty or did not represent a valid, absolute . - /// - public UsernamePasswordConnection(string serverUrl, string username, string password) - : this(serverUrl, username, password, null) - { - } - - /// - /// Creates an instance of the class. - /// - /// YouTrack server instance URL that will be connected against. - /// The username to be used when authenticating. - /// The password to be used when authenticating. - /// An action that configures the underlying , e.g. to override SSL settings. - /// - /// The was null, empty or did not represent a valid, absolute . - /// - public UsernamePasswordConnection(string serverUrl, string username, string password, Action configureHandler) - : base(serverUrl) - { - _username = username; - _password = password; - _configureHandler = configureHandler; - } - - /// - public override async Task GetAuthenticatedHttpClient() - { - // Initialize HTTP client - if (_httpClient == null) - { - var handler = new HttpClientHandler - { - CookieContainer = new CookieContainer(), - UseCookies = true - }; - - _configureHandler?.Invoke(handler); - - _httpClient = new HttpClient(handler) - { - BaseAddress = ServerUri - }; - - _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(Constants.HttpContentTypes.ApplicationJson)); - } - - // Authenticate? - if (!_authenticated) - { - var formData = new Dictionary - { - { "login", _username }, - { "password", _password } - }; - - var response = await _httpClient.PostAsync("rest/user/login", new FormUrlEncodedContent(formData)); - - if (response.IsSuccessStatusCode) - { - var responseString = await response.Content.ReadAsStringAsync(); - if (string.Equals(responseString, "ok", StringComparison.OrdinalIgnoreCase)) - { - _authenticated = true; - } - else - { - throw new UnauthorizedConnectionException( - Strings.Exception_CouldNotAuthenticate, response.StatusCode, responseString); - } - } - - if (!_authenticated) - { - throw new UnauthorizedConnectionException( - Strings.Exception_CouldNotAuthenticate, response.StatusCode, response.ReasonPhrase); - } - } - - return _httpClient; - } - } -} \ No newline at end of file From a7d0b9dfddbd887890f7917a1b4c4751ba30403f Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Wed, 3 Apr 2019 15:50:59 +0200 Subject: [PATCH 03/15] Update all tests to use bearer token connection --- .../Infrastructure/Connections.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs index 613c6fa4..df167a1d 100644 --- a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs +++ b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs @@ -8,16 +8,13 @@ public static string ServerUrl => "https://ytsharp.myjetbrains.com/youtrack/"; public static Connection UnauthorizedConnection => - new UsernamePasswordConnection(ServerUrl, "demogod", "demogod"); - - public static Connection Demo1Password => - new UsernamePasswordConnection(ServerUrl, "demo1", "demo1"); + new BearerTokenConnection(ServerUrl, "invalidtoken"); public static Connection Demo1Token => new BearerTokenConnection(ServerUrl, "perm:ZGVtbzE=.WW91VHJhY2tTaGFycA==.AX3uf8RYk3y2bupWA1xyd9BhAHoAxc"); - public static Connection Demo2Password => - new UsernamePasswordConnection(ServerUrl, "demo2", "demo2"); + public static Connection Demo2Token => + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzI=.WW91VHJhY2tTaGFycA==.GQEOl33LyTtmJvhWuz0Q629wbo8dk0"); public static Connection Demo3Token => new BearerTokenConnection(ServerUrl, "perm:ZGVtbzM=.WW91VHJhY2tTaGFycA==.L04RdcCnjyW2UPCVg1qyb6dQflpzFy"); @@ -27,9 +24,8 @@ public static class TestData public static readonly List ValidConnections = new List { - new object[] { Demo1Password }, new object[] { Demo1Token }, - new object[] { Demo2Password } + new object[] { Demo2Token } }; public static readonly List InvalidConnections From 175a79fc64dd4792744d581c02918a90c89810e4 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 15:51:01 +0200 Subject: [PATCH 04/15] Update tests --- src/YouTrackSharp/BearerTokenConnection.cs | 2 +- src/YouTrackSharp/Users/User.cs | 24 ++++++++++++++----- src/YouTrackSharp/Users/UserService.cs | 2 +- .../Integration/ConnectionHttpClientTests.cs | 2 +- .../Projects/CreateProjectCustomField.cs | 4 ++-- .../Projects/UpdateProjectCustomField.cs | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/YouTrackSharp/BearerTokenConnection.cs b/src/YouTrackSharp/BearerTokenConnection.cs index 3fa94b01..81281437 100644 --- a/src/YouTrackSharp/BearerTokenConnection.cs +++ b/src/YouTrackSharp/BearerTokenConnection.cs @@ -70,7 +70,7 @@ public override async Task GetAuthenticatedHttpClient() // Authenticate? if (!_authenticated) { - var response = await _httpClient.GetAsync("rest/user/current"); + var response = await _httpClient.GetAsync("api/admin/users/me"); if (response.IsSuccessStatusCode) { _authenticated = true; diff --git a/src/YouTrackSharp/Users/User.cs b/src/YouTrackSharp/Users/User.cs index fca853a1..ff9e8a3a 100644 --- a/src/YouTrackSharp/Users/User.cs +++ b/src/YouTrackSharp/Users/User.cs @@ -7,6 +7,12 @@ namespace YouTrackSharp.Users /// public class User { + /// + /// Login of the user. + /// + [JsonProperty("login")] + public string Login { get; set; } + /// /// Full name of the user. /// @@ -20,15 +26,21 @@ public class User public string Email { get; set; } /// - /// Project that was last created. + /// Is a guest? + /// + [JsonProperty("guest")] + public bool IsGuest { get; set; } + + /// + /// Is online? /// - [JsonProperty("lastCreatedProject")] - public string LastCreatedProject { get; set; } + [JsonProperty("online")] + public bool IsOnline { get; set; } /// - /// Project that is filtered on. + /// Avatar URL. /// - [JsonProperty("filterProject")] - public string FilterProject { get; set; } + [JsonProperty("avatarUrl")] + public string AvatarUrl { get; set; } } } \ No newline at end of file diff --git a/src/YouTrackSharp/Users/UserService.cs b/src/YouTrackSharp/Users/UserService.cs index 6e15ab63..211cf4e4 100644 --- a/src/YouTrackSharp/Users/UserService.cs +++ b/src/YouTrackSharp/Users/UserService.cs @@ -25,7 +25,7 @@ public UserService(Connection connection) public async Task GetCurrentUserInfo() { var client = await _connection.GetAuthenticatedHttpClient(); - var response = await client.GetAsync("rest/user/current"); + var response = await client.GetAsync("api/admin/users/me"); response.EnsureSuccessStatusCode(); diff --git a/tests/YouTrackSharp.Tests/Integration/ConnectionHttpClientTests.cs b/tests/YouTrackSharp.Tests/Integration/ConnectionHttpClientTests.cs index 5d1dce65..8de4c3bd 100644 --- a/tests/YouTrackSharp.Tests/Integration/ConnectionHttpClientTests.cs +++ b/tests/YouTrackSharp.Tests/Integration/ConnectionHttpClientTests.cs @@ -14,7 +14,7 @@ public async Task Valid_Connection_Returns_Authenticated_HttpClient(Connection c { // Arrange & Act var httpClient = await connection.GetAuthenticatedHttpClient(); - var response = await httpClient.GetAsync("rest/user/current"); + var response = await httpClient.GetAsync("api/admin/users/me"); // Assert Assert.True(response.IsSuccessStatusCode); diff --git a/tests/YouTrackSharp.Tests/Integration/Projects/CreateProjectCustomField.cs b/tests/YouTrackSharp.Tests/Integration/Projects/CreateProjectCustomField.cs index 70027de6..f07953b3 100644 --- a/tests/YouTrackSharp.Tests/Integration/Projects/CreateProjectCustomField.cs +++ b/tests/YouTrackSharp.Tests/Integration/Projects/CreateProjectCustomField.cs @@ -13,7 +13,7 @@ public class CreateProjectCustomField public async Task Valid_Connection_Creates_CustomField_For_Project() { // Arrange - var connection = Connections.Demo1Password; + var connection = Connections.Demo1Token; var service = connection.ProjectCustomFieldsService(); var customField = new CustomField { Name = "TestField" }; var projectId = "DP1"; @@ -42,7 +42,7 @@ public async Task Valid_Connection_Creates_CustomField_For_Project() public async Task Valid_Connection_Creates_CustomField_With_EmptyText_For_Project() { // Arrange - var connection = Connections.Demo1Password; + var connection = Connections.Demo1Token; var service = connection.ProjectCustomFieldsService(); var customField = new CustomField { Name = "TestField", EmptyText = "empty" }; var projectId = "DP1"; diff --git a/tests/YouTrackSharp.Tests/Integration/Projects/UpdateProjectCustomField.cs b/tests/YouTrackSharp.Tests/Integration/Projects/UpdateProjectCustomField.cs index e032f294..9ff77427 100644 --- a/tests/YouTrackSharp.Tests/Integration/Projects/UpdateProjectCustomField.cs +++ b/tests/YouTrackSharp.Tests/Integration/Projects/UpdateProjectCustomField.cs @@ -14,7 +14,7 @@ public class UpdateProjectCustomField public async Task Valid_Connection_Update_CustomField_For_Project() { // Arrange - var connection = Connections.Demo1Password; + var connection = Connections.Demo1Token; var service = connection.ProjectCustomFieldsService(); var customField = new CustomField { Name = "TestField" }; var projectId = "DP1"; From 37e57f2f76755c181d7985e7743f46d8fccc21f1 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 15:51:39 +0200 Subject: [PATCH 05/15] Update YouTrack 2018.2 agile board notification text --- src/YouTrackSharp/ConnectionExtensions.cs | 4 ++-- .../Integration/AgileBoards/CreateAgileBoard.cs | 4 ++-- .../Integration/AgileBoards/GetAgileBoard.cs | 4 ++-- .../Integration/AgileBoards/GetAgileBoards.cs | 4 ++-- .../YouTrackSharp.Tests/Integration/AgileBoards/GetSprint.cs | 4 ++-- .../Integration/AgileBoards/UpdateAgileBoard.cs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/YouTrackSharp/ConnectionExtensions.cs b/src/YouTrackSharp/ConnectionExtensions.cs index cbb2d663..9258eebb 100644 --- a/src/YouTrackSharp/ConnectionExtensions.cs +++ b/src/YouTrackSharp/ConnectionExtensions.cs @@ -76,11 +76,11 @@ public static IProjectCustomFieldsService ProjectCustomFieldsService(this Connec /// Creates a . /// /// - /// YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information. + /// YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information. /// /// The to create a service with. /// for working with YouTrack agile boards. - [Obsolete("YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Obsolete("YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public static IAgileBoardService CreateAgileBoardService(this Connection connection) { return new AgileBoardService(connection); diff --git a/tests/YouTrackSharp.Tests/Integration/AgileBoards/CreateAgileBoard.cs b/tests/YouTrackSharp.Tests/Integration/AgileBoards/CreateAgileBoard.cs index d5823061..d4a5b939 100644 --- a/tests/YouTrackSharp.Tests/Integration/AgileBoards/CreateAgileBoard.cs +++ b/tests/YouTrackSharp.Tests/Integration/AgileBoards/CreateAgileBoard.cs @@ -49,7 +49,7 @@ public async Task Valid_Connection_Creates_Agile_Board() // Remove the newly created board (currently not supported) } - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Valid_Connection_Throws_HttpRequestException_On_Bad_Parameter() { // Arrange @@ -60,7 +60,7 @@ await Assert.ThrowsAsync( async () => await service.CreateAgileBoard(new AgileSettings())); } - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Invalid_Connection_Throws_UnauthorizedConnectionException() { // Arrange diff --git a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoard.cs b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoard.cs index 45c495cc..c1b34873 100644 --- a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoard.cs +++ b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoard.cs @@ -8,7 +8,7 @@ public partial class AgileBoardServiceTests { public class GetAgileBoard { - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Valid_Connection_Returns_Agile_Board() { // Arrange @@ -31,7 +31,7 @@ public async Task Valid_Connection_Returns_Agile_Board() Assert.NotNull(demoBoard.Sprints); } - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Invalid_Connection_Throws_UnauthorizedConnectionException() { // Arrange diff --git a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoards.cs b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoards.cs index 9f999e10..2ad9084e 100644 --- a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoards.cs +++ b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetAgileBoards.cs @@ -9,7 +9,7 @@ public partial class AgileBoardServiceTests { public class GetAgileBoards { - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Valid_Connection_Returns_Agile_Boards() { // Arrange @@ -33,7 +33,7 @@ public async Task Valid_Connection_Returns_Agile_Boards() Assert.NotNull(demoBoard.Sprints); } - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Invalid_Connection_Throws_UnauthorizedConnectionException() { // Arrange diff --git a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetSprint.cs b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetSprint.cs index da73f993..ea45874b 100644 --- a/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetSprint.cs +++ b/tests/YouTrackSharp.Tests/Integration/AgileBoards/GetSprint.cs @@ -8,7 +8,7 @@ public partial class AgileBoardServiceTests { public class GetSprint { - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Valid_Connection_Returns_Sprint() { // Arrange @@ -27,7 +27,7 @@ public async Task Valid_Connection_Returns_Sprint() Assert.NotNull(demoSprint.Version); } - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Invalid_Connection_Throws_UnauthorizedConnectionException() { // Arrange diff --git a/tests/YouTrackSharp.Tests/Integration/AgileBoards/UpdateAgileBoard.cs b/tests/YouTrackSharp.Tests/Integration/AgileBoards/UpdateAgileBoard.cs index 81a9cceb..be622c50 100644 --- a/tests/YouTrackSharp.Tests/Integration/AgileBoards/UpdateAgileBoard.cs +++ b/tests/YouTrackSharp.Tests/Integration/AgileBoards/UpdateAgileBoard.cs @@ -11,7 +11,7 @@ public partial class AgileBoardServiceTests { public class UpdateAgileBoard { - [Fact(Skip = "YouTrack 2018.2 no longer supports the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] + [Fact(Skip = "YouTrack 2018.2 and higher no longer support the agile board API. Please check https://github.com/JetBrains/YouTrackSharp/issues/81 for more information.")] public async Task Valid_Connection_Updates_Agile_Board() { // Arrange From a205e3e9b63711c08e646f9a362c8c761641c654 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 16:05:15 +0200 Subject: [PATCH 06/15] Update SDK version used --- global.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/global.json b/global.json index 30a025c7..1be2fcf9 100644 --- a/global.json +++ b/global.json @@ -1 +1,5 @@ -{"sdk":{"version":"2.1.202"}} \ No newline at end of file +{ + "sdk": { + "version": "2.1.602" + } +} \ No newline at end of file From 2100e3302e56919d88f53e6dbcb5b5d12d29814f Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 16:19:42 +0200 Subject: [PATCH 07/15] Update build --- YouTrackSharp.sln | 16 ++++++--- build.ps1 | 31 ++++++++-------- build.sh | 36 ++++++++----------- build/.editorconfig | 10 ++++++ build/Build.cs | 35 +++++++++++++----- ...uTrackSharp.Build.csproj => _build.csproj} | 13 +++---- ....dotsettings => _build.csproj.DotSettings} | 0 7 files changed, 84 insertions(+), 57 deletions(-) create mode 100644 build/.editorconfig rename build/{YouTrackSharp.Build.csproj => _build.csproj} (75%) rename build/{YouTrackSharp.Build.csproj.dotsettings => _build.csproj.DotSettings} (100%) diff --git a/YouTrackSharp.sln b/YouTrackSharp.sln index 92396dbe..237d68e3 100644 --- a/YouTrackSharp.sln +++ b/YouTrackSharp.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTrackSharp.Build", "build\YouTrackSharp.Build.csproj", "{8319DDE9-EA2C-438B-8121-00C0521E9413}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTrackSharp", "src\YouTrackSharp\YouTrackSharp.csproj", "{DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTrackSharp.Tests", "tests\YouTrackSharp.Tests\YouTrackSharp.Tests.csproj", "{854897F4-93D5-4A38-9B7F-B4E5063EA5F9}" @@ -15,14 +13,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AFD08188 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{BCDA53C1-8888-4EEF-BA2C-0611747E4FC4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{C525EC99-2687-4F53-B839-558F18B2F71D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\_build.csproj", "{944D7366-06AA-474B-BE5A-B4A0E654121D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8319DDE9-EA2C-438B-8121-00C0521E9413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8319DDE9-EA2C-438B-8121-00C0521E9413}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C525EC99-2687-4F53-B839-558F18B2F71D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C525EC99-2687-4F53-B839-558F18B2F71D}.Release|Any CPU.ActiveCfg = Release|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -31,13 +33,17 @@ Global {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Release|Any CPU.Build.0 = Release|Any CPU + {944D7366-06AA-474B-BE5A-B4A0E654121D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {944D7366-06AA-474B-BE5A-B4A0E654121D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {944D7366-06AA-474B-BE5A-B4A0E654121D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {944D7366-06AA-474B-BE5A-B4A0E654121D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {8319DDE9-EA2C-438B-8121-00C0521E9413} = {BCDA53C1-8888-4EEF-BA2C-0611747E4FC4} {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1} = {05F1283A-BBF6-4E24-9DBE-A524AC28EF63} {854897F4-93D5-4A38-9B7F-B4E5063EA5F9} = {AFD08188-88DE-4FCF-BB47-95923037CF58} + {944D7366-06AA-474B-BE5A-B4A0E654121D} = {BCDA53C1-8888-4EEF-BA2C-0611747E4FC4} EndGlobalSection EndGlobal diff --git a/build.ps1 b/build.ps1 index cd1be8ac..cb7fbdb2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,29 +1,27 @@ [CmdletBinding()] Param( - #[switch]$CustomParam, [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] [string[]]$BuildArguments ) Write-Output "Windows PowerShell $($Host.Version)" -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { $host.SetShouldExit(1) } +Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 } $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent ########################################################################### # CONFIGURATION ########################################################################### -$BuildProjectFile = "$PSScriptRoot\build\YouTrackSharp.Build.csproj" +$BuildProjectFile = "$PSScriptRoot\build\_build.csproj" $TempDirectory = "$PSScriptRoot\\.tmp" $DotNetGlobalFile = "$PSScriptRoot\\global.json" $DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" -$DotNetReleasesUrl = "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases.json" +$DotNetChannel = "Current" $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:NUGET_XMLDOC_MODE = "skip" ########################################################################### # EXECUTION @@ -36,7 +34,10 @@ function ExecSafe([scriptblock] $cmd) { # If global.json exists, load expected version if (Test-Path $DotNetGlobalFile) { - $DotNetVersion = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json).sdk.version + $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) + if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { + $DotNetVersion = $DotNetGlobal.sdk.version + } } # If dotnet is installed locally, and expected version is not set or installation matches the expected version @@ -48,18 +49,20 @@ else { $DotNetDirectory = "$TempDirectory\dotnet-win" $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" - # If expected version is not set, get latest version - if (!(Test-Path variable:DotNetVersion)) { - $DotNetVersion = $(Invoke-WebRequest -UseBasicParsing $DotNetReleasesUrl | ConvertFrom-Json)[0]."version-sdk" - } - - # Download and execute install script + # Download install script $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" md -force $TempDirectory > $null (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) - ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } + + # Install by channel or version + if (!(Test-Path variable:DotNetVersion)) { + ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } + } else { + ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } + } } Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" -ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile -- $BuildArguments } +ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false } +ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh index 1f2ce310..6d6e2ad4 100644 --- a/build.sh +++ b/build.sh @@ -2,16 +2,6 @@ echo $(bash --version 2>&1 | head -n 1) -#CUSTOMPARAM=0 -BUILD_ARGUMENTS=() -for i in "$@"; do - case $(echo $1 | awk '{print tolower($0)}') in - # -custom-param) CUSTOMPARAM=1;; - *) BUILD_ARGUMENTS+=("$1") ;; - esac - shift -done - set -eo pipefail SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) @@ -19,16 +9,15 @@ SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) # CONFIGURATION ########################################################################### -BUILD_PROJECT_FILE="$SCRIPT_DIR/build/YouTrackSharp.Build.csproj" +BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" TEMP_DIRECTORY="$SCRIPT_DIR//.tmp" DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" -DOTNET_RELEASES_URL="https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases.json" +DOTNET_CHANNEL="Current" export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export NUGET_XMLDOC_MODE="skip" ########################################################################### # EXECUTION @@ -41,6 +30,9 @@ function FirstJsonValue { # If global.json exists, load expected version if [ -f "$DOTNET_GLOBAL_FILE" ]; then DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) + if [ "$DOTNET_VERSION" == "" ]; then + unset DOTNET_VERSION + fi fi # If dotnet is installed locally, and expected version is not set or installation matches the expected version @@ -50,19 +42,21 @@ else DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" - # If expected version is not set, get latest version - if [ -z ${DOTNET_VERSION+x} ]; then - DOTNET_VERSION=$(FirstJsonValue "version-sdk" $(curl -s "$DOTNET_RELEASES_URL")) - fi - - # Download and execute install script + # Download install script DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" mkdir -p "$TEMP_DIRECTORY" curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" chmod +x "$DOTNET_INSTALL_FILE" - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path + + # Install by channel or version + if [ -z ${DOTNET_VERSION+x} ]; then + "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path + else + "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path + fi fi echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" -"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]} +"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false +"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/build/.editorconfig b/build/.editorconfig new file mode 100644 index 00000000..94be682c --- /dev/null +++ b/build/.editorconfig @@ -0,0 +1,10 @@ +[*.cs] +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning +dotnet_style_require_accessibility_modifiers = never:warning + +csharp_style_expression_bodied_properties = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_accessors = true:warning diff --git a/build/Build.cs b/build/Build.cs index 9a7c44cc..b125e877 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,15 +1,26 @@ using System; using Nuke.Common; +using Nuke.Common.Execution; +using Nuke.Common.ProjectModel; using Nuke.Common.Tools.DotNet; using static Nuke.Common.EnvironmentInfo; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.PathConstruction; -using static Nuke.Common.Tools.DotNet.DotNetTasks; +[CheckBuildProjectConfigurations] +[UnsetVisualStudioEnvironmentVariables] class Build : NukeBuild { + /// Support plugins are available for: + /// - JetBrains ReSharper https://nuke.build/resharper + /// - JetBrains Rider https://nuke.build/rider + /// - Microsoft VisualStudio https://nuke.build/visualstudio + /// - Microsoft VSCode https://nuke.build/vscode + public string PackageVersionSuffix => "develop-" + DateTime.UtcNow.ToString("yyyyMMddhhmm"); + [Solution] readonly Solution Solution; + public static int Main() => Execute(x => x.Pack); Target Initialize => _ => _ @@ -20,20 +31,26 @@ class Build : NukeBuild Target Clean => _ => _ .DependsOn(Initialize) - .Executes(() => DeleteDirectories(GlobDirectories(SourceDirectory, "**/bin", "**/obj"))); + .Executes(() => + { + foreach (var directory in Solution.Directory.GlobDirectories("**/bin", "**/obj")) + { + DeleteDirectory(directory); + } + }); Target Restore => _ => _ .DependsOn(Clean) .Executes(() => { - DotNetRestore(SolutionDirectory); + DotNetTasks.DotNetRestore(); }); Target Compile => _ => _ .DependsOn(Restore) .Executes(() => { - DotNetBuild(SolutionFile, settings => settings + DotNetTasks.DotNetBuild(settings => settings .SetVersionSuffix(PackageVersionSuffix)); }); @@ -41,8 +58,8 @@ class Build : NukeBuild .DependsOn(Compile) .Executes(() => { - DotNetTest(settings => settings - .SetProjectFile(SolutionDirectory / "tests" / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj") + DotNetTasks.DotNetTest(settings => settings + .SetProjectFile(Solution.Directory / "tests" / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj") .EnableNoBuild()); }); @@ -50,10 +67,10 @@ class Build : NukeBuild .DependsOn(Test) .Executes(() => { - EnsureExistingDirectory(ArtifactsDirectory); + EnsureExistingDirectory(Solution.Directory / "artifacts"); - DotNetPack(settings => settings - .SetOutputDirectory(ArtifactsDirectory) + DotNetTasks.DotNetPack(settings => settings + .SetOutputDirectory(Solution.Directory / "artifacts") .EnableIncludeSource() .EnableIncludeSymbols() .SetVersionSuffix(PackageVersionSuffix)); diff --git a/build/YouTrackSharp.Build.csproj b/build/_build.csproj similarity index 75% rename from build/YouTrackSharp.Build.csproj rename to build/_build.csproj index b67d1b98..f2348458 100644 --- a/build/YouTrackSharp.Build.csproj +++ b/build/_build.csproj @@ -1,4 +1,4 @@ - + Exe @@ -10,24 +10,21 @@ - - - all - runtime; build; native; contentfiles; analyzers - + - + - + + diff --git a/build/YouTrackSharp.Build.csproj.dotsettings b/build/_build.csproj.DotSettings similarity index 100% rename from build/YouTrackSharp.Build.csproj.dotsettings rename to build/_build.csproj.DotSettings From 2afb5e4e45eea2719f0ad8249bf0ff9255576815 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 16:31:32 +0200 Subject: [PATCH 08/15] More build updates --- build/Build.cs | 54 +++++++++++++++++++++------------ build/_build.csproj.DotSettings | 3 +- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/build/Build.cs b/build/Build.cs index b125e877..b34265a6 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,11 +1,14 @@ using System; using Nuke.Common; using Nuke.Common.Execution; +using Nuke.Common.Git; using Nuke.Common.ProjectModel; using Nuke.Common.Tools.DotNet; +using Nuke.Common.Utilities.Collections; using static Nuke.Common.EnvironmentInfo; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.PathConstruction; +using static Nuke.Common.Tools.DotNet.DotNetTasks; [CheckBuildProjectConfigurations] [UnsetVisualStudioEnvironmentVariables] @@ -17,62 +20,73 @@ class Build : NukeBuild /// - Microsoft VisualStudio https://nuke.build/visualstudio /// - Microsoft VSCode https://nuke.build/vscode - public string PackageVersionSuffix => "develop-" + DateTime.UtcNow.ToString("yyyyMMddhhmm"); + public static int Main () => Execute(x => x.Pack); - [Solution] readonly Solution Solution; + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - public static int Main() => Execute(x => x.Pack); + [Parameter("Package version suffix")] + readonly string PackageVersionSuffix = "develop-" + DateTime.UtcNow.ToString("yyyyMMddhhmm"); + + [Solution] readonly Solution Solution; + [GitRepository] readonly GitRepository GitRepository; + + AbsolutePath SourceDirectory => RootDirectory / "src"; + AbsolutePath TestsDirectory => RootDirectory / "tests"; + AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; Target Initialize => _ => _ + .Before(Clean) .Executes(() => { SetVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1"); }); Target Clean => _ => _ - .DependsOn(Initialize) + .Before(Restore) .Executes(() => { - foreach (var directory in Solution.Directory.GlobDirectories("**/bin", "**/obj")) - { - DeleteDirectory(directory); - } + SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + EnsureCleanDirectory(ArtifactsDirectory); }); Target Restore => _ => _ - .DependsOn(Clean) .Executes(() => { - DotNetTasks.DotNetRestore(); + DotNetRestore(s => s + .SetProjectFile(Solution)); }); Target Compile => _ => _ .DependsOn(Restore) .Executes(() => { - DotNetTasks.DotNetBuild(settings => settings - .SetVersionSuffix(PackageVersionSuffix)); + DotNetBuild(s => s + .SetProjectFile(Solution) + .SetConfiguration(Configuration) + .EnableNoRestore()); }); - + Target Test => _ => _ .DependsOn(Compile) .Executes(() => { - DotNetTasks.DotNetTest(settings => settings - .SetProjectFile(Solution.Directory / "tests" / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj") + DotNetTest(settings => settings + .SetProjectFile(TestsDirectory / "YouTrackSharp.Tests" / "YouTrackSharp.Tests.csproj") .EnableNoBuild()); }); - + Target Pack => _ => _ .DependsOn(Test) .Executes(() => { - EnsureExistingDirectory(Solution.Directory / "artifacts"); + EnsureExistingDirectory(ArtifactsDirectory); - DotNetTasks.DotNetPack(settings => settings - .SetOutputDirectory(Solution.Directory / "artifacts") + DotNetPack(settings => settings + .SetOutputDirectory(ArtifactsDirectory) .EnableIncludeSource() .EnableIncludeSymbols() .SetVersionSuffix(PackageVersionSuffix)); }); -} +} \ No newline at end of file diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index 9aac7d8e..96e392e6 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -1,4 +1,4 @@ - + False Implicit Implicit @@ -17,7 +17,6 @@ True True True - True True True True From f9d5bcb8c08008296b5bf72cfac5d33efc944857 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 16:59:06 +0200 Subject: [PATCH 09/15] Remove build project from .sln --- YouTrackSharp.sln | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/YouTrackSharp.sln b/YouTrackSharp.sln index 237d68e3..bd694199 100644 --- a/YouTrackSharp.sln +++ b/YouTrackSharp.sln @@ -11,20 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{05F1283A-BBF EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AFD08188-88DE-4FCF-BB47-95923037CF58}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{BCDA53C1-8888-4EEF-BA2C-0611747E4FC4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{C525EC99-2687-4F53-B839-558F18B2F71D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\_build.csproj", "{944D7366-06AA-474B-BE5A-B4A0E654121D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C525EC99-2687-4F53-B839-558F18B2F71D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C525EC99-2687-4F53-B839-558F18B2F71D}.Release|Any CPU.ActiveCfg = Release|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -33,10 +25,6 @@ Global {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {854897F4-93D5-4A38-9B7F-B4E5063EA5F9}.Release|Any CPU.Build.0 = Release|Any CPU - {944D7366-06AA-474B-BE5A-B4A0E654121D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {944D7366-06AA-474B-BE5A-B4A0E654121D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {944D7366-06AA-474B-BE5A-B4A0E654121D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {944D7366-06AA-474B-BE5A-B4A0E654121D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -44,6 +32,5 @@ Global GlobalSection(NestedProjects) = preSolution {DB576D3A-7CCE-4B4D-8CBF-9090B1573DE1} = {05F1283A-BBF6-4E24-9DBE-A524AC28EF63} {854897F4-93D5-4A38-9B7F-B4E5063EA5F9} = {AFD08188-88DE-4FCF-BB47-95923037CF58} - {944D7366-06AA-474B-BE5A-B4A0E654121D} = {BCDA53C1-8888-4EEF-BA2C-0611747E4FC4} EndGlobalSection EndGlobal From a7b994db80d3c43a840c0384676c1450a99fc8bc Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 18:19:10 +0200 Subject: [PATCH 10/15] Use TLS 1.2 for test suite --- .../Infrastructure/Connections.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs index df167a1d..7a524cea 100644 --- a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs +++ b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Net.Http; +using System.Security.Authentication; namespace YouTrackSharp.Tests.Infrastructure { @@ -8,16 +10,16 @@ public static string ServerUrl => "https://ytsharp.myjetbrains.com/youtrack/"; public static Connection UnauthorizedConnection => - new BearerTokenConnection(ServerUrl, "invalidtoken"); + new BearerTokenConnection(ServerUrl, "invalidtoken", handler => ConfigureTestsHandler(handler)); public static Connection Demo1Token => - new BearerTokenConnection(ServerUrl, "perm:ZGVtbzE=.WW91VHJhY2tTaGFycA==.AX3uf8RYk3y2bupWA1xyd9BhAHoAxc"); + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzE=.WW91VHJhY2tTaGFycA==.AX3uf8RYk3y2bupWA1xyd9BhAHoAxc", handler => ConfigureTestsHandler(handler)); public static Connection Demo2Token => - new BearerTokenConnection(ServerUrl, "perm:ZGVtbzI=.WW91VHJhY2tTaGFycA==.GQEOl33LyTtmJvhWuz0Q629wbo8dk0"); + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzI=.WW91VHJhY2tTaGFycA==.GQEOl33LyTtmJvhWuz0Q629wbo8dk0", handler => ConfigureTestsHandler(handler)); public static Connection Demo3Token => - new BearerTokenConnection(ServerUrl, "perm:ZGVtbzM=.WW91VHJhY2tTaGFycA==.L04RdcCnjyW2UPCVg1qyb6dQflpzFy"); + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzM=.WW91VHJhY2tTaGFycA==.L04RdcCnjyW2UPCVg1qyb6dQflpzFy", handler => ConfigureTestsHandler(handler)); public static class TestData { @@ -34,5 +36,10 @@ public static readonly List InvalidConnections new object[] { UnauthorizedConnection } }; } + + private static void ConfigureTestsHandler(HttpClientHandler handler) + { + handler.SslProtocols = SslProtocols.Tls12; + } } } \ No newline at end of file From 1d49c65b3d2bdb0e19676f5fa1827b100e87da15 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 18:20:13 +0200 Subject: [PATCH 11/15] No need for lambda's --- tests/YouTrackSharp.Tests/Infrastructure/Connections.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs index 7a524cea..d73c7ecd 100644 --- a/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs +++ b/tests/YouTrackSharp.Tests/Infrastructure/Connections.cs @@ -10,13 +10,13 @@ public static string ServerUrl => "https://ytsharp.myjetbrains.com/youtrack/"; public static Connection UnauthorizedConnection => - new BearerTokenConnection(ServerUrl, "invalidtoken", handler => ConfigureTestsHandler(handler)); + new BearerTokenConnection(ServerUrl, "invalidtoken", ConfigureTestsHandler); public static Connection Demo1Token => - new BearerTokenConnection(ServerUrl, "perm:ZGVtbzE=.WW91VHJhY2tTaGFycA==.AX3uf8RYk3y2bupWA1xyd9BhAHoAxc", handler => ConfigureTestsHandler(handler)); + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzE=.WW91VHJhY2tTaGFycA==.AX3uf8RYk3y2bupWA1xyd9BhAHoAxc", ConfigureTestsHandler); public static Connection Demo2Token => - new BearerTokenConnection(ServerUrl, "perm:ZGVtbzI=.WW91VHJhY2tTaGFycA==.GQEOl33LyTtmJvhWuz0Q629wbo8dk0", handler => ConfigureTestsHandler(handler)); + new BearerTokenConnection(ServerUrl, "perm:ZGVtbzI=.WW91VHJhY2tTaGFycA==.GQEOl33LyTtmJvhWuz0Q629wbo8dk0", ConfigureTestsHandler); public static Connection Demo3Token => new BearerTokenConnection(ServerUrl, "perm:ZGVtbzM=.WW91VHJhY2tTaGFycA==.L04RdcCnjyW2UPCVg1qyb6dQflpzFy", handler => ConfigureTestsHandler(handler)); From 9e1f2bd23512269ee72826b092a1ef84e51a4a7a Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 20:41:18 +0200 Subject: [PATCH 12/15] Add PackageLicenseExpression for new NuGet metadata format --- src/YouTrackSharp/YouTrackSharp.csproj | 2 +- tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/YouTrackSharp/YouTrackSharp.csproj b/src/YouTrackSharp/YouTrackSharp.csproj index bacd5056..3cd47211 100644 --- a/src/YouTrackSharp/YouTrackSharp.csproj +++ b/src/YouTrackSharp/YouTrackSharp.csproj @@ -5,7 +5,7 @@ True True https://raw.githubusercontent.com/JetBrains/YouTrackSharp/master/logo.png - https://github.com/JetBrains/YouTrackSharp/blob/master/LICENSE.txt + Apache-2.0 https://github.com/JetBrains/YouTrackSharp/ YouTrack JetBrains SDK 2019.1.0 diff --git a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj index bff07d9a..7f06ae94 100644 --- a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj +++ b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj @@ -7,7 +7,7 @@ JetBrains YouTrackSharp Tests for YouTrackSharp. - https://github.com/JetBrains/YouTrackSharp/blob/master/LICENSE.txt + Apache-2.0 JetBrains https://github.com/JetBrains/YouTrackSharp/ https://raw.githubusercontent.com/JetBrains/YouTrackSharp/master/logo.png From 02e2c4eeeb98df70bbe347ec2219f83d3ba1c52f Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 5 Apr 2019 20:51:01 +0200 Subject: [PATCH 13/15] Update xUnit dependency --- tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj index 7f06ae94..ab6d1602 100644 --- a/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj +++ b/tests/YouTrackSharp.Tests/YouTrackSharp.Tests.csproj @@ -19,8 +19,8 @@ - - + + all runtime; build; native; contentfiles; analyzers From 5116ca89c3362b51359c7764c6479467cb5bb0c8 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Mon, 8 Apr 2019 16:01:22 +0200 Subject: [PATCH 14/15] Add test for paging --- .../Integration/Issues/Querying/GetIssues.cs | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/YouTrackSharp.Tests/Integration/Issues/Querying/GetIssues.cs b/tests/YouTrackSharp.Tests/Integration/Issues/Querying/GetIssues.cs index 8d117b90..f76e5687 100644 --- a/tests/YouTrackSharp.Tests/Integration/Issues/Querying/GetIssues.cs +++ b/tests/YouTrackSharp.Tests/Integration/Issues/Querying/GetIssues.cs @@ -34,7 +34,44 @@ public async Task Valid_Connection_Returns_Issues() await temporaryIssueContext.Destroy(); } } - + + [Fact] + public async Task Valid_Connection_Page_Issues() + { + // Arrange + var connection = Connections.Demo1Token; + using (var temporaryIssueContext = await TemporaryIssueContext.Create(connection, GetType())) + { + var service = connection.CreateIssuesService(); + + await service.ApplyCommand(temporaryIssueContext.Issue.Id, "assignee me"); + + // Act + var totalResultsCount = 0; + + var skip = 0; + while (skip < 1000) + { + var result = await service.GetIssues("assignee: me", skip, take: 100); + if (result?.Count > 0) + { + totalResultsCount += result.Count; + } + else + { + break; + } + + skip += 100; + } + + // Assert + Assert.True(totalResultsCount > 100); + + await temporaryIssueContext.Destroy(); + } + } + [Fact] public async Task Invalid_Connection_Throws_UnauthorizedConnectionException() { From 971a910d274ac88e710e8000bd57e263715a283b Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Mon, 8 Apr 2019 16:20:40 +0200 Subject: [PATCH 15/15] Check for 400 status code as well --- src/YouTrackSharp/Management/UserManagementService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/YouTrackSharp/Management/UserManagementService.cs b/src/YouTrackSharp/Management/UserManagementService.cs index 8a5c39b0..28178a76 100644 --- a/src/YouTrackSharp/Management/UserManagementService.cs +++ b/src/YouTrackSharp/Management/UserManagementService.cs @@ -33,7 +33,7 @@ public async Task GetUser(string username) var client = await _connection.GetAuthenticatedHttpClient(); var response = await client.GetAsync($"rest/admin/user/{username}"); - if (response.StatusCode == HttpStatusCode.NotFound) + if (response.StatusCode == HttpStatusCode.NotFound || response.StatusCode == HttpStatusCode.BadRequest) { return null; }