chore: improve integration tests (#8727)

Improve integration tests:
- spliting the tests in TokenExchange to isolated instances and in
parallel
- corrected some test structure so that the check for Details is no done
anymore if the test already failed
- replace required-calls with assert-calls to not stop the testing
- add gofakeit for application, project and usernames(emails)
- add eventually checks for testing in actions v2, so the request only
get called when the execution is defined
- check for length of results in list/search endpoints to avoid index
errors

(cherry picked from commit 8d97363642)
This commit is contained in:
Stefan Benz
2024-10-17 23:20:57 +02:00
committed by Livio Spring
parent b6fad5ac83
commit 63a9312a8e
47 changed files with 719 additions and 649 deletions

View File

@@ -4,11 +4,11 @@ package org_test
import (
"context"
"fmt"
"os"
"testing"
"time"
"github.com/brianvoe/gofakeit/v6"
"github.com/muhlemmer/gu"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -72,7 +72,7 @@ func TestServer_AddOrganization(t *testing.T) {
name: "invalid admin type",
ctx: CTX,
req: &org.AddOrganizationRequest{
Name: fmt.Sprintf("%d", time.Now().UnixNano()),
Name: gofakeit.AppName(),
Admins: []*org.AddOrganizationRequest_Admin{
{},
},
@@ -83,7 +83,7 @@ func TestServer_AddOrganization(t *testing.T) {
name: "admin with init",
ctx: CTX,
req: &org.AddOrganizationRequest{
Name: fmt.Sprintf("%d", time.Now().UnixNano()),
Name: gofakeit.AppName(),
Admins: []*org.AddOrganizationRequest_Admin{
{
UserType: &org.AddOrganizationRequest_Admin_Human{
@@ -93,7 +93,7 @@ func TestServer_AddOrganization(t *testing.T) {
FamilyName: "lastname",
},
Email: &user_v2beta.SetHumanEmail{
Email: fmt.Sprintf("%d@mouse.com", time.Now().UnixNano()),
Email: gofakeit.Email(),
Verification: &user_v2beta.SetHumanEmail_ReturnCode{
ReturnCode: &user_v2beta.ReturnEmailVerificationCode{},
},
@@ -118,7 +118,7 @@ func TestServer_AddOrganization(t *testing.T) {
name: "existing user and new human with idp",
ctx: CTX,
req: &org.AddOrganizationRequest{
Name: fmt.Sprintf("%d", time.Now().UnixNano()),
Name: gofakeit.AppName(),
Admins: []*org.AddOrganizationRequest_Admin{
{
UserType: &org.AddOrganizationRequest_Admin_UserId{UserId: User.GetUserId()},
@@ -131,7 +131,7 @@ func TestServer_AddOrganization(t *testing.T) {
FamilyName: "lastname",
},
Email: &user_v2beta.SetHumanEmail{
Email: fmt.Sprintf("%d@mouse.com", time.Now().UnixNano()),
Email: gofakeit.Email(),
Verification: &user_v2beta.SetHumanEmail_IsVerified{
IsVerified: true,
},