mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-06-28 06:49:36 +00:00
Add Fallback Resource Json Schemas
This commit is contained in:
parent
b0a66d5dbf
commit
eb55164696
2 changed files with 249 additions and 0 deletions
231
api/schema.go
Normal file
231
api/schema.go
Normal file
|
@ -0,0 +1,231 @@
|
|||
package api
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// Fallback Schema, Only to be used if we encounter a Broken Server (v5.0), Not API Stable!
|
||||
var ResourceSchemas = map[string]json.RawMessage{
|
||||
"v5-default": json.RawMessage(`
|
||||
{
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1024,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"secret": {
|
||||
"type": "object",
|
||||
"required": ["password"],
|
||||
"properties": {
|
||||
"object_type": {
|
||||
"type": "string",
|
||||
"enum": ["PASSBOLT_SECRET_DATA"]
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"maxLength": 4096,
|
||||
"nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}`),
|
||||
"v5-password-string": json.RawMessage(`
|
||||
{
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1024,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"secret": {
|
||||
"type": "string",
|
||||
"maxLength": 4096
|
||||
}
|
||||
}`),
|
||||
"v5-default-with-totp": json.RawMessage(`
|
||||
{
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1024,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"secret": {
|
||||
"type": "object",
|
||||
"required": ["totp"],
|
||||
"properties": {
|
||||
"object_type": {
|
||||
"type": "string",
|
||||
"enum": ["PASSBOLT_SECRET_DATA"]
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"maxLength": 4096,
|
||||
"nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
},
|
||||
"totp": {
|
||||
"type": "object",
|
||||
"required": ["secret_key", "digits", "algorithm"],
|
||||
"properties": {
|
||||
"algorithm": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"maxLength": 6
|
||||
},
|
||||
"secret_key": {
|
||||
"type": "string",
|
||||
"maxLength": 1024
|
||||
},
|
||||
"digits": {
|
||||
"type": "number",
|
||||
"minimum": 6,
|
||||
"maximum": 8
|
||||
},
|
||||
"period": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`),
|
||||
"v5-totp-standalone": json.RawMessage(`
|
||||
{
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1024,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 10000,
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"secret": {
|
||||
"type": "object",
|
||||
"required": ["totp"],
|
||||
"properties": {
|
||||
"object_type": {
|
||||
"type": "string",
|
||||
"enum": ["PASSBOLT_SECRET_DATA"]
|
||||
},
|
||||
"totp": {
|
||||
"type": "object",
|
||||
"required": ["secret_key", "digits", "algorithm"],
|
||||
"properties": {
|
||||
"algorithm": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"maxLength": 6
|
||||
},
|
||||
"secret_key": {
|
||||
"type": "string",
|
||||
"maxLength": 1024
|
||||
},
|
||||
"digits": {
|
||||
"type": "number",
|
||||
"minimum": 6,
|
||||
"maximum": 8
|
||||
},
|
||||
"period": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`),
|
||||
}
|
18
api/schema_test.go
Normal file
18
api/schema_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResourceJsonSchema(t *testing.T) {
|
||||
for slug, schema := range ResourceSchemas {
|
||||
var schemaDefinition ResourceTypeSchema
|
||||
err := json.Unmarshal(schema, &schemaDefinition)
|
||||
if err != nil {
|
||||
t.Errorf("Error While Parsing Resource Schema %v: %v", slug, err)
|
||||
} else {
|
||||
t.Logf("Schema for type %v is ok", slug)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue