mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
@@ -956,6 +956,7 @@ export class Subsonic implements MusicService {
|
||||
};
|
||||
|
||||
if (credentials.type == "navidrome") {
|
||||
// todo: there does not seem to be a test for this??
|
||||
return Promise.resolve({
|
||||
...genericSubsonic,
|
||||
flavour: () => "navidrome",
|
||||
@@ -964,7 +965,7 @@ export class Subsonic implements MusicService {
|
||||
TE.tryCatch(
|
||||
() =>
|
||||
axios.post(
|
||||
`${this.url}/auth/login`,
|
||||
this.url.append({ pathname: '/auth/login' }).href(),
|
||||
_.pick(credentials, "username", "password")
|
||||
),
|
||||
() => new AuthFailure("Failed to get bearerToken")
|
||||
|
||||
@@ -928,6 +928,34 @@ describe("Subsonic", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("bearerToken", () => {
|
||||
describe("when flavour is generic subsonic", () => {
|
||||
it("should return undefined", async () => {
|
||||
const credentials = { username: "foo", password: "bar" };
|
||||
const token = { ...credentials, type: "subsonic", bearer: undefined }
|
||||
const client = await subsonic.login(asToken(token));
|
||||
|
||||
const bearerToken = await pipe(client.bearerToken(credentials))();
|
||||
expect(bearerToken).toStrictEqual(E.right(undefined));
|
||||
});
|
||||
});
|
||||
|
||||
describe("when flavour is navidrome", () => {
|
||||
it("should get a bearerToken from navidrome", async () => {
|
||||
const credentials = { username: "foo", password: "bar" };
|
||||
const token = { ...credentials, type: "navidrome", bearer: undefined }
|
||||
const client = await subsonic.login(asToken(token));
|
||||
|
||||
mockPOST.mockImplementationOnce(() => Promise.resolve(ok({ token: 'theBearerToken' })))
|
||||
|
||||
const bearerToken = await pipe(client.bearerToken(credentials))();
|
||||
expect(bearerToken).toStrictEqual(E.right('theBearerToken'));
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(url.append({ pathname: '/auth/login' }).href(), credentials)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getting genres", () => {
|
||||
describe("when there are none", () => {
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user