Part of AppLink login process

This commit is contained in:
simojenki
2021-02-21 09:35:34 +11:00
parent 302efd2878
commit c26a325ee1
20 changed files with 644 additions and 253 deletions

View File

@@ -1,38 +1,22 @@
import request from "supertest";
import makeServer from "../src/server";
import { SONOS_DISABLED } from "../src/sonos";
import { SONOS_DISABLED, SOAP_PATH } from "../src/sonos";
import { aService } from "./builders";
import { aService, InMemoryMusicService } from "./builders";
import supersoap from './supersoap';
import { createClientAsync } from "soap";
describe("ws", () => {
describe("can call getSessionId", () => {
it("should do something", async () => {
const server = makeServer(SONOS_DISABLED, aService());
const WEB_ADDRESS = 'http://localhost:7653'
const server = makeServer(SONOS_DISABLED, aService(), WEB_ADDRESS, new InMemoryMusicService());
const { username, sessionId } = await createClientAsync(
`http://localhost/ws?wsdl`,
`${WEB_ADDRESS}${SOAP_PATH}?wsdl`,
{
endpoint: `http://localhost/ws`,
httpClient: {
request: (
rurl: string,
data: any,
callback: (error: any, res?: any, body?: any) => any,
exheaders?: any
) => {
const withoutHost = rurl.replace("http://localhost", "");
const req =
data == null
? request(server).get(withoutHost).send()
: request(server).post(withoutHost).send(data);
req
.set(exheaders || {})
.then((response) => callback(null, response, response.text))
.catch(callback);
},
},
endpoint: `${WEB_ADDRESS}${SOAP_PATH}`,
httpClient: supersoap(server, WEB_ADDRESS),
}
).then((client) =>
client