Skip to content

Commit 1844d2c

Browse files
committed
add acceptance tests
1 parent 729ef4f commit 1844d2c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/acceptance/acceptance_tests.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,35 @@
191191
expect(response.body).to include("Boomtown error occurred")
192192
end
193193
end
194+
195+
describe "okta setup" do
196+
it "sends a POST request to the /webhooks/okta_webhook_setup endpoint and it fails because it is not a GET" do
197+
payload = {}.to_json
198+
headers = {}
199+
response = http.post("/webhooks/okta_webhook_setup", payload, headers)
200+
201+
expect(response).to be_a(Net::HTTPMethodNotAllowed)
202+
expect(response.body).to include("405 Not Allowed")
203+
end
204+
205+
it "sends a GET request to the /webhooks/okta_webhook_setup endpoint and it returns the verification challenge" do
206+
headers = { "x-okta-verification-challenge" => "test-challenge" }
207+
response = http.get("/webhooks/okta_webhook_setup", headers)
208+
209+
expect(response).to be_a(Net::HTTPSuccess)
210+
body = JSON.parse(response.body)
211+
expect(body["verification"]).to eq("test-challenge")
212+
end
213+
214+
it "sends a GET request to the /webhooks/okta_webhook_setup endpoint but it is missing the verification challenge header" do
215+
response = http.get("/webhooks/okta_webhook_setup")
216+
217+
expect(response).to be_a(Net::HTTPSuccess)
218+
expect(response.code).to eq("200")
219+
body = JSON.parse(response.body)
220+
expect(body["error"]).to eq("Missing verification challenge header")
221+
expect(body["expected_header"]).to eq("x-okta-verification-challenge")
222+
end
223+
end
194224
end
195225
end

0 commit comments

Comments
 (0)