ability to set username and password from env

rename OC_OCIS_HOST to OC_HOST to make it more clear that the oc10 api is backward compatible
This commit is contained in:
Florian Schade
2020-11-29 22:21:40 +01:00
parent 5ee7bad25c
commit 1558b2a472
6 changed files with 26 additions and 8 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ export const fileUpload = <RT extends ResponseType | undefined>(
{credential, userName, asset}: { credential: types.Account | types.Token; userName: string; asset: types.Asset }
): RefinedResponse<RT> => {
return http.put(
`${defaults.OC_OCIS_HOST}/remote.php/dav/files/${userName}/${asset.fileName}`,
`${defaults.OC_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.Account | types.Token; userName: string; fileName: string }
): RefinedResponse<RT> => {
return http.get(
`${defaults.OC_OCIS_HOST}/remote.php/dav/files/${userName}/${fileName}`,
`${defaults.OC_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.Account | types.Token; userName: string; fileName: string }
): RefinedResponse<RT> => {
return http.del(
`${defaults.OC_OCIS_HOST}/remote.php/dav/files/${userName}/${fileName}`,
`${defaults.OC_HOST}/remote.php/dav/files/${userName}/${fileName}`,
{},
{
headers: {
+1 -1
View File
@@ -7,7 +7,7 @@ export const userInfo = <RT extends ResponseType | undefined>(
{credential, userName}: { credential: types.Account | types.Token; userName: string; }
): RefinedResponse<RT> => {
return http.get(
`${defaults.OC_OCIS_HOST}/ocs/v1.php/cloud/users/${userName}`,
`${defaults.OC_HOST}/ocs/v1.php/cloud/users/${userName}`,
{
headers: {
...api.headersDefault({credential})
+4 -2
View File
@@ -2,8 +2,10 @@ 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_OCIS_HOST = __ENV.OC_OCIS_HOST || 'https://localhost:9200'
export const OC_OIDC_HOST = __ENV.OC_OIDC_HOST || OC_OCIS_HOST
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,
+14
View File
@@ -1,3 +1,6 @@
import * as types from "./types";
import * as defaults from "./defaults";
export const randomString = (): string => {
return Math.random().toString(36).slice(2)
}
@@ -6,3 +9,14 @@ export const extension = (p: string): string | undefined => {
return (p.split('/').pop())!.split('.').pop()
}
export const getAccount = (key: string): types.Account => {
if (defaults.OC_LOGIN && defaults.OC_PASSWORD) {
return {
login: defaults.OC_LOGIN,
password: defaults.OC_PASSWORD,
}
}
return defaults.knownAccounts[key];
}
+2 -1
View File
@@ -3,6 +3,7 @@ import {Options} from 'k6/options';
import {sleep} from "k6";
import * as auth from "../../lib/auth";
import * as types from "../../lib/types";
import * as utils from "../../lib/utils";
interface dataI {
credential: types.Account | types.Token;
@@ -13,7 +14,7 @@ export const options: Options = {
iterations: 1,
vus: 1,
};
const account = defaults.knownAccounts.einstein;
const account = utils.getAccount('einstein');
const playbooks = {
fileUpload: playbook.dav.fileUpload(),
fileDownload: playbook.dav.fileDownload(),
+2 -1
View File
@@ -3,6 +3,7 @@ import {Options} from 'k6/options';
import {sleep} from "k6";
import * as auth from "../../lib/auth";
import * as types from "../../lib/types";
import * as utils from "../../lib/utils";
interface dataI {
credential: types.Account | types.Token;
@@ -13,7 +14,7 @@ export const options: Options = {
iterations: 1,
vus: 1,
};
const account = defaults.knownAccounts.einstein;
const account = utils.getAccount('einstein');
const playbooks = {
fileUpload: playbook.dav.fileUpload(),
fileDelete: playbook.dav.fileDelete(),