This commit is contained in:
1 parent
cdb4637c65
commit
f0c0479bcb
22 files changed
+1099
-76
No files matched your search
@@ -72,6 +72,48 @@ public sealed class WebUntisClientTests
|
||||
await client.DisposeAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTimetableGridAsync_ErzeugtBearerUndLiestExamMitDoppelblock()
|
||||
{
|
||||
var login = Json("{\"result\":{\"sessionId\":\"s\",\"personId\":89}}");
|
||||
login.Headers.TryAddWithoutValidation("Set-Cookie", "Tenant-Id=\"4026000\"; Path=/");
|
||||
var jwtPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"exp\":4102444800}"))
|
||||
.TrimEnd('=').Replace('+', '-').Replace('/', '_');
|
||||
var handler = new QueueHandler(
|
||||
login,
|
||||
new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent($"x.{jwtPayload}.signature", Encoding.UTF8, "application/json"),
|
||||
},
|
||||
Json("{\"format\":1,\"errors\":[],\"days\":[{\"gridEntries\":[{" +
|
||||
"\"ids\":[2002979,2002982],\"duration\":{\"start\":\"2026-09-29T09:40\"," +
|
||||
"\"end\":\"2026-09-29T11:10\"},\"type\":\"EXAM\",\"status\":\"REGULAR\"," +
|
||||
"\"lessonInfo\":\"Arbeit 1\",\"position1\":[{\"current\":{\"type\":\"CLASS\"," +
|
||||
"\"shortName\":\"10c\"},\"removed\":null}],\"position2\":[{\"current\":{" +
|
||||
"\"type\":\"SUBJECT\",\"shortName\":\"Mat_E\"},\"removed\":null}]}]}]}"),
|
||||
Json("{\"result\":{}}"));
|
||||
var client = CreateClient(handler);
|
||||
|
||||
var entries = await client.GetTimetableGridAsync(89, 22,
|
||||
new DateOnly(2026, 9, 28), new DateOnly(2026, 10, 2), CancellationToken.None);
|
||||
|
||||
var exam = Assert.Single(entries);
|
||||
Assert.Equal("EXAM", exam.Type);
|
||||
Assert.Equal(new DateTime(2026, 9, 29, 9, 40, 0), exam.Start);
|
||||
Assert.Equal(new DateTime(2026, 9, 29, 11, 10, 0), exam.End);
|
||||
Assert.Equal([2002979, 2002982], exam.Ids);
|
||||
Assert.Equal("10c", exam.CurrentResources.Single(resource => resource.Type == "CLASS").ShortName);
|
||||
Assert.Equal("Mat_E", exam.CurrentResources.Single(resource => resource.Type == "SUBJECT").ShortName);
|
||||
Assert.EndsWith("/WebUntis/api/token/new", handler.Requests[1].Uri);
|
||||
Assert.Contains("/api/rest/view/v1/timetable/entries", handler.Requests[2].Uri);
|
||||
Assert.Contains("start=2026-09-28&end=2026-10-02", handler.Requests[2].Uri);
|
||||
Assert.Equal("Bearer x." + jwtPayload + ".signature", handler.Requests[2].Authorization);
|
||||
Assert.Equal("22", handler.Requests[2].SchoolYearId);
|
||||
Assert.Contains("Tenant-Id=\"4026000\"", handler.Requests[2].Cookie);
|
||||
|
||||
await client.DisposeAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FehlendeKonfiguration_BrichtVorHttpRequestAb()
|
||||
{
|
||||
@@ -318,7 +360,9 @@ public sealed class WebUntisClientTests
|
||||
Requests.Add(new CapturedRequest(
|
||||
request.RequestUri?.ToString() ?? "",
|
||||
request.Content is null ? "" : await request.Content.ReadAsStringAsync(cancellationToken),
|
||||
string.Join("; ", request.Headers.TryGetValues("Cookie", out var cookies) ? cookies : [])));
|
||||
string.Join("; ", request.Headers.TryGetValues("Cookie", out var cookies) ? cookies : []),
|
||||
request.Headers.Authorization?.ToString() ?? "",
|
||||
string.Join("", request.Headers.TryGetValues("x-webuntis-api-school-year-id", out var years) ? years : [])));
|
||||
return _responses.Count > 0
|
||||
? _responses.Dequeue()
|
||||
: throw new InvalidOperationException("Keine Testantwort mehr vorhanden.");
|
||||
@@ -353,5 +397,6 @@ public sealed class WebUntisClientTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed record CapturedRequest(string Uri, string Body, string Cookie);
|
||||
private sealed record CapturedRequest(string Uri, string Body, string Cookie, string Authorization,
|
||||
string SchoolYearId);
|
||||
}
|
||||
Reference in new issue
Block a user