func (c *LoginController) Generate(ctx *app.GenerateLoginContext) error {
	var tokens app.AuthTokenCollection

	tokenEndpoint, err := c.configuration.GetKeycloakEndpointToken(ctx.RequestData)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))
	}

	testuser, err := GenerateUserToken(ctx, tokenEndpoint, c.configuration, c.configuration.GetKeycloakTestUserName(), c.configuration.GetKeycloakTestUserSecret())
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to generate test token "+err.Error()))
	}
	// Creates the testuser user and identity if they don't yet exist
	c.auth.CreateOrUpdateKeycloakUser(*testuser.Token.AccessToken, ctx)
	tokens = append(tokens, testuser)

	testuser, err = GenerateUserToken(ctx, tokenEndpoint, c.configuration, c.configuration.GetKeycloakTestUser2Name(), c.configuration.GetKeycloakTestUser2Secret())
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to generate test token "+err.Error()))
	}
	// Creates the testuser2 user and identity if they don't yet exist
	c.auth.CreateOrUpdateKeycloakUser(*testuser.Token.AccessToken, ctx)
	tokens = append(tokens, testuser)

	// jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))
	return ctx.OK(tokens)
}
// Generate obtain the access token from Keycloak for the test user
Generate obtain the access token from Keycloak for the test user
// Generate obtain the access token from Keycloak for the test user
func (c *LoginController) Generate(ctx *app.GenerateLoginContext) error {
	var tokens app.AuthTokenCollection
	tokenEndpoint, err := c.configuration.GetKeycloakEndpointToken(ctx.RequestData)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))
	}
	testuser, err := GenerateUserToken(ctx, tokenEndpoint, c.configuration, c.configuration.GetKeycloakTestUserName(), c.configuration.GetKeycloakTestUserSecret())
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to generate test token "+err.Error()))
	}
	c.auth.CreateOrUpdateKeycloakUser(*testuser.Token.AccessToken, ctx)
	tokens = append(tokens, testuser)
	testuser, err = GenerateUserToken(ctx, tokenEndpoint, c.configuration, c.configuration.GetKeycloakTestUser2Name(), c.configuration.GetKeycloakTestUser2Secret())
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to generate test token "+err.Error()))
	}
	c.auth.CreateOrUpdateKeycloakUser(*testuser.Token.AccessToken, ctx)
	tokens = append(tokens, testuser)
	return ctx.OK(tokens)
}
func ( c * LoginController ) Generate ( ctx * app . GenerateLoginContext ) error { var tokens app . AuthTokenCollection tokenEndpoint , err := c . configuration . GetKeycloakEndpointToken ( ctx . RequestData ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( " " + err . Error ( ) ) ) } testuser , err := GenerateUserToken ( ctx , tokenEndpoint , c . configuration , c . configuration . GetKeycloakTestUserName ( ) , c . configuration . GetKeycloakTestUserSecret ( ) ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( " " + err . Error ( ) ) ) } c . auth . CreateOrUpdateKeycloakUser ( * testuser . Token . AccessToken , ctx ) tokens = append ( tokens , testuser ) testuser , err = GenerateUserToken ( ctx , tokenEndpoint , c . configuration , c . configuration . GetKeycloakTestUser2Name ( ) , c . configuration . GetKeycloakTestUser2Secret ( ) ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( " " + err . Error ( ) ) ) } c . auth . CreateOrUpdateKeycloakUser ( * testuser . Token . AccessToken , ctx ) tokens = append ( tokens , testuser ) return ctx . OK ( tokens ) }
Generate obtain the access token from Keycloak for the test user
Generate obtain the access token from Keycloak for the test user
// Creates the testuser user and identity if they don't yet exist // Creates the testuser2 user and identity if they don't yet exist // jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))