@@ -11,34 +11,31 @@ import {
1111import test , { expect } from "@playwright/test" ;
1212import { Zodios , ZodiosInstance } from "@zodios/core" ;
1313import AdmZip from "adm-zip" ;
14- import { getPresignedPutUrl , S3Client } from "s3-helpers" ;
14+ import { authConfig } from "common-helpers" ;
15+ //import { getPresignedPutUrl, S3Client } from "s3-helpers";
1516import { dosAPI , userAPI } from "validation-helpers" ;
1617
1718/**
1819 * Construct Zodios callers for the API endpoints to easily call them in the tests.
1920 */
2021
21- const server = process . env . KEYCLOAK_URL ;
22- const realm = process . env . KEYCLOAK_REALM ;
23- const clientId = process . env . KEYCLOAK_CLIENT_ID_API ;
24- const clientSecret = process . env . KEYCLOAK_CLIENT_SECRET_API ;
25- const username = process . env . E2E_USER_USERNAME ;
26- const password = process . env . E2E_USER_PASSWORD ;
27-
28- if ( ! server || ! realm || ! clientId || ! clientSecret || ! username || ! password ) {
29- throw new Error (
30- "KEYCLOAK_URL, KEYCLOAK_REALM, KEYCLOAK_CLIENT_ID_API, KEYCLOAK_CLIENT_SECRET_API, E2E_USER_USERNAME and E2E_USER_PASSWORD environment variables must be set" ,
31- ) ;
32- }
22+ const server = authConfig . url ;
23+ const realm = authConfig . realm ;
24+ const clientId = authConfig . clientIdUI ;
25+ const clientSecret = authConfig . clientSecretUI ;
26+ const username = "test-user" ;
27+ const password = "test-user" ;
28+ const apiUrl = process . env . E2E_API_BASE_URL || "http://localhost:5000" ;
3329
30+ /*
3431const s3Client = S3Client(
3532 process.env.NODE_ENV !== "production",
3633 // This needs to be localhost instead of SPACES_ENDPOINT due to the containers needing to access
3734 // Minio with SPACES_ENDPOINT, but the tests needing to access Minio with localhost.
3835 "http://localhost:9000",
3936 process.env.SPACES_KEY,
4037 process.env.SPACES_SECRET,
41- ) ;
38+ );*/
4239
4340test . describe ( "API lets authenticated users to" , ( ) => {
4441 let keycloakToken : string ;
@@ -72,7 +69,7 @@ test.describe("API lets authenticated users to", () => {
7269 const body = await result . json ( ) ;
7370 keycloakToken = ( body as { access_token : string } ) . access_token ;
7471
75- userZodios = new Zodios ( "http://localhost:3001/ api/user/" , userAPI , {
72+ userZodios = new Zodios ( ` ${ apiUrl } / api/user/` , userAPI , {
7673 axiosConfig : {
7774 headers : {
7875 Authorization : `Bearer ${ keycloakToken } ` ,
@@ -88,7 +85,7 @@ test.describe("API lets authenticated users to", () => {
8885
8986 dosToken = userToken . token ;
9087
91- dosZodios = new Zodios ( "http://localhost:3001/ api/" , dosAPI , {
88+ dosZodios = new Zodios ( ` ${ apiUrl } / api/` , dosAPI , {
9289 axiosConfig : {
9390 headers : {
9491 Authorization : `Bearer ${ dosToken } ` ,
@@ -133,11 +130,18 @@ test.describe("API lets authenticated users to", () => {
133130 * running on host. This means that we need to create the presigned URL with an external S3
134131 * client that can access the Minio on localhost.
135132 */
133+ /*
136134 const presignedUrl = await getPresignedPutUrl(
137135 s3Client,
138136 "doubleopen",
139137 zipKey,
140- ) ;
138+ );*/
139+
140+ const presignedUrl = (
141+ await dosZodios . post ( "/upload-url" , {
142+ key : zipKey ,
143+ } )
144+ ) . presignedUrl ;
141145
142146 expect ( presignedUrl ) . toBeDefined ( ) ;
143147
0 commit comments