Skip to content

Commit 796c370

Browse files
Remove OAuth1.0 and basic authentication (#12)
* Remove OAuth1.0 * Update tests to use .net 8 * Removing basic Auth. Updating Auth tests to use oauth2. * Remove abstract auth client class and simplify hierarchy * Remove inheritance and use only interfaces. Add doc comments to interface and use inheritdoc. * Bump version number Add test results to ignore. * Allow easier testing --------- Co-authored-by: Alex Hennings <blackboxlogic@gmail.com>
1 parent 050ccce commit 796c370

14 files changed

Lines changed: 640 additions & 766 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ test-results*/
3333
.idea/*
3434

3535
packages/*
36-
!packages/repositories.config
36+
!packages/repositories.config
37+
.vs
38+
TestResults

OsmSharp.IO.API.Tests/NonAuthTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public void TestToStringCulture()
213213
const string doubleString = "-77.06719208";
214214

215215
var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
216-
var clientAsChild = client as NonAuthClient;
216+
var clientAsChild = client as OsmClient;
217217

218218
foreach (var culture in cultures)
219219
{

OsmSharp.IO.API.Tests/BasicAuthClientTests.cs renamed to OsmSharp.IO.API.Tests/OAuth2ClientTests.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using OsmSharp.API;
44
using OsmSharp.Changesets;
55
using OsmSharp.Tags;
6-
using System;
76
using System.IO;
87
using System.Linq;
98
using System.Net.Http;
@@ -12,8 +11,7 @@
1211
namespace OsmSharp.IO.API.Tests
1312
{
1413
[TestClass]
15-
[Ignore("Should only be ran manually - comment-out for testing, do not check-in")]
16-
public class BasicAuthClientTests
14+
public class OAuth2ClientTests
1715
{
1816
private IAuthClient client;
1917

@@ -26,7 +24,7 @@ public class BasicAuthClientTests
2624

2725
private static readonly TagsCollection ChangeSetTags = new TagsCollection()
2826
{
29-
new Tag("comment", "Running a functional test of an automated system."),
27+
new Tag("comment", "Running a functional test of an automation tool."),
3028
new Tag("created_by", "https://github.com/OsmSharp/osm-api-client/"),
3129
new Tag("bot", "yes")
3230
};
@@ -37,13 +35,12 @@ public void TestInitialize()
3735
using var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
3836
var logger = loggerFactory.CreateLogger("Tests");
3937
IClientsFactory clientFactory = new ClientsFactory(logger, new HttpClient(), ClientsFactory.DEVELOPMENT_URL);
40-
// Enter your user name and password here or OAuth credential below - do not check-in!
41-
client = clientFactory.CreateBasicAuthClient("user-email", "password");
42-
//client = clientFactory.CreateOAuthClient("customerkey", "customerSecret", "token", "tokenSecret");
43-
//client = clientFactory.CreateOAuth2Client("token");
38+
// Enter your OAuth2 credential below - do not check-in!
39+
client = clientFactory.CreateOAuth2Client("oAuth-token");
4440
}
4541

4642
[TestMethod]
43+
[Ignore("Should only be ran manually - comment-out for testing, do not check-in")]
4744
public async Task TestChangesetLifeCycle()
4845
{
4946
var user = await client.GetUserDetails();
@@ -101,6 +98,7 @@ public async Task TestChangesetLifeCycle()
10198
}
10299

103100
[TestMethod]
101+
[Ignore("Should only be ran manually - comment-out for testing, do not check-in")]
104102
public async Task TestPreferences()
105103
{
106104
var preferences = await client.GetUserPreferences();
@@ -122,6 +120,7 @@ public async Task TestPreferences()
122120
}
123121

124122
[TestMethod]
123+
[Ignore("Should only be ran manually - comment-out for testing, do not check-in")]
125124
public async Task TestNotes()
126125
{
127126
var permissions = await client.GetPermissions();
@@ -162,6 +161,7 @@ public async Task TestNotes()
162161
}
163162

164163
[TestMethod]
164+
[Ignore("Should only be ran manually - comment-out for testing, do not check-in")]
165165
public async Task TestTraces()
166166
{
167167
using var gpxStream = File.Open("test.gpx", FileMode.Open);
@@ -171,6 +171,7 @@ public async Task TestTraces()
171171
NewGpx.Description += updatedText;
172172
await client.UpdateTrace(NewGpx);
173173
var myTraces = await client.GetTraces();
174+
var originalLength = myTraces.Length;
174175
Assert.IsTrue(myTraces?.Length > 0);
175176
var gpxDetails = await client.GetTraceDetails(NewGpx.Id);
176177
Assert.IsNotNull(gpxDetails);
@@ -179,12 +180,9 @@ public async Task TestTraces()
179180
Assert.IsNotNull(gpxStreamBack.Stream);
180181
Assert.IsNotNull(gpxStreamBack.FileName);
181182
Assert.IsNotNull(gpxStreamBack.ContentType);
182-
foreach (var trace in myTraces)
183-
{
184-
await client.DeleteTrace(trace.Id);
185-
}
183+
await client.DeleteTrace(NewGpx.Id);
186184
myTraces = await client.GetTraces();
187-
Assert.AreEqual(0 ,myTraces?.Length);
185+
Assert.AreEqual(originalLength - 1, myTraces?.Length);
188186
}
189187
}
190188
}

OsmSharp.IO.API.Tests/OsmSharp.IO.API.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

0 commit comments

Comments
 (0)