Adding more test coverage

Fixing some outdated code as well.

Signed-off-by: Dave Shanley <dave@quobix.com>

Cleaning up more coverage issues

Signed-off-by: Dave Shanley <dave@quobix.com>

More test coverage updates.

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2023-06-16 15:54:03 -04:00
committed by quobix
parent e1f0f69650
commit 20ac2fb25a
11 changed files with 296 additions and 228 deletions

View File

@@ -199,19 +199,15 @@ func (n *NodeBuilder) add(key string, i int) {
nodeEntry.Style = lines[0].style
break
case reflect.Map:
l := value.Len()
lines := make([]lineStyle, l)
line := make([]int, l)
for q, ky := range value.MapKeys() {
if we, wok := ky.Interface().(low.HasKeyNode); wok {
lines[q] = lineStyle{we.GetKeyNode().Line, we.GetKeyNode().Style}
line[q] = we.GetKeyNode().Line
}
}
sort.Slice(lines, func(i, j int) bool {
return lines[i].line < lines[j].line
})
nodeEntry.Line = lines[0].line // pick the lowest line number, sort in order
nodeEntry.Style = lines[0].style
sort.Ints(line)
nodeEntry.Line = line[0]
case reflect.Struct:
y := value.Interface()

View File

@@ -157,24 +157,19 @@ func (d *Document) Render() ([]byte, error) {
// RenderWithIndention will return a YAML representation of the Document object as a byte slice.
// the rendering will use the original indention of the document.
func (d *Document) RenderWithIndention(indent int) ([]byte, error) {
func (d *Document) RenderWithIndention(indent int) []byte {
var buf bytes.Buffer
yamlEncoder := yaml.NewEncoder(&buf)
yamlEncoder.SetIndent(indent)
err := yamlEncoder.Encode(d)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
_ = yamlEncoder.Encode(d)
return buf.Bytes()
}
// RenderJSON will return a JSON representation of the Document object as a byte slice.
func (d *Document) RenderJSON(indention string) ([]byte, error) {
yamlData, err := yaml.Marshal(d)
if err != nil {
return yamlData, err
}
return utils.ConvertYAMLtoJSONPretty(yamlData, "", indention)
func (d *Document) RenderJSON(indention string) []byte {
yamlData, _ := yaml.Marshal(d)
dat, _ := utils.ConvertYAMLtoJSONPretty(yamlData, "", indention)
return dat
}
func (d *Document) RenderInline() ([]byte, error) {

View File

@@ -4,7 +4,9 @@
package v3
import (
"io/ioutil"
"fmt"
"net/url"
"os"
"strings"
"testing"
@@ -18,7 +20,7 @@ import (
var lowDoc *lowv3.Document
func initTest() {
data, _ := ioutil.ReadFile("../../../test_specs/burgershop.openapi.yaml")
data, _ := os.ReadFile("../../../test_specs/burgershop.openapi.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
@@ -379,30 +381,30 @@ func testBurgerShop(t *testing.T, h *Document, checkLines bool) {
}
func TestStripeAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/stripe.yaml")
data, _ := os.ReadFile("../../../test_specs/stripe.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocument(info)
lowDoc, err = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
assert.Len(t, err, 3)
d := NewDocument(lowDoc)
assert.NotNil(t, d)
}
func TestK8sAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/k8s.json")
data, _ := os.ReadFile("../../../test_specs/k8s.json")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowSwag, err := lowv2.CreateDocument(info)
lowSwag, err := lowv2.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
d := v2.NewSwaggerDocument(lowSwag)
assert.Len(t, err, 0)
assert.NotNil(t, d)
}
func TestAsanaAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/asana.yaml")
data, _ := os.ReadFile("../../../test_specs/asana.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocument(info)
lowDoc, err = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
if err != nil {
panic("broken something")
}
@@ -411,36 +413,36 @@ func TestAsanaAsDoc(t *testing.T) {
assert.Equal(t, 118, len(d.Paths.PathItems))
}
//func TestDigitalOceanAsDocFromSHA(t *testing.T) {
// data, _ := ioutil.ReadFile("../../../test_specs/digitalocean.yaml")
// info, _ := datamodel.ExtractSpecInfo(data)
// var err []error
//
// baseURL, _ := url.Parse("https://raw.githubusercontent.com/digitalocean/openapi/82e1d558e15a59edc1d47d2c5544e7138f5b3cbf/specification")
// config := datamodel.DocumentConfiguration{
// AllowFileReferences: true,
// AllowRemoteReferences: true,
// BaseURL: baseURL,
// }
//
// lowDoc, err = lowv3.CreateDocumentFromConfig(info, &config)
// if err != nil {
// for e := range err {
// fmt.Println(err[e])
// }
// panic("broken something")
// }
// d := NewDocument(lowDoc)
// assert.NotNil(t, d)
// assert.Equal(t, 183, len(d.Paths.PathItems))
//
//}
func TestPetstoreAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json")
func TestDigitalOceanAsDocFromSHA(t *testing.T) {
data, _ := os.ReadFile("../../../test_specs/digitalocean.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocument(info)
baseURL, _ := url.Parse("https://raw.githubusercontent.com/digitalocean/openapi/82e1d558e15a59edc1d47d2c5544e7138f5b3cbf/specification")
config := datamodel.DocumentConfiguration{
AllowFileReferences: true,
AllowRemoteReferences: true,
BaseURL: baseURL,
}
lowDoc, err = lowv3.CreateDocumentFromConfig(info, &config)
if err != nil {
for e := range err {
fmt.Println(err[e])
}
panic("broken something")
}
d := NewDocument(lowDoc)
assert.NotNil(t, d)
assert.Equal(t, 183, len(d.Paths.PathItems))
}
func TestPetstoreAsDoc(t *testing.T) {
data, _ := os.ReadFile("../../../test_specs/petstorev3.json")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
if err != nil {
panic("broken something")
}
@@ -450,10 +452,10 @@ func TestPetstoreAsDoc(t *testing.T) {
}
func TestCircularReferencesDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
data, _ := os.ReadFile("../../../test_specs/circular-tests.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
lowDoc, err = lowv3.CreateDocument(info)
lowDoc, err = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
assert.Len(t, err, 3)
d := NewDocument(lowDoc)
assert.Len(t, d.Components.Schemas, 9)
@@ -478,6 +480,62 @@ func TestDocument_MarshalYAML(t *testing.T) {
}
func TestDocument_MarshalIndention(t *testing.T) {
data, _ := os.ReadFile("../../../test_specs/single-definition.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
lowDoc, _ = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
highDoc := NewDocument(lowDoc)
rendered := highDoc.RenderWithIndention(2)
assert.Equal(t, string(data), strings.TrimSpace(string(rendered)))
rendered = highDoc.RenderWithIndention(4)
assert.NotEqual(t, string(data), strings.TrimSpace(string(rendered)))
}
func TestDocument_MarshalIndention_Error(t *testing.T) {
data, _ := os.ReadFile("../../../test_specs/single-definition.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
lowDoc, _ = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
highDoc := NewDocument(lowDoc)
rendered := highDoc.RenderWithIndention(2)
assert.Equal(t, string(data), strings.TrimSpace(string(rendered)))
rendered = highDoc.RenderWithIndention(4)
assert.NotEqual(t, string(data), strings.TrimSpace(string(rendered)))
}
func TestDocument_MarshalJSON(t *testing.T) {
data, _ := os.ReadFile("../../../test_specs/petstorev3.json")
info, _ := datamodel.ExtractSpecInfo(data)
lowDoc, _ = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
highDoc := NewDocument(lowDoc)
rendered := highDoc.RenderJSON(" ")
// now read back in the JSON
info, _ = datamodel.ExtractSpecInfo(rendered)
lowDoc, _ = lowv3.CreateDocumentFromConfig(info, datamodel.NewOpenDocumentConfiguration())
newDoc := NewDocument(lowDoc)
assert.Equal(t, len(newDoc.Paths.PathItems), len(highDoc.Paths.PathItems))
assert.Equal(t, len(newDoc.Components.Schemas), len(highDoc.Components.Schemas))
}
func TestDocument_MarshalYAMLInline(t *testing.T) {
// create a new document

View File

@@ -2,7 +2,7 @@ package v3
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/pb33f/libopenapi/datamodel"
@@ -16,7 +16,7 @@ func initTest() {
if doc != nil {
return
}
data, _ := ioutil.ReadFile("../../../test_specs/burgershop.openapi.yaml")
data, _ := os.ReadFile("../../../test_specs/burgershop.openapi.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
var err []error
// deprecated function test.
@@ -27,7 +27,7 @@ func initTest() {
}
func BenchmarkCreateDocument(b *testing.B) {
data, _ := ioutil.ReadFile("../../../test_specs/burgershop.openapi.yaml")
data, _ := os.ReadFile("../../../test_specs/burgershop.openapi.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
for i := 0; i < b.N; i++ {
doc, _ = CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
@@ -38,7 +38,7 @@ func BenchmarkCreateDocument(b *testing.B) {
}
func BenchmarkCreateDocument_Circular(b *testing.B) {
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
data, _ := os.ReadFile("../../../test_specs/circular-tests.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
for i := 0; i < b.N; i++ {
_, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
@@ -53,7 +53,7 @@ func BenchmarkCreateDocument_Circular(b *testing.B) {
func BenchmarkCreateDocument_k8s(b *testing.B) {
data, _ := ioutil.ReadFile("../../../test_specs/k8s.json")
data, _ := os.ReadFile("../../../test_specs/k8s.json")
info, _ := datamodel.ExtractSpecInfo(data)
for i := 0; i < b.N; i++ {
@@ -70,7 +70,7 @@ func BenchmarkCreateDocument_k8s(b *testing.B) {
func TestCircularReferenceError(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
data, _ := os.ReadFile("../../../test_specs/circular-tests.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
circDoc, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
AllowFileReferences: false,
@@ -81,7 +81,7 @@ func TestCircularReferenceError(t *testing.T) {
}
func BenchmarkCreateDocument_Stripe(b *testing.B) {
data, _ := ioutil.ReadFile("../../../test_specs/stripe.yaml")
data, _ := os.ReadFile("../../../test_specs/stripe.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
for i := 0; i < b.N; i++ {
@@ -96,7 +96,7 @@ func BenchmarkCreateDocument_Stripe(b *testing.B) {
}
func BenchmarkCreateDocument_Petstore(b *testing.B) {
data, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json")
data, _ := os.ReadFile("../../../test_specs/petstorev3.json")
info, _ := datamodel.ExtractSpecInfo(data)
for i := 0; i < b.N; i++ {
_, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
@@ -111,7 +111,7 @@ func BenchmarkCreateDocument_Petstore(b *testing.B) {
func TestCreateDocumentStripe(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/stripe.yaml")
data, _ := os.ReadFile("../../../test_specs/stripe.yaml")
info, _ := datamodel.ExtractSpecInfo(data)
d, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
AllowFileReferences: false,
@@ -134,6 +134,26 @@ func TestCreateDocument(t *testing.T) {
assert.Len(t, doc.GetExtensions(), 1)
}
//func TestCreateDocumentHash(t *testing.T) {
// data, _ := os.ReadFile("../../../test_specs/all-the-components.yaml")
// info, _ := datamodel.ExtractSpecInfo(data)
// d, _ := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
// AllowFileReferences: false,
// AllowRemoteReferences: false,
// BasePath: "/here",
// })
//
// dataB, _ := os.ReadFile("../../../test_specs/all-the-components.yaml")
// infoB, _ := datamodel.ExtractSpecInfo(dataB)
// e, _ := CreateDocumentFromConfig(infoB, &datamodel.DocumentConfiguration{
// AllowFileReferences: false,
// AllowRemoteReferences: false,
// BasePath: "/here",
// })
//
// assert.Equal(t, d.Hash(), e.Hash())
//}
func TestCreateDocument_Info(t *testing.T) {
initTest()
assert.Equal(t, "https://pb33f.io", doc.Info.Value.TermsOfService.Value)
@@ -653,7 +673,7 @@ func ExampleCreateDocument() {
// How to create a low-level OpenAPI 3 Document
// load petstore into bytes
petstoreBytes, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json")
petstoreBytes, _ := os.ReadFile("../../../test_specs/petstorev3.json")
// read in specification
info, _ := datamodel.ExtractSpecInfo(petstoreBytes)

View File

@@ -108,3 +108,68 @@ func (d *Document) GetExternalDocs() *low.NodeReference[any] {
Value: d.ExternalDocs.Value,
}
}
// TODO: some behavior in this hash is not correct, disabled for now
// Hash will return a consistent SHA256 Hash of the Document object
//func (d *Document) Hash() [32]byte {
// var f []string
// if d.Version.Value != "" {
// f = append(f, d.Version.Value)
// }
// if d.Info.Value != nil {
// f = append(f, low.GenerateHashString(d.Info.Value))
// }
// if d.JsonSchemaDialect.Value != "" {
// f = append(f, d.JsonSchemaDialect.Value)
// }
// keys := make([]string, len(d.Webhooks.Value))
// z := 0
// for k := range d.Webhooks.Value {
// keys[z] = fmt.Sprintf("%s-%s", k.Value, low.GenerateHashString(d.Webhooks.Value[k].Value))
// z++
// }
// z = 0
// sort.Strings(keys)
// f = append(f, keys...)
// keys = make([]string, len(d.Servers.Value))
// for k := range d.Servers.Value {
// keys[z] = fmt.Sprintf("%s", low.GenerateHashString(d.Servers.Value[k].Value))
// z++
// }
// sort.Strings(keys)
// f = append(f, keys...)
// if d.Paths.Value != nil {
// f = append(f, low.GenerateHashString(d.Paths.Value))
// }
// if d.Components.Value != nil {
// f = append(f, low.GenerateHashString(d.Components.Value))
// }
// keys = make([]string, len(d.Security.Value))
// z = 0
// for k := range d.Security.Value {
// keys[z] = fmt.Sprintf("%s", low.GenerateHashString(d.Security.Value[k].Value))
// z++
// }
// sort.Strings(keys)
// f = append(f, keys...)
// keys = make([]string, len(d.Tags.Value))
// z = 0
// for k := range d.Tags.Value {
// keys[z] = fmt.Sprintf("%s", low.GenerateHashString(d.Tags.Value[k].Value))
// z++
// }
// sort.Strings(keys)
// f = append(f, keys...)
// if d.ExternalDocs.Value != nil {
// f = append(f, low.GenerateHashString(d.ExternalDocs.Value))
// }
// keys = make([]string, len(d.Extensions))
// z = 0
// for k := range d.Extensions {
// keys[z] = fmt.Sprintf("%s-%x", k.Value, sha256.Sum256([]byte(fmt.Sprint(d.Extensions[k].Value))))
// z++
// }
// sort.Strings(keys)
// f = append(f, keys...)
// return sha256.Sum256([]byte(strings.Join(f, "|")))
//}

View File

@@ -162,7 +162,6 @@ func (d *document) RenderAndReload() ([]byte, Document, *DocumentModel[v3high.Do
}
var newBytes []byte
var renderError error
// render the model as the correct type based on the source.
// https://github.com/pb33f/libopenapi/issues/105
@@ -174,14 +173,10 @@ func (d *document) RenderAndReload() ([]byte, Document, *DocumentModel[v3high.Do
jsonIndent += " "
}
}
newBytes, renderError = d.highOpenAPI3Model.Model.RenderJSON(jsonIndent)
newBytes = d.highOpenAPI3Model.Model.RenderJSON(jsonIndent)
}
if d.info.SpecFileType == datamodel.YAMLFileType {
newBytes, renderError = d.highOpenAPI3Model.Model.RenderWithIndention(d.info.OriginalIndentation)
}
if renderError != nil {
return newBytes, nil, nil, []error{renderError}
newBytes = d.highOpenAPI3Model.Model.RenderWithIndention(d.info.OriginalIndentation)
}
newDoc, err := NewDocumentWithConfiguration(newBytes, d.config)

View File

@@ -1,3 +1,4 @@
openapi: 3.1.0
components:
schemas:
Thing:

View File

@@ -505,7 +505,7 @@ func ConvertYAMLtoJSON(yamlData []byte) ([]byte, error) {
}
// ConvertYAMLtoJSONPretty will do exactly what you think it will. It will deserialize YAML into serialized JSON.
// However, this version will a apply prefix/indentation to the JSON.
// However, this version will apply prefix/indentation to the JSON.
func ConvertYAMLtoJSONPretty(yamlData []byte, prefix string, indent string) ([]byte, error) {
var decodedYaml map[string]interface{}
err := yaml.Unmarshal(yamlData, &decodedYaml)

View File

@@ -645,6 +645,11 @@ func TestConvertYAMLtoJSONPretty(t *testing.T) {
}
func TestConvertYAMLtoJSONPrettyError(t *testing.T) {
_, err := ConvertYAMLtoJSONPretty([]byte("BAD"), "", " ")
assert.Error(t, err)
}
func TestIsHttpVerb(t *testing.T) {
assert.True(t, IsHttpVerb("get"))
assert.True(t, IsHttpVerb("post"))
@@ -821,3 +826,8 @@ func TestDetermineJSONWhitespaceLength(t *testing.T) {
someBytes, _ := os.ReadFile("../test_specs/petstorev3.json")
assert.Equal(t, 2, DetermineWhitespaceLength(string(someBytes)))
}
func TestDetermineJSONWhitespaceLength_None(t *testing.T) {
someBytes := []byte(`{"hello": "world"}`)
assert.Equal(t, 0, DetermineWhitespaceLength(string(someBytes)))
}

View File

@@ -1055,6 +1055,86 @@ components:
assert.Equal(t, v3.ContainsLabel, changes.Changes[0].Property)
}
func TestCompareSchemas_UnevaluatedProperties_Bool(t *testing.T) {
left := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties: false`
right := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties: true`
leftDoc, rightDoc := test_BuildDoc(left, right)
// extract left reference schema and non reference schema.
lSchemaProxy := leftDoc.Components.Value.FindSchema("OK").Value
rSchemaProxy := rightDoc.Components.Value.FindSchema("OK").Value
changes := CompareSchemas(lSchemaProxy, rSchemaProxy)
assert.NotNil(t, changes)
assert.Equal(t, 1, changes.TotalChanges())
assert.Len(t, changes.GetAllChanges(), 1)
assert.Equal(t, 1, changes.TotalBreakingChanges())
}
func TestCompareSchemas_UnevaluatedProperties_Bool_Schema(t *testing.T) {
left := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties: false`
right := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties:
type: string`
leftDoc, rightDoc := test_BuildDoc(left, right)
// extract left reference schema and non reference schema.
lSchemaProxy := leftDoc.Components.Value.FindSchema("OK").Value
rSchemaProxy := rightDoc.Components.Value.FindSchema("OK").Value
changes := CompareSchemas(lSchemaProxy, rSchemaProxy)
assert.NotNil(t, changes)
assert.Equal(t, 1, changes.TotalChanges())
assert.Len(t, changes.GetAllChanges(), 1)
assert.Equal(t, 1, changes.TotalBreakingChanges())
}
func TestCompareSchemas_UnevaluatedProperties_Schema_Bool(t *testing.T) {
left := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties: false`
right := `openapi: 3.1
components:
schemas:
OK:
unevaluatedProperties:
type: string`
leftDoc, rightDoc := test_BuildDoc(right, left)
// extract left reference schema and non reference schema.
lSchemaProxy := leftDoc.Components.Value.FindSchema("OK").Value
rSchemaProxy := rightDoc.Components.Value.FindSchema("OK").Value
changes := CompareSchemas(lSchemaProxy, rSchemaProxy)
assert.NotNil(t, changes)
assert.Equal(t, 1, changes.TotalChanges())
assert.Len(t, changes.GetAllChanges(), 1)
assert.Equal(t, 1, changes.TotalBreakingChanges())
}
func TestCompareSchemas_UnevaluatedProperties(t *testing.T) {
left := `openapi: 3.1
components:

View File

@@ -384,155 +384,3 @@ biscuit:
assert.Equal(t, 0, extChanges.TotalBreakingChanges())
assert.Equal(t, ObjectAdded, extChanges.Changes[0].ChangeType)
}
//
//func TestCompareSecurityRequirement_V3(t *testing.T) {
//
// left := `- auth:
// - pizza
// - pie`
//
// right := `- auth:
// - pie
// - pizza`
//
// var lNode, rNode yaml.Node
// _ = yaml.Unmarshal([]byte(left), &lNode)
// _ = yaml.Unmarshal([]byte(right), &rNode)
//
// // create low level objects
// var lDoc v3.SecurityRequirement
// var rDoc v3.SecurityRequirement
// _ = low.BuildModel(lNode.Content[0], &lDoc)
// _ = low.BuildModel(rNode.Content[0], &rDoc)
// _ = lDoc.Build(lNode.Content[0], nil)
// _ = rDoc.Build(rNode.Content[0], nil)
//
// // compare
// extChanges := CompareSecurityRequirementV3(&lDoc, &rDoc)
// assert.Nil(t, extChanges)
//}
//
//func TestCompareSecurityRequirement_V3_AddARole(t *testing.T) {
//
// left := `- auth:
// - pizza
// - pie`
//
// right := `- auth:
// - pie
// - pizza
// - beer`
//
// var lNode, rNode yaml.Node
// _ = yaml.Unmarshal([]byte(left), &lNode)
// _ = yaml.Unmarshal([]byte(right), &rNode)
//
// // create low level objects
// var lDoc v3.SecurityRequirement
// var rDoc v3.SecurityRequirement
// _ = low.BuildModel(lNode.Content[0], &lDoc)
// _ = low.BuildModel(rNode.Content[0], &rDoc)
// _ = lDoc.Build(lNode.Content[0], nil)
// _ = rDoc.Build(rNode.Content[0], nil)
//
// // compare
// extChanges := CompareSecurityRequirementV3(&lDoc, &rDoc)
// assert.Equal(t, 1, extChanges.TotalChanges())
// assert.Equal(t, 0, extChanges.TotalBreakingChanges())
// assert.Equal(t, ObjectAdded, extChanges.Changes[0].ChangeType)
//}
//
//func TestCompareSecurityRequirement_V3_RemoveRole(t *testing.T) {
//
// left := `- auth:
// - pizza
// - pie`
//
// right := `- auth:
// - pie
// - pizza
// - beer`
//
// var lNode, rNode yaml.Node
// _ = yaml.Unmarshal([]byte(left), &lNode)
// _ = yaml.Unmarshal([]byte(right), &rNode)
//
// // create low level objects
// var lDoc v3.SecurityRequirement
// var rDoc v3.SecurityRequirement
// _ = low.BuildModel(lNode.Content[0], &lDoc)
// _ = low.BuildModel(rNode.Content[0], &rDoc)
// _ = lDoc.Build(lNode.Content[0], nil)
// _ = rDoc.Build(rNode.Content[0], nil)
//
// // compare
// extChanges := CompareSecurityRequirementV3(&rDoc, &lDoc)
// assert.Equal(t, 1, extChanges.TotalChanges())
// assert.Equal(t, 1, extChanges.TotalBreakingChanges())
// assert.Equal(t, ObjectRemoved, extChanges.Changes[0].ChangeType)
//}
//
//func TestCompareSecurityRequirement_V3_AddAReq(t *testing.T) {
//
// left := `- auth:
// - pizza
// - pie`
//
// right := `- auth:
// - pie
// - pizza
//- coffee:
// - filter
// - espresso`
//
// var lNode, rNode yaml.Node
// _ = yaml.Unmarshal([]byte(left), &lNode)
// _ = yaml.Unmarshal([]byte(right), &rNode)
//
// // create low level objects
// var lDoc v3.SecurityRequirement
// var rDoc v3.SecurityRequirement
// _ = low.BuildModel(lNode.Content[0], &lDoc)
// _ = low.BuildModel(rNode.Content[0], &rDoc)
// _ = lDoc.Build(lNode.Content[0], nil)
// _ = rDoc.Build(rNode.Content[0], nil)
//
// // compare
// extChanges := CompareSecurityRequirementV3(&lDoc, &rDoc)
// assert.Equal(t, 1, extChanges.TotalChanges())
// assert.Equal(t, 0, extChanges.TotalBreakingChanges())
// assert.Equal(t, ObjectAdded, extChanges.Changes[0].ChangeType)
//}
//
//func TestCompareSecurityRequirement_V3_RemoveAReq(t *testing.T) {
//
// left := `- coffee:
// - filter
// - espresso`
//
// right := `- coffee:
// - filter
// - espresso
//- auth:
// - pizza
// - pie`
//
// var lNode, rNode yaml.Node
// _ = yaml.Unmarshal([]byte(left), &lNode)
// _ = yaml.Unmarshal([]byte(right), &rNode)
//
// // create low level objects
// var lDoc v3.SecurityRequirement
// var rDoc v3.SecurityRequirement
// _ = low.BuildModel(lNode.Content[0], &lDoc)
// _ = low.BuildModel(rNode.Content[0], &rDoc)
// _ = lDoc.Build(lNode.Content[0], nil)
// _ = rDoc.Build(rNode.Content[0], nil)
//
// // compare
// extChanges := CompareSecurityRequirementV3(&rDoc, &lDoc)
// assert.Equal(t, 1, extChanges.TotalChanges())
// assert.Equal(t, 1, extChanges.TotalBreakingChanges())
// assert.Equal(t, ObjectRemoved, extChanges.Changes[0].ChangeType)
//}