scimtest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package scimtest is an in-memory example SCIM server used by tests and as a usage example for github.com/singlestore-labs/scim.

Index

Constants

View Source
const DummyToken = "dummyToken"

Variables

View Source
var ExampleFullUserJSON []byte
View Source
var ExampleUserCore = SCIMUser{
	CoreUser: CoreUser{
		Active:      true,
		DisplayName: "Babs Jensen",
		Emails: []Email{
			{
				Value:   "bjensen@example.com",
				Type:    "work",
				Primary: true,
			},
			{
				Value: "babs@jensen.org",
				Type:  "home",
			},
		},
		ExternalID: "701984",
		Groups: []Group{
			{
				Value:   "e9e30dba-f08f-4109-8486-d5c6a331660a",
				Ref:     "https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a",
				Display: "Tour Guides",
			},
			{
				Value:   "fc348aa8-3835-40eb-a20b-c726e15c55b5",
				Ref:     "https://example.com/v2/Groups/fc348aa8-3835-40eb-a20b-c726e15c55b5",
				Display: "Employees",
			},
			{
				Value:   "71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7",
				Ref:     "https://example.com/v2/Groups/71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7",
				Display: "US Employees",
			},
		},
		ID: "2819c223-7f76-453a-919d-413861904646",
		Name: Name{
			Formatted:       "Ms. Barbara J Jensen, III",
			FamilyName:      "Jensen",
			GivenName:       "Barbara",
			MiddleName:      "Jane",
			HonorificPrefix: "Ms.",
			HonorificSuffix: "III",
		},

		Timezone: "America/Los_Angeles",
		Title:    "Tour Guide",
		UserName: "bjensen@example.com",
		UserType: "Employee",
	},
}
View Source
var ExampleUserCoreJSON []byte
View Source
var ExampleUserWithExtension = SCIMUser{
	CoreUser: CoreUser{
		Active:      true,
		DisplayName: "Babs Jensen",
		Emails: []Email{
			{
				Value:   "bjensen@example.com",
				Type:    "work",
				Primary: true,
			},
			{
				Value: "babs@jensen.org",
				Type:  "home",
			},
		},
		ExternalID: "701984",
		Groups: []Group{
			{
				Value:   "e9e30dba-f08f-4109-8486-d5c6a331660a",
				Ref:     "https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a",
				Display: "Tour Guides",
			},
			{
				Value:   "fc348aa8-3835-40eb-a20b-c726e15c55b5",
				Ref:     "https://example.com/v2/Groups/fc348aa8-3835-40eb-a20b-c726e15c55b5",
				Display: "Employees",
			},
			{
				Value:   "71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7",
				Ref:     "https://example.com/v2/Groups/71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7",
				Display: "US Employees",
			},
		},
		ID: "2819c223-7f76-453a-919d-413861904646",
		Name: Name{
			Formatted:       "Ms. Barbara J Jensen, III",
			FamilyName:      "Jensen",
			GivenName:       "Barbara",
			MiddleName:      "Jane",
			HonorificPrefix: "Ms.",
			HonorificSuffix: "III",
		},

		Timezone: "America/Los_Angeles",
		Title:    "Tour Guide",
		UserName: "bjensen@example.com",
		UserType: "Employee",
	},
}
View Source
var ExampleUserWithExtensionJSON []byte

Functions

This section is empty.

Types

type CoreGroup

type CoreGroup struct {
	ID          string            `scim:"id,mutability=readOnly,returned=always,ignoreUnmarshal"`
	ExternalID  string            `scim:"externalId"`
	DisplayName string            `scim:"displayName"`
	Members     []SCIMGroupMember `scim:"members"`
}

type CoreUser

type CoreUser struct {
	Active            bool          `scim:"active,returned=keepEmpty"`
	DisplayName       string        `scim:"displayName,caseExact"`
	Emails            []Email       `scim:"emails"`
	Entitlements      []Entitlement `scim:"entitlements"`
	ExternalID        string        `scim:"externalId"`
	Groups            []Group       `scim:"groups,mutability=readOnly"`
	ID                string        `scim:"id,mutability=readOnly,returned=always,ignoreUnmarshal"`
	Name              Name          `scim:"name"`
	PreferredLanguage string        `scim:"preferredLanguage"`
	Roles             []Role        `scim:"roles"`
	Timezone          string        `scim:"timezone"`
	Title             string        `scim:"title"`
	UserName          string        `scim:"userName,required"`
	UserType          string        `scim:"userType"`
}

type Email

type Email struct {
	Value   string `json:"value"   scim:"value"`
	Type    string `json:"type"    scim:"type,canonicalValues=work"` // azure only allow work
	Primary bool   `json:"primary" scim:"primary,returned=keepEmpty"`
}

func (*Email) IsEmpty

func (e *Email) IsEmpty() bool

type Entitlement

type Entitlement struct {
	Value   string `json:"value"   scim:"value"`
	Display string `json:"display" scim:"display"`
	Type    string `json:"type"    scim:"type,canonicalValues= "` // special canonicalValues to return empty [] in schemas
	Primary bool   `json:"primary" scim:"primary"`
}

func (*Entitlement) IsEmpty

func (e *Entitlement) IsEmpty() bool

type Group

type Group struct {
	Value   string `scim:"value"`
	Display string `scim:"display"`
	Type    string `scim:"type,canonicalValues= "`         // special canonicalValues to return empty [] in schemas, azure support
	Ref     string `scim:"$ref,referenceTypes=User Group"` // string array in tag separate by space
}

type Name

type Name struct {
	Formatted       string `json:"formatted"       scim:"formatted"`
	FamilyName      string `json:"familyName"      scim:"familyName"`
	GivenName       string `json:"givenName"       scim:"givenName"`
	MiddleName      string `json:"middleName"      scim:"middleName"`
	HonorificPrefix string `json:"honorificPrefix" scim:"honorificPrefix"`
	HonorificSuffix string `json:"honorificSuffix" scim:"honorificSuffix"`
}

func (*Name) IsEmpty

func (n *Name) IsEmpty() bool

type Role

type Role struct {
	Value   string `json:"value"   scim:"value"`
	Display string `json:"display" scim:"display"`
	Type    string `json:"type"    scim:"type,canonicalValues= "` // special canonicalValues to return empty [] in schemas
	Primary bool   `json:"primary" scim:"primary"`
}

func (*Role) IsEmpty

func (r *Role) IsEmpty() bool

type SCIMGroup

type SCIMGroup struct {
	scimprotocol.SCIMResourceMarker
	TeamID    TeamID
	CoreGroup `scim:"urn:ietf:params:scim:schemas:core:2.0:Group"`
	Meta      SCIMMeta `scim:"meta,ignoreUnmarshal"`
}

type SCIMGroupID

type SCIMGroupID string

type SCIMGroupMember

type SCIMGroupMember struct {
	Value   string `scim:"value,required"`
	Ref     string `scim:"$ref"`
	Display string `scim:"display"`
	Type    string `scim:"type,canonicalValues= "`
}

type SCIMID

type SCIMID uuid.UUID

type SCIMMeta

type SCIMMeta struct {
	// json tag here is for test only
	Created      time.Time `json:"created"      scim:"created,returned=always"` // characteristics need specify at all level
	LastModified time.Time `json:"lastModified" scim:"lastModified,returned=always"`
}

type SCIMUser

type SCIMUser struct {
	scimprotocol.SCIMResourceMarker
	UserID   *UserID                                             // non-scim tagged field will not be considered in SCIM related operations like marshal/filter/patch
	CoreUser `scim:"urn:ietf:params:scim:schemas:core:2.0:User"` // core schema required to be the first field with a scim tag
	Meta     SCIMMeta                                            `scim:"meta,ignoreUnmarshal,returned=always"`
}

func (SCIMUser) Copy

func (su SCIMUser) Copy() SCIMUser

type SCIMUserDBJSONFields

type SCIMUserDBJSONFields struct {
	Name         []byte
	Emails       []byte
	Entitlements []byte
	Groups       []byte
	Roles        []byte
}

type SCIMUserID

type SCIMUserID string

type Server

type Server struct {
	ResourceTypes []scimprotocol.ResourceType
	// contains filtered or unexported fields
}

func NewServer

func NewServer(trace util.Trace, storage *Storage) Server

func (Server) Authorization

func (h Server) Authorization(inner func() error, r *http.Request) error

func (Server) BulkHandler

func (h Server) BulkHandler() (nvelope.Response, error)

func (Server) DeleteResourceHandler

func (h Server) DeleteResourceHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMIDAndResourceID) (nvelope.Response, error)

func (Server) GetResourceHandler

func (h Server) GetResourceHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMIDAndResourceID) (nvelope.Response, error)

func (Server) GetResourceListHandler

func (h Server) GetResourceListHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMID) (nvelope.Response, error)

func (Server) GetResourceTypes

func (h Server) GetResourceTypes() []scimprotocol.ResourceType

func (Server) GetResourceTypesHandler

func (h Server) GetResourceTypesHandler() (nvelope.Response, error)

func (Server) GetServiceProviderConfigHandler

func (h Server) GetServiceProviderConfigHandler(r *http.Request, w http.ResponseWriter) (nvelope.Response, error)

func (Server) PatchResourceHandler

func (h Server) PatchResourceHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMIDAndResourceID) (nvelope.Response, error)

func (Server) PostResourceHandler

func (h Server) PostResourceHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMID) (nvelope.Response, error)

func (Server) SchemasHandler

func (h Server) SchemasHandler() (resp nvelope.Response, err error)

func (Server) UpdateResourceHandler

func (h Server) UpdateResourceHandler(r *http.Request, resourceType scimprotocol.ResourceType, params scimprotocol.EndpointSCIMIDAndResourceID) (nvelope.Response, error)

type Storage

type Storage struct {
	Users  map[SCIMUserID]SCIMUser
	Groups map[SCIMGroupID]SCIMGroup
}

In-memory storage for SCIM users and groups we don't care SCIMID in in-memory storage for testing purpose

func NewInMemStorage

func NewInMemStorage() *Storage

func (*Storage) CreateSCIMGroup

func (s *Storage) CreateSCIMGroup(ctx context.Context, _ string, group SCIMGroup) (SCIMGroup, error)

func (*Storage) CreateSCIMUser

func (s *Storage) CreateSCIMUser(ctx context.Context, _ string, user SCIMUser) (SCIMUser, error)

func (*Storage) DeleteSCIMGroup

func (s *Storage) DeleteSCIMGroup(ctx context.Context, _ string, id string) error

func (*Storage) DeleteSCIMUser

func (s *Storage) DeleteSCIMUser(ctx context.Context, _ string, id string) error

func (Storage) GetAllSCIMGroup

func (s Storage) GetAllSCIMGroup(ctx context.Context, _ string) ([]SCIMGroup, error)

func (Storage) GetAllSCIMUser

func (s Storage) GetAllSCIMUser(ctx context.Context, _ string) ([]SCIMUser, error)

func (Storage) GetSCIMGroup

func (s Storage) GetSCIMGroup(ctx context.Context, _ string, id string) (SCIMGroup, error)

func (Storage) GetSCIMUser

func (s Storage) GetSCIMUser(ctx context.Context, _ string, userID string) (SCIMUser, error)

func (*Storage) UpdateSCIMGroup

func (s *Storage) UpdateSCIMGroup(ctx context.Context, _ string, id string, group SCIMGroup) (SCIMGroup, error)

func (*Storage) UpdateSCIMUser

func (s *Storage) UpdateSCIMUser(ctx context.Context, _ string, id string, user SCIMUser) (SCIMUser, error)

type TeamID

type TeamID uuid.UUIDs

type UserID

type UserID uuid.UUID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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