Skip to content

Commit bab4213

Browse files
mamoonrajagermanattanasio
authored andcommitted
test: add test for disabling ssl verification for websocket
1 parent 4210a08 commit bab4213

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

test/unit/test_configure_http_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_timeout_global
140140
assert_equal(expected_timeouts, timeout)
141141
end
142142

143-
def test_disable_ssl
143+
def test_disable_ssl_verification
144144
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
145145
version: "2018-03-16",
146146
username: "username",

test/unit/test_speech_to_text_v1.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,37 @@ def test_success
8989
refute_nil(service_response)
9090
end
9191

92+
def test_recognize_using_websocket_disable_ssl_verification
93+
service = IBMWatson::SpeechToTextV1.new(
94+
username: "username",
95+
password: "password"
96+
)
97+
98+
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
99+
stub_request(:post, "ws://stream.watsonplatform.net/speech-to-text/api/v1/recognize")
100+
.with(
101+
headers: {
102+
"Accept" => "application/json",
103+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
104+
"Content-Type" => "audio/l16; rate=44100",
105+
"Host" => "stream.watsonplatform.net"
106+
}
107+
).to_return(status: 200, body: "", headers: { "Content-Type" => "application/json" })
108+
109+
atomic_boolean = Concurrent::AtomicBoolean.new
110+
mycallback = MyRecognizeCallback.new(atomic_boolean: atomic_boolean)
111+
service.configure_http_client(disable_ssl_verification: true)
112+
speech = service.recognize_using_websocket(
113+
audio: audio_file,
114+
recognize_callback: mycallback,
115+
inactivity_timeout: 1,
116+
content_type: "audio/l16; rate=44100"
117+
)
118+
thr = Thread.new { speech.start }
119+
thr.join
120+
assert(atomic_boolean.true?)
121+
end
122+
92123
def test_get_model
93124
service = IBMWatson::SpeechToTextV1.new(
94125
username: "username",

0 commit comments

Comments
 (0)