mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-13 06:49:38 -05:00
cleanup defaults
update README.md
This commit is contained in:
+1
-1
@@ -19,6 +19,6 @@ k6 run ./dist/test/NAME_OF_TEST.js
|
||||
$ OC_LOGIN=USERNAME OC_PASSWORD=PASSWORD k6 run ...
|
||||
$ OC_HOST=URL k6 run ...
|
||||
$ OC_OIDC_HOST=URL k6 run ...
|
||||
$ OC_OIDC=BOOL k6 run ...
|
||||
$ OC_OIDC_ENABLED=BOOL k6 run ...
|
||||
$ OC_TEST_FILE=STRING k6 run ...
|
||||
```
|
||||
@@ -7,7 +7,7 @@ export const fileUpload = <RT extends ResponseType | undefined>(
|
||||
{credential, userName, asset}: { credential: types.Credential; userName: string; asset: types.Asset }
|
||||
): RefinedResponse<RT> => {
|
||||
return http.put(
|
||||
`${defaults.OC_HOST}/remote.php/dav/files/${userName}/${asset.fileName}`,
|
||||
`${defaults.ENV.HOST}/remote.php/dav/files/${userName}/${asset.fileName}`,
|
||||
asset.bytes as any,
|
||||
{
|
||||
headers: {
|
||||
@@ -21,7 +21,7 @@ export const fileDownload = <RT extends ResponseType | undefined>(
|
||||
{credential, userName, fileName}: { credential: types.Credential; userName: string; fileName: string }
|
||||
): RefinedResponse<RT> => {
|
||||
return http.get(
|
||||
`${defaults.OC_HOST}/remote.php/dav/files/${userName}/${fileName}`,
|
||||
`${defaults.ENV.HOST}/remote.php/dav/files/${userName}/${fileName}`,
|
||||
{
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
@@ -34,7 +34,7 @@ export const fileDelete = <RT extends ResponseType | undefined>(
|
||||
{credential, userName, fileName}: { credential: types.Credential; userName: string; fileName: string }
|
||||
): RefinedResponse<RT> => {
|
||||
return http.del(
|
||||
`${defaults.OC_HOST}/remote.php/dav/files/${userName}/${fileName}`,
|
||||
`${defaults.ENV.HOST}/remote.php/dav/files/${userName}/${fileName}`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -7,7 +7,7 @@ export const userInfo = <RT extends ResponseType | undefined>(
|
||||
{credential, userName}: { credential: types.Credential; userName: string; }
|
||||
): RefinedResponse<RT> => {
|
||||
return http.get(
|
||||
`${defaults.OC_HOST}/ocs/v1.php/cloud/users/${userName}`,
|
||||
`${defaults.ENV.HOST}/ocs/v1.php/cloud/users/${userName}`,
|
||||
{
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
|
||||
@@ -13,13 +13,12 @@ export default class Factory {
|
||||
constructor(account: types.Account) {
|
||||
this.account = account;
|
||||
|
||||
if (defaults.OC_OIDC) {
|
||||
if (defaults.ENV.OIDC_ENABLED) {
|
||||
this.provider = new OIDCProvider(account);
|
||||
return
|
||||
}
|
||||
|
||||
if (!defaults.OC_OIDC) {
|
||||
this.provider = new AccountProvider(account);
|
||||
}
|
||||
this.provider = new AccountProvider(account);
|
||||
}
|
||||
|
||||
public get credential(): types.Credential {
|
||||
@@ -41,9 +40,9 @@ class AccountProvider implements types.AuthProvider {
|
||||
|
||||
class OIDCProvider implements types.AuthProvider {
|
||||
private account: types.Account;
|
||||
private redirectUri = `${defaults.OC_OIDC_HOST}/oidc-callback.html`;
|
||||
private logonUri = `${defaults.OC_OIDC_HOST}/signin/v1/identifier/_/logon`;
|
||||
private tokenUrl = `${defaults.OC_OIDC_HOST}/konnect/v1/token`;
|
||||
private redirectUri = `${defaults.ENV.OIDC_HOST}/oidc-callback.html`;
|
||||
private logonUri = `${defaults.ENV.OIDC_HOST}/signin/v1/identifier/_/logon`;
|
||||
private tokenUrl = `${defaults.ENV.OIDC_HOST}/konnect/v1/token`;
|
||||
private cache!: {
|
||||
validTo: Date;
|
||||
token: types.Token;
|
||||
@@ -93,7 +92,7 @@ class OIDCProvider implements types.AuthProvider {
|
||||
{
|
||||
headers: {
|
||||
'Kopano-Konnect-XSRF': '1',
|
||||
Referer: defaults.OC_OIDC_HOST,
|
||||
Referer: defaults.ENV.OIDC_HOST,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import * as types from './types';
|
||||
import {Options} from "k6/options";
|
||||
|
||||
const ocTestFile = '../_files/' + (__ENV.OC_TEST_FILE || 'kb_50.jpg').split('/').pop()
|
||||
export const OC_HOST = __ENV.OC_HOST || 'https://localhost:9200'
|
||||
export const OC_LOGIN = __ENV.OC_LOGIN
|
||||
export const OC_PASSWORD = __ENV.OC_PASSWORD
|
||||
export const OC_OIDC_HOST = __ENV.OC_OIDC_HOST || OC_HOST
|
||||
export const OC_OIDC = __ENV.OC_OIDC === 'true' || false
|
||||
export const OC_TEST_FILE = {
|
||||
fileName: ocTestFile,
|
||||
bytes: open(ocTestFile, 'b'),
|
||||
export class K6 {
|
||||
public static readonly OPTIONS: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
iterations: 1,
|
||||
vus: 1,
|
||||
};
|
||||
}
|
||||
export const K6_OPTION_DEFAULTS: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
|
||||
export class ENV {
|
||||
public static readonly HOST = __ENV.OC_HOST || 'https://localhost:9200';
|
||||
public static readonly LOGIN = __ENV.OC_LOGIN;
|
||||
public static readonly PASSWORD = __ENV.OC_PASSWORD;
|
||||
public static readonly OIDC_HOST = __ENV.OC_OIDC_HOST || ENV.HOST;
|
||||
public static readonly OIDC_ENABLED = __ENV.OC_OIDC_ENABLED === 'true' || false;
|
||||
public static readonly FILE_NAME = '../_files/' + (__ENV.OC_TEST_FILE || 'kb_50.jpg').split('/').pop();
|
||||
}
|
||||
|
||||
export const FILE = {
|
||||
fileName: ENV.FILE_NAME,
|
||||
bytes: open(ENV.FILE_NAME, 'b'),
|
||||
};
|
||||
|
||||
export class ACCOUNTS {
|
||||
export class ACCOUNT {
|
||||
public static readonly EINSTEIN = 'einstein';
|
||||
public static readonly RICHARD = 'richard';
|
||||
private static readonly list: { [key: string]: types.Account; } = {
|
||||
@@ -30,10 +38,10 @@ export class ACCOUNTS {
|
||||
}
|
||||
|
||||
public static for(key: string): types.Account {
|
||||
if (OC_LOGIN && OC_PASSWORD) {
|
||||
if (ENV.LOGIN && ENV.PASSWORD) {
|
||||
return {
|
||||
login: OC_LOGIN,
|
||||
password: OC_PASSWORD,
|
||||
login: ENV.LOGIN,
|
||||
password: ENV.PASSWORD,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,28 +4,25 @@ import {sleep} from "k6";
|
||||
import auth from "../../lib/auth";
|
||||
|
||||
export const options: Options = {
|
||||
...defaults.K6_OPTION_DEFAULTS,
|
||||
iterations: 1,
|
||||
vus: 1,
|
||||
...defaults.K6.OPTIONS,
|
||||
};
|
||||
const authFactory = new auth(defaults.ACCOUNTS.for(defaults.ACCOUNTS.EINSTEIN));
|
||||
const playbooks = {
|
||||
const authFactory = new auth(defaults.ACCOUNT.for(defaults.ACCOUNT.EINSTEIN));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload(),
|
||||
fileDownload: playbook.dav.fileDownload(),
|
||||
fileDelete: playbook.dav.fileDelete(),
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const {login: userName} = authFactory.account;
|
||||
const fileName = playbooks.fileUpload({
|
||||
const fileName = plays.fileUpload({
|
||||
credential: authFactory.credential,
|
||||
userName,
|
||||
asset: defaults.OC_TEST_FILE
|
||||
asset: defaults.FILE,
|
||||
});
|
||||
|
||||
sleep(1)
|
||||
|
||||
playbooks.fileDownload({
|
||||
plays.fileDownload({
|
||||
credential: authFactory.credential,
|
||||
userName,
|
||||
fileName,
|
||||
@@ -33,7 +30,7 @@ export default () => {
|
||||
|
||||
sleep(1)
|
||||
|
||||
playbooks.fileDelete({
|
||||
plays.fileDelete({
|
||||
credential: authFactory.credential,
|
||||
userName,
|
||||
fileName,
|
||||
|
||||
@@ -4,26 +4,24 @@ import {sleep} from "k6";
|
||||
import auth from "../../lib/auth";
|
||||
|
||||
export const options: Options = {
|
||||
...defaults.K6_OPTION_DEFAULTS,
|
||||
iterations: 1,
|
||||
vus: 1,
|
||||
...defaults.K6.OPTIONS,
|
||||
};
|
||||
const authFactory = new auth(defaults.ACCOUNTS.for(defaults.ACCOUNTS.EINSTEIN));
|
||||
const playbooks = {
|
||||
const authFactory = new auth(defaults.ACCOUNT.for(defaults.ACCOUNT.EINSTEIN));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload(),
|
||||
fileDelete: playbook.dav.fileDelete(),
|
||||
}
|
||||
export default () => {
|
||||
const {login: userName} = authFactory.account;
|
||||
const fileName = playbooks.fileUpload({
|
||||
const fileName = plays.fileUpload({
|
||||
credential: authFactory.credential,
|
||||
userName,
|
||||
asset: defaults.OC_TEST_FILE
|
||||
asset: defaults.FILE,
|
||||
});
|
||||
|
||||
sleep(1)
|
||||
|
||||
playbooks.fileDelete({
|
||||
plays.fileDelete({
|
||||
credential: authFactory.credential,
|
||||
userName,
|
||||
fileName,
|
||||
|
||||
Reference in New Issue
Block a user