mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
47 lines
3.2 KiB
TypeScript
47 lines
3.2 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import nock from 'nock';
|
|
import { BaseMock } from '../base.mock';
|
|
|
|
export class OAuthMock extends BaseMock {
|
|
username: string;
|
|
password: string;
|
|
|
|
constructor(host?: string, username?: string, password?: string) {
|
|
super(host);
|
|
this.username = username || 'admin';
|
|
this.password = password || 'admin';
|
|
}
|
|
|
|
get200Response(mockToken?: string): void {
|
|
nock(this.host, { encodedQueryParams: true })
|
|
.post('/auth/realms/springboot/protocol/openid-connect/token')
|
|
.reply(200, {
|
|
access_token: mockToken || 'test-token',
|
|
expires_in: 300,
|
|
refresh_expires_in: 1800,
|
|
refresh_token:
|
|
// eslint-disable-next-line max-len
|
|
'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI0cHczOUltNE54dXZEN0ZqZ3JOQ3Q2ZkpaVDctQ3JWTzRkX3BLaXJlSTF3In0.eyJqdGkiOiI2MzQxMDc1ZC1lOTY4LTRmZTctOTkwZS05MTQ3NTUwOGEzZWIiLCJleHAiOjE1Mjk2MDkxMDYsIm5iZiI6MCwiaWF0IjoxNTI5NjA3MzA2LCJpc3MiOiJodHRwOi8vYTVlMmY5M2RlMTBhZjExZThhMDU2MGExYmVhNWI3YzgtMjM2NzA5N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