Skip to content

Commit 004e5c6

Browse files
committed
feat(sdk): updated auth check to use project properties
1 parent 4a65372 commit 004e5c6

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Kepware.Api.Test/ApiClient/_TestApiClientBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ protected void ConfigureConnectedClient(
100100

101101
_httpMessageHandlerMock.SetupRequest(HttpMethod.Get, $"{TEST_ENDPOINT}/config/v1/doc")
102102
.ReturnsResponse(HttpStatusCode.OK, statusResponse, "application/json");
103+
104+
_httpMessageHandlerMock.SetupRequest(HttpMethod.Get, $"{TEST_ENDPOINT}/config/v1/project")
105+
.ReturnsResponse(HttpStatusCode.OK, "[]", "application/json");
103106
}
104107

105108
protected Channel CreateTestChannel(string name = "TestChannel", string driver = "Advanced Simulator")

Kepware.Api/KepwareApiClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public partial class KepwareApiClient : IKepwareDefaultValueProvider
3333
private const string ENDPOINT_STATUS = "/config/v1/status";
3434
private const string ENDPOINT_DOC = "/config/v1/doc";
3535
private const string ENDPOINT_ABOUT = "/config/v1/about";
36+
private const string ENDPOINT_PROJECT = "/config/v1/project";
3637

3738
private readonly ILogger<KepwareApiClient> m_logger;
3839
private readonly HttpClient m_httpClient;
@@ -243,7 +244,8 @@ private async Task<bool> TestCredentialsAsync(CancellationToken cancellationToke
243244
bool hasValidCredentials = false;
244245
try
245246
{
246-
var response = await m_httpClient.GetAsync(ENDPOINT_DOC, cancellationToken).ConfigureAwait(false);
247+
248+
var response = await m_httpClient.GetAsync(ENDPOINT_PROJECT, cancellationToken).ConfigureAwait(false);
247249
hasValidCredentials = response.IsSuccessStatusCode;
248250
if (hasValidCredentials)
249251
{

0 commit comments

Comments
 (0)