-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathobject_test.go
54 lines (44 loc) · 1.47 KB
/
object_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package stix2
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCommonRelationships(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
sdo, err := NewAttackPattern("test")
require.NoError(err)
sco, err := NewDomainName("example.com")
require.NoError(err)
rel, err := sdo.AddDerivedFrom(sco.ID)
require.NoError(err)
assert.Equal(RelationshipTypeDerivedFrom, rel.RelationshipType)
assert.Equal(sdo.ID, rel.Source)
assert.Equal(sco.ID, rel.Target)
rel, err = sdo.AddDuplicateOf(sco.ID)
require.NoError(err)
assert.Equal(RelationshipTypeDuplicateOf, rel.RelationshipType)
assert.Equal(sdo.ID, rel.Source)
assert.Equal(sco.ID, rel.Target)
rel, err = sdo.AddRelatedTo(sco.ID)
require.NoError(err)
assert.Equal(RelationshipTypeRelatedTo, rel.RelationshipType)
assert.Equal(sdo.ID, rel.Source)
assert.Equal(sco.ID, rel.Target)
rel, err = sco.AddDerivedFrom(sdo.ID)
require.NoError(err)
assert.Equal(RelationshipTypeDerivedFrom, rel.RelationshipType)
assert.Equal(sco.ID, rel.Source)
assert.Equal(sdo.ID, rel.Target)
rel, err = sco.AddDuplicateOf(sdo.ID)
require.NoError(err)
assert.Equal(RelationshipTypeDuplicateOf, rel.RelationshipType)
assert.Equal(sco.ID, rel.Source)
assert.Equal(sdo.ID, rel.Target)
rel, err = sco.AddRelatedTo(sdo.ID)
require.NoError(err)
assert.Equal(RelationshipTypeRelatedTo, rel.RelationshipType)
assert.Equal(sco.ID, rel.Source)
assert.Equal(sdo.ID, rel.Target)
}