forked from crewjam/saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema_test.go
36 lines (29 loc) · 1.02 KB
/
schema_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package saml
import (
"encoding/xml"
"github.com/beevik/etree"
. "gopkg.in/check.v1"
)
var _ = Suite(&SchemaTest{})
type SchemaTest struct {
}
func (test *SchemaTest) TestAttributeXMLRoundTrip(c *C) {
expected := Attribute{
FriendlyName: "TestFriendlyName",
Name: "TestName",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
Values: []AttributeValue{AttributeValue{
Type: "xs:string",
Value: "test",
}},
}
doc := etree.NewDocument()
doc.SetRoot(expected.Element())
x, err := doc.WriteToBytes()
c.Assert(err, IsNil)
c.Assert(string(x), Equals, "<saml:Attribute FriendlyName=\"TestFriendlyName\" Name=\"TestName\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:basic\"><saml:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">test</saml:AttributeValue></saml:Attribute>")
var actual Attribute
err = xml.Unmarshal(x, &actual)
c.Assert(err, IsNil)
c.Assert(actual, DeepEquals, expected)
}