diff --git a/eeg_backend/src/test/java/at/mueller/eeg/backend/OpenApiGeneratorTest.java b/eeg_backend/src/test/java/at/mueller/eeg/backend/OpenApiGeneratorTest.java index cdd92b4..dde84a3 100644 --- a/eeg_backend/src/test/java/at/mueller/eeg/backend/OpenApiGeneratorTest.java +++ b/eeg_backend/src/test/java/at/mueller/eeg/backend/OpenApiGeneratorTest.java @@ -11,6 +11,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -34,5 +35,13 @@ class OpenApiGeneratorTest { Files.writeString(outputPath, openApiYaml, StandardCharsets.UTF_8); System.out.println("OpenAPI YAML erfolgreich nach " + outputPath.toAbsolutePath() + " exportiert."); + + // Verify acceptance criteria + assertTrue(openApiYaml.contains("/api/community/admin/memberships"), + "OpenAPI Spec muss /api/community/admin/memberships enthalten"); + assertTrue(openApiYaml.contains("/api/admin/users"), + "OpenAPI Spec muss /api/admin/users enthalten"); + assertTrue(openApiYaml.contains("getAllUsers"), + "OpenAPI Spec muss getAllUsers Operation enthalten"); } } diff --git a/eeg_frontend/src/app/api/api/adminIAM.service.ts b/eeg_frontend/src/app/api/api/adminIAM.service.ts index e260eb4..c0cbfea 100644 --- a/eeg_frontend/src/app/api/api/adminIAM.service.ts +++ b/eeg_frontend/src/app/api/api/adminIAM.service.ts @@ -91,6 +91,59 @@ export class AdminIAMService extends BaseService { ); } + /** + * Lädt alle User + * Zeigt alle registrierten Benutzer sortiert nach Erstellungsdatum (neueste zuerst). + * @endpoint get /api/admin/users + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + * @param options additional options + */ + public getAllUsers(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAllUsers(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getAllUsers(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getAllUsers(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/admin/users`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + /** * Lädt alle wartenden User * Zeigt User im Status PENDING inkl. der Ergebnisse des EDA-Netz-Checks. @@ -144,58 +197,6 @@ export class AdminIAMService extends BaseService { ); } - /** - * Lädt alle User - * Zeigt alle registrierten Benutzer. - * @endpoint get /api/admin/users - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - * @param options additional options - */ - public getAllUsers(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAllUsers(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAllUsers(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAllUsers(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - - let localVarHeaders = this.defaultHeaders; - - const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/json' - ]); - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); - - const localVarTransferCache: boolean = options?.transferCache ?? true; - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/api/admin/users`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request>('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); - } - /** * User ablehnen * Lehnt den Antrag ab (z.B. weil Zählpunkt nicht ins Netz passt). diff --git a/eeg_frontend/src/app/pages/user-tariff/user-tariff.ts b/eeg_frontend/src/app/pages/user-tariff/user-tariff.ts index ba001ab..a472e9d 100644 --- a/eeg_frontend/src/app/pages/user-tariff/user-tariff.ts +++ b/eeg_frontend/src/app/pages/user-tariff/user-tariff.ts @@ -189,9 +189,7 @@ export class UserTariffComponent implements OnInit, OnDestroy { onDelete(tariff: UserTariffResponse) { if (!confirm('Möchtest du diesen Tarif wirklich löschen?')) return; - const userId = this.authService.getCurrentUserId(); - if (!userId) return; - this.userTariffService.deleteUserTariff(tariff.id!, userId).subscribe({ + this.userTariffService.deleteUserTariff(tariff.id!).subscribe({ next: () => { this.toastService.success('Tarif erfolgreich gelöscht.'); this.loadUserTariffs(this.selectedCommunityId());