• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-js / 3698619628

pending completion
3698619628

Pull #4389

github

GitHub
Merge 33a6b02b4 into e5f7e3abe
Pull Request #4389: chore(deps): bump express from 4.17.1 to 4.17.3

9686 of 12680 branches covered (76.39%)

Branch coverage included in aggregate %.

19968 of 22357 relevant lines covered (89.31%)

3197.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.67
/libraries/botframework-connector/src/emulatorApiClient.ts
1
/**
2
 * @module botframework-connector
3
 */
4
/**
5
 * Copyright (c) Microsoft Corporation. All rights reserved.
6
 * Licensed under the MIT License.
7
 */
8

9
import { AppCredentials } from './auth/appCredentials';
10
import fetch from 'cross-fetch';
1✔
11

12
/**
13
 * The purpose of this class is to emulate an api client.
14
 */
15
export class EmulatorApiClient {
1✔
16
    /**
17
     * OAuth card emulation.
18
     *
19
     * @remarks If the emulation fails, an error containing the status code from the server is thrown.
20
     *
21
     * @param credentials [AppCredentials](xref:botframework-connector.AppCredentials) for OAuth.
22
     * @param emulatorUrl The URL of the emulator.
23
     * @param emulate `true` to send an emulated OAuth card to the emulator; or `false` to not send the card.
24
     * @returns `true` on a successful emulation of OAuthCards.
25
     */
26
    static async emulateOAuthCards(
27
        credentials: AppCredentials,
28
        emulatorUrl: string,
29
        emulate: boolean
30
    ): Promise<boolean> {
31
        const token = await credentials.getToken();
×
32
        const requestUrl: string =
33
            emulatorUrl +
×
34
            (emulatorUrl.endsWith('/') ? '' : '/') +
×
35
            `api/usertoken/emulateOAuthCards?emulate=${(!!emulate).toString()}`;
36
        const res = await fetch(requestUrl, {
×
37
            method: 'POST',
38
            headers: {
39
                Authorization: `Bearer ${token}`,
40
            },
41
        });
42

43
        if (res.ok) {
×
44
            return true;
×
45
        } else {
46
            throw new Error(`EmulateOAuthCards failed with status code: ${res.status}`);
×
47
        }
48
    }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc