services

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestData

func CleanupTestData(t *testing.T, db *gorm.DB)

CleanupTestData removes all test data from the database Exported for use in handler tests

func RequireTestDB

func RequireTestDB(t *testing.T) *gorm.DB

RequireTestDB is a helper function that sets up a test database and fails the test if the database cannot be established. This provides a cleaner API for tests that absolutely require a database connection.

Usage:

db := RequireTestDB(t)
// No need to check for nil - test will fail if DB setup fails

func SetupMockDB

func SetupMockDB(t *testing.T) (*gorm.DB, sqlmock.Sqlmock, func())

SetupMockDB creates a mock database for testing using go-sqlmock

func SetupSQLiteTestDB

func SetupSQLiteTestDB(t *testing.T) *gorm.DB

SetupSQLiteTestDB creates an in-memory SQLite database for testing NOTE: This should only be used in integration tests or handler tests. Unit tests in services should use SetupMockDB instead.

Types

type ApplicationService

type ApplicationService struct {
	// contains filtered or unexported fields
}

ApplicationService handles application-related operations

func NewApplicationService

func NewApplicationService(db *gorm.DB, pdpService *PDPService, idp idp.IdentityProviderAPI) *ApplicationService

NewApplicationService creates a new application service

func (*ApplicationService) CreateApplication

CreateApplication creates a new application. If req.IdpApplicationID and req.IdpClientID are both set, the caller has already provisioned the OAuth2 client directly in the IDP (e.g. manually via ThunderID's console, since idpfactory only supports Asgardeo's admin API today) - IDP creation is skipped and those values are used as-is.

func (*ApplicationService) CreateApplicationSubmission

CreateApplicationSubmission creates a new application submission

func (*ApplicationService) GetApplication

func (s *ApplicationService) GetApplication(ctx context.Context, applicationID string) (*models.ApplicationResponse, error)

GetApplication retrieves an application by ID

func (*ApplicationService) GetApplicationIdByIdpClientId

func (s *ApplicationService) GetApplicationIdByIdpClientId(ctx context.Context, idpClientId string) (*models.ApplicationIDResponse, error)

GetApplicationIdByIdpClientId retrieves applicationId by idpClientId

func (*ApplicationService) GetApplicationSubmission

func (s *ApplicationService) GetApplicationSubmission(ctx context.Context, submissionID string) (*models.ApplicationSubmissionResponse, error)

GetApplicationSubmission retrieves an application submission by ID

func (*ApplicationService) GetApplicationSubmissions

func (s *ApplicationService) GetApplicationSubmissions(ctx context.Context, MemberID *string, statusFilter *[]string) ([]models.ApplicationSubmissionResponse, error)

GetApplicationSubmissions retrieves all application submissions and filters by member ID if provided

func (*ApplicationService) GetApplications

func (s *ApplicationService) GetApplications(ctx context.Context, MemberID *string) ([]models.ApplicationResponse, error)

GetApplications retrieves all applications and filters by member ID if provided

func (*ApplicationService) UpdateApplication

func (s *ApplicationService) UpdateApplication(ctx context.Context, applicationID string, req *models.UpdateApplicationRequest) (*models.ApplicationResponse, error)

UpdateApplication updates an existing application

func (*ApplicationService) UpdateApplicationPolicy

func (s *ApplicationService) UpdateApplicationPolicy(ctx context.Context, applicationID string, req *models.UpdateApplicationPolicyRequest) (*models.ApplicationResponse, error)

UpdateApplicationPolicy replaces an existing application's allow-list in the PDP and persists the resulting selected fields on the application record.

func (*ApplicationService) UpdateApplicationSubmission

UpdateApplicationSubmission updates an existing application submission

type MemberService

type MemberService struct {
	// contains filtered or unexported fields
}

MemberService handles Member-related operations

func NewMemberService

func NewMemberService(db *gorm.DB, idp idp.IdentityProviderAPI) *MemberService

NewMemberService creates a new Member service

func (*MemberService) CreateMember

CreateMember creates a new Member. Normally this also provisions a user in the IDP and adds them to the "OpenNDX_Members" group there, so all new members are automatically assigned it. If req.IdpUserID is set, the caller has already provisioned that user directly in the IDP (e.g. manually via ThunderID's console, since idpfactory only supports Asgardeo's admin API today) - IDP creation and group assignment are skipped, and the caller is responsible for that group/role assignment having already happened.

func (*MemberService) GetAllMembers

func (s *MemberService) GetAllMembers(ctx context.Context, idpUserId *string, email *string) ([]models.MemberResponse, error)

GetAllMembers retrieves all members, optionally filtered by idpUserId or email

func (*MemberService) GetMember

func (s *MemberService) GetMember(ctx context.Context, memberID string) (*models.MemberResponse, error)

GetMember retrieves a Member by ID

func (*MemberService) UpdateMember

func (s *MemberService) UpdateMember(ctx context.Context, memberID string, req *models.UpdateMemberRequest) (*models.MemberResponse, error)

UpdateMember updates an existing Member

type MockRoundTripper

type MockRoundTripper struct {
	RoundTripFunc func(req *http.Request) (*http.Response, error)
}

MockRoundTripper is a mock implementation of http.RoundTripper

func (*MockRoundTripper) RoundTrip

func (m *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes the mock RoundTripFunc

type PDPService

type PDPService struct {

	// HTTPClient is used to make requests to the PDP
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

PDPService handles communication with the Policy Decision Point

func NewPDPService

func NewPDPService(baseURL string) *PDPService

NewPDPService creates a new instance of PDPService. The PDP is reached through a trusted API gateway, so no API key is required.

func (*PDPService) CreatePolicyMetadata

func (s *PDPService) CreatePolicyMetadata(schemaId string, sdl string) (*models.PolicyMetadataCreateResponse, error)

CreatePolicyMetadata sends a request to create policy metadata in the PDP, parsing the field records out of a GraphQL SDL string.

func (*PDPService) CreatePolicyMetadataFromRecords

func (s *PDPService) CreatePolicyMetadataFromRecords(schemaId string, records []models.PolicyMetadataCreateRequestRecord) (*models.PolicyMetadataCreateResponse, error)

CreatePolicyMetadataFromRecords sends a request to create policy metadata in the PDP from caller-supplied records directly, skipping SDL/GraphQL parsing entirely.

func (*PDPService) UpdateAllowList

UpdateAllowList sends a request to update the allow list in the PDP

type SchemaService

type SchemaService struct {
	// contains filtered or unexported fields
}

SchemaService handles schema-related operations

func NewSchemaService

func NewSchemaService(db *gorm.DB, policyService *PDPService) *SchemaService

NewSchemaService creates a new schema service

func (*SchemaService) CreateSchema

CreateSchema creates a new schema. Exactly one of req.SDL / req.Fields must be set: SDL is parsed into policy metadata records via GraphQL directives, while Fields are used directly, skipping that parsing entirely.

func (*SchemaService) CreateSchemaSubmission

CreateSchemaSubmission creates a new schema

func (*SchemaService) GetSchema

func (s *SchemaService) GetSchema(schemaID string) (*models.SchemaResponse, error)

GetSchema retrieves a schema by ID

func (*SchemaService) GetSchemaSubmission

func (s *SchemaService) GetSchemaSubmission(submissionID string) (*models.SchemaSubmissionResponse, error)

GetSchemaSubmission retrieves a schema submission by ID

func (*SchemaService) GetSchemaSubmissions

func (s *SchemaService) GetSchemaSubmissions(memberID *string, statusFilter *[]string) ([]*models.SchemaSubmissionResponse, error)

GetSchemaSubmissions Get all schema submissions and filter by member ID OR Status Array if given

func (*SchemaService) GetSchemas

func (s *SchemaService) GetSchemas(memberID *string) ([]*models.SchemaResponse, error)

GetSchemas Get all schemas and filter by member ID if given

func (*SchemaService) UpdateSchema

func (s *SchemaService) UpdateSchema(schemaID string, req *models.UpdateSchemaRequest) (*models.SchemaResponse, error)

UpdateSchema updates an existing schema

func (*SchemaService) UpdateSchemaSubmission

func (s *SchemaService) UpdateSchemaSubmission(submissionID string, req *models.UpdateSchemaSubmissionRequest) (*models.SchemaSubmissionResponse, error)

UpdateSchemaSubmission updates an existing schema submission

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL