@@ -24,14 +24,19 @@ func TestAsaCreate(t *testing.T) {
24
24
cdgReadOutput := testModel .CdgReadOutput ()
25
25
createInput := testModel .AsaCreateInput ()
26
26
readOutput := testModel .AsaReadOutput ()
27
+ readSpecificOutput := testModel .AsaReadSpecificDeviceOutput ()
28
+ createInputWithIncorrectSoftwareVersion := createInput
29
+ createInputWithIncorrectSoftwareVersion .SoftwareVersion = readOutput .SoftwareVersion + "_different"
30
+ createInputWithIncorrectAsdmVersion := createInput
31
+ createInputWithIncorrectAsdmVersion .AsdmVersion = readOutput .AsdmVersion + "_different"
27
32
doneTransaction := testModel .CreateDoneTransaction (readOutput .Uid , transactiontype .ONBOARD_ASA )
28
33
errorTransaction := testModel .CreateErrorTransaction (readOutput .Uid , transactiontype .ONBOARD_ASA )
29
34
30
35
testCases := []struct {
31
36
testName string
32
37
input asa.CreateInput
33
38
setupFunc func (input asa.CreateInput )
34
- assertFunc func (output * asa.CreateOutput , err * asa.CreateError , t * testing.T )
39
+ assertFunc func (output * asa.ReadOutput , specificDeviceOutput * asa. ReadSpecificOutput , err * asa.CreateError , t * testing.T )
35
40
}{
36
41
{
37
42
testName : "successfully onboards ASA" ,
@@ -41,16 +46,50 @@ func TestAsaCreate(t *testing.T) {
41
46
internalTesting .MockGetOk (url .ReadConnectorByUid (testModel .BaseUrl , cdgReadOutput .Uid ), cdgReadOutput )
42
47
internalTesting .MockPostAccepted (url .CreateAsa (testModel .BaseUrl ), doneTransaction )
43
48
internalTesting .MockGetOk (url .ReadDevice (testModel .BaseUrl , readOutput .Uid ), readOutput )
49
+ internalTesting .MockGetOk (url .ReadSpecificDevice (testModel .BaseUrl , readOutput .Uid ), readSpecificOutput )
44
50
},
45
51
46
- assertFunc : func (actualOutput * asa.CreateOutput , err * asa.CreateError , t * testing.T ) {
52
+ assertFunc : func (actualOutput * asa.ReadOutput , actualSpecificDeviceOutput * asa. ReadSpecificOutput , err * asa.CreateError , t * testing.T ) {
47
53
assert .Nil (t , err )
48
54
assert .NotNil (t , actualOutput )
55
+ assert .NotNil (t , actualSpecificDeviceOutput )
49
56
assert .Equal (t , readOutput , * actualOutput )
50
57
},
51
58
},
52
59
{
53
- testName : "fails onboards Duo Admin Panel if transaction fails" ,
60
+ testName : "fails to onboard ASA due to specified software version mismatch" ,
61
+ input : createInputWithIncorrectSoftwareVersion ,
62
+ setupFunc : func (input asa.CreateInput ) {
63
+ internalTesting .MockGetOk (url .ReadConnectorByUid (testModel .BaseUrl , cdgReadOutput .Uid ), cdgReadOutput )
64
+ internalTesting .MockPostAccepted (url .CreateAsa (testModel .BaseUrl ), doneTransaction )
65
+ internalTesting .MockGetOk (url .ReadDevice (testModel .BaseUrl , readOutput .Uid ), readOutput )
66
+ internalTesting .MockGetOk (url .ReadSpecificDevice (testModel .BaseUrl , readOutput .Uid ), readSpecificOutput )
67
+ },
68
+ assertFunc : func (actualOutput * asa.ReadOutput , actualSpecificDeviceOutput * asa.ReadSpecificOutput , err * asa.CreateError , t * testing.T ) {
69
+ assert .Nil (t , actualOutput )
70
+ assert .Nil (t , actualSpecificDeviceOutput )
71
+ assert .NotNil (t , err )
72
+ assert .ErrorContains (t , err , "ASA Software version mismatch." )
73
+ },
74
+ },
75
+ {
76
+ testName : "fails to onboard ASA due to specified ASDM version mismatch" ,
77
+ input : createInputWithIncorrectAsdmVersion ,
78
+ setupFunc : func (input asa.CreateInput ) {
79
+ internalTesting .MockGetOk (url .ReadConnectorByUid (testModel .BaseUrl , cdgReadOutput .Uid ), cdgReadOutput )
80
+ internalTesting .MockPostAccepted (url .CreateAsa (testModel .BaseUrl ), doneTransaction )
81
+ internalTesting .MockGetOk (url .ReadDevice (testModel .BaseUrl , readOutput .Uid ), readOutput )
82
+ internalTesting .MockGetOk (url .ReadSpecificDevice (testModel .BaseUrl , readOutput .Uid ), readSpecificOutput )
83
+ },
84
+ assertFunc : func (actualOutput * asa.ReadOutput , actualSpecificDeviceOutput * asa.ReadSpecificOutput , err * asa.CreateError , t * testing.T ) {
85
+ assert .Nil (t , actualOutput )
86
+ assert .Nil (t , actualSpecificDeviceOutput )
87
+ assert .NotNil (t , err )
88
+ assert .ErrorContains (t , err , "ASDM version mismatch." )
89
+ },
90
+ },
91
+ {
92
+ testName : "fails onboards ASA if transaction fails" ,
54
93
input : createInput ,
55
94
56
95
setupFunc : func (input asa.CreateInput ) {
@@ -59,23 +98,25 @@ func TestAsaCreate(t *testing.T) {
59
98
internalTesting .MockGetOk (url .ReadDevice (testModel .BaseUrl , readOutput .Uid ), readOutput )
60
99
},
61
100
62
- assertFunc : func (actualOutput * asa.CreateOutput , err * asa.CreateError , t * testing.T ) {
101
+ assertFunc : func (actualOutput * asa.ReadOutput , actualSpecificDeviceOutput * asa. ReadSpecificOutput , err * asa.CreateError , t * testing.T ) {
63
102
assert .Nil (t , actualOutput )
103
+ assert .Nil (t , actualSpecificDeviceOutput )
64
104
assert .NotNil (t , err )
65
105
assert .ErrorContains (t , err , errorTransaction .ErrorMessage )
66
106
},
67
107
},
68
108
{
69
- testName : "fails onboards Duo Admin Panel if trigger transaction fails" ,
109
+ testName : "fails onboards ASA if trigger transaction fails" ,
70
110
input : createInput ,
71
111
72
112
setupFunc : func (input asa.CreateInput ) {
73
113
internalTesting .MockPostError (url .CreateAsa (testModel .BaseUrl ), "post error" )
74
114
internalTesting .MockGetOk (url .ReadDevice (testModel .BaseUrl , readOutput .Uid ), readOutput )
75
115
},
76
116
77
- assertFunc : func (actualOutput * asa.CreateOutput , err * asa.CreateError , t * testing.T ) {
117
+ assertFunc : func (actualOutput * asa.ReadOutput , actualSpecificDeviceOutput * asa. ReadSpecificOutput , err * asa.CreateError , t * testing.T ) {
78
118
assert .Nil (t , actualOutput )
119
+ assert .Nil (t , actualSpecificDeviceOutput )
79
120
assert .NotNil (t , err )
80
121
assert .ErrorContains (t , err , "post error" )
81
122
},
@@ -88,13 +129,13 @@ func TestAsaCreate(t *testing.T) {
88
129
89
130
testCase .setupFunc (testCase .input )
90
131
91
- output , err := asa .Create (
132
+ output , specificDeviceOuput , err := asa .Create (
92
133
context .Background (),
93
134
* http .MustNewWithConfig (testModel .BaseUrl , "a_valid_token" , 0 , 0 , time .Minute ),
94
135
testCase .input ,
95
136
)
96
137
97
- testCase .assertFunc (output , err , t )
138
+ testCase .assertFunc (output , specificDeviceOuput , err , t )
98
139
})
99
140
}
100
141
}
0 commit comments