@@ -90,79 +90,6 @@ func TestClientAuthScheme(t *testing.T) {
90
90
91
91
}
92
92
93
- func TestClientDigestAuth (t * testing.T ) {
94
- conf := defaultDigestServerConf ()
95
- ts := createDigestServer (t , conf )
96
- defer ts .Close ()
97
-
98
- c := dcnl ().
99
- SetBaseURL (ts .URL + "/" ).
100
- SetDigestAuth (conf .username , conf .password )
101
-
102
- resp , err := c .R ().
103
- SetResult (& AuthSuccess {}).
104
- Get (conf .uri )
105
- assertError (t , err )
106
- assertEqual (t , http .StatusOK , resp .StatusCode ())
107
-
108
- t .Logf ("Result Success: %q" , resp .Result ().(* AuthSuccess ))
109
- logResponse (t , resp )
110
- }
111
-
112
- func TestClientDigestSession (t * testing.T ) {
113
- conf := defaultDigestServerConf ()
114
- conf .algo = "MD5-sess"
115
- conf .qop = "auth, auth-int"
116
- ts := createDigestServer (t , conf )
117
- defer ts .Close ()
118
-
119
- c := dcnl ().
120
- SetBaseURL (ts .URL + "/" ).
121
- SetDigestAuth (conf .username , conf .password )
122
-
123
- resp , err := c .R ().
124
- SetResult (& AuthSuccess {}).
125
- Get (conf .uri )
126
- assertError (t , err )
127
- assertEqual (t , http .StatusOK , resp .StatusCode ())
128
-
129
- t .Logf ("Result Success: %q" , resp .Result ().(* AuthSuccess ))
130
- logResponse (t , resp )
131
- }
132
-
133
- func TestClientDigestErrors (t * testing.T ) {
134
- type test struct {
135
- mutateConf func (* digestServerConfig )
136
- expect error
137
- }
138
- tests := []test {
139
- {mutateConf : func (c * digestServerConfig ) { c .algo = "BAD_ALGO" }, expect : ErrDigestAlgNotSupported },
140
- {mutateConf : func (c * digestServerConfig ) { c .qop = "bad-qop" }, expect : ErrDigestQopNotSupported },
141
- {mutateConf : func (c * digestServerConfig ) { c .qop = "" }, expect : ErrDigestNoQop },
142
- {mutateConf : func (c * digestServerConfig ) { c .charset = "utf-16" }, expect : ErrDigestCharset },
143
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/bad" }, expect : ErrDigestBadChallenge },
144
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/unknown_param" }, expect : ErrDigestBadChallenge },
145
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/missing_value" }, expect : ErrDigestBadChallenge },
146
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/unclosed_quote" }, expect : ErrDigestBadChallenge },
147
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/no_challenge" }, expect : ErrDigestBadChallenge },
148
- {mutateConf : func (c * digestServerConfig ) { c .uri = "/status_500" }, expect : nil },
149
- }
150
-
151
- for _ , tc := range tests {
152
- conf := defaultDigestServerConf ()
153
- tc .mutateConf (conf )
154
- ts := createDigestServer (t , conf )
155
-
156
- c := dcnl ().
157
- SetBaseURL (ts .URL + "/" ).
158
- SetDigestAuth (conf .username , conf .password )
159
-
160
- _ , err := c .R ().Get (conf .uri )
161
- assertErrorIs (t , tc .expect , err )
162
- ts .Close ()
163
- }
164
- }
165
-
166
93
func TestClientResponseMiddleware (t * testing.T ) {
167
94
ts := createGenericServer (t )
168
95
defer ts .Close ()
0 commit comments