Skip to content

Commit

Permalink
fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
Quint Daenen committed May 21, 2019
1 parent 4ed18fc commit c2d2953
Showing 1 changed file with 7 additions and 51 deletions.
58 changes: 7 additions & 51 deletions resource_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package scim

import (
"fmt"
"log"
"math/rand"
"net/http"
"time"

"github.com/elimity-com/scim/errors"
)

func ExampleResourceHandler() {
var r interface{} = testResourceHandler{}
_, ok := r.(ResourceHandler)
fmt.Println(ok)
// Output: true
}

// simple in-memory resource database
type testResourceHandler struct {
data map[string]ResourceAttributes
Expand Down Expand Up @@ -87,52 +92,3 @@ func (h testResourceHandler) Delete(id string) errors.DeleteError {

return errors.DeleteErrorNil
}

func ExampleResourceHandler() {
config, _ := NewServiceProviderConfig([]byte(`{
"patch": {"supported": true},
"bulk": {
"supported": true,
"maxOperations": 1000,
"maxPayloadSize": 1048576
},
"filter": {
"supported": true,
"maxResults": 200
},
"changePassword": {"supported": true},
"sort": {"supported": true},
"etag": {"supported": true},
"authenticationSchemes": []
}`))

userSchema, _ := NewSchema([]byte(`{
"id": "urn:ietf:params:scim:schemas:core:2.0:User",
"name": "User",
"description": "User Account",
"attributes": [
{
"name": "userName",
"type": "string",
"multiValued": false,
"required": true,
"caseExact": false,
"mutability": "readWrite",
"returned": "default",
"uniqueness": "server"
}
]
}`))

resourceType, _ := NewResourceType([]byte(`{
"id": "User",
"name": "User",
"endpoint": "/Users",
"description": "User Account",
"schema": "urn:ietf:params:scim:schemas:core:2.0:User",
"schemaExtensions": []
}`), new(testResourceHandler))

server, _ := NewServer(config, []Schema{userSchema}, []ResourceType{resourceType})
log.Fatal(http.ListenAndServe(":8080", server))
}

0 comments on commit c2d2953

Please sign in to comment.