aft-web-services
Version:
Automated Functional Testing (AFT) module for testing web services over HTTP and HTTPS
79 lines (78 loc) • 2.37 kB
TypeScript
/**
* a module containing helper const and functions to generate
* HTTP headers that can then be appended to your header object using:
* ```typescript
* const headers = {
* ...HttpHeaders.Authorization.basic('myUsername', 'myPassword'),
* ...HttpHeaders.ContentType.get(HttpHeaders.MimeType.applicationJson)
* ...HttpHeaders.Cookies.setCookie({
* key: 'foo',
* val: 'bar',
* expiration: new Date().toString('u'),
* secure: true,
* httpOnly: true
* })
* };
* ```
*/
export declare namespace HttpHeaders {
namespace MimeType {
const applicationOctetstream = "application/octet-stream";
const textPlain = "text/plain";
const textCss = "text/css";
const textHtml = "text/html";
const textXml = "text/xml";
const textJavascript = "text/javascript";
const multipartFormData = "multipart/form-data";
const applicationJson = "application/json";
}
namespace ContentType {
type CT = {
"Content-Type": string;
};
function get(mimeType: string): CT;
}
namespace Accept {
type Acc = {
"Accept": string;
};
function get(mimeType: string): Acc;
}
namespace Authorization {
type Auth = {
Authorization: string;
};
function basic(username: string, password: string): Auth;
function bearer(token: string): Auth;
type DigestOptions = {
username: string;
realm: string;
uri: string;
algorithm: string;
nonce: string;
nc: string;
cnonce: string;
qop: string;
response: string;
opaque: string;
};
function digest(options: Partial<DigestOptions>): Auth;
}
namespace Cookies {
type Cookie = {
Cookie: string;
};
type SetCookie = {
"Set-Cookie": string;
};
type SetCookieOptions = {
key: string;
val: string;
expires?: string;
secure?: boolean;
httpOnly?: boolean;
};
function cookie(...cookies: Array<Pick<SetCookieOptions, 'key' | 'val'>>): Cookie;
function setCookie(cookie: SetCookieOptions): SetCookie;
}
}