Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/update auth sdk #643

Merged
merged 9 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ public async Task UpsertSystemDataAsync<T>(string systemId, T data)
return dataList.FirstOrDefault().Value ?? default;
}

public async Task<Dictionary<Guid, T>> GetSystemListDataAsync<T>(IEnumerable<Guid> userIds, string systemId)
public async Task<Dictionary<Guid, T?>> GetSystemListDataAsync<T>(IEnumerable<Guid> userIds, string systemId)
{
var requestUri = $"api/user/systemData/byIds";
var data = await _caller.PostAsync<Dictionary<Guid, T>>(requestUri, new GetSystemDataModel { UserIds = userIds.ToList(), SystemId = systemId }) ?? new();
return data;
var data = await _caller.PostAsync<Dictionary<Guid, string>>(requestUri, new GetSystemDataModel { UserIds = userIds.ToList(), SystemId = systemId }) ?? new();
return data.ToDictionary(d => d.Key, d => typeof(T) == typeof(string) ? (T)(object)d.Value : JsonSerializer.Deserialize<T?>(d.Value));
}

public async Task<bool> DisableAsync(DisableUserModel user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,26 +515,6 @@ public async Task TestObjectGetUserSystemDataAsync(string systemId)
Assert.IsTrue(result is not null);
}

[TestMethod]
[DataRow("masa-auth")]
public async Task TestGetUserSystemDataAsync(string systemId)
{
var userIds = new List<Guid> { Guid.NewGuid() };
var data = new SystemData
{
Name = "name",
Value = "value"
};
var requestUri = $"api/user/systemData/byIds";
var caller = new Mock<ICaller>();
caller.Setup(provider => provider.GetAsync<object, string>(requestUri, new { userIds = string.Join(',', userIds), systemId }, default))
.ReturnsAsync(JsonSerializer.Serialize(data)).Verifiable();
var userContext = new Mock<IUserContext>();
var userService = GetUserService(caller, userContext);
var result = await userService.GetSystemListDataAsync<SystemData>(userIds, systemId);
Assert.IsTrue(result is not null);
}

[TestMethod]
[DataRow("masa-auth")]
public async Task TestIntUpsertSystemDataAsync(string systemId)
Expand Down
Loading