@@ -14,9 +14,9 @@ def contact_identified_payload
1414
1515 test "saves incoming webhook" do
1616 ActionDispatch ::Request . any_instance . stubs ( :remote_ip ) . returns ( @valid_ip )
17-
17+
1818 post "/webhooks/incoming/click_funnels_webhooks?secret=#{ @endpoint_secret } " ,
19- params : contact_identified_payload . to_json
19+ params : contact_identified_payload . to_json
2020
2121 assert_response :success
2222 assert_equal response . parsed_body , { "status" => "OK" }
@@ -28,8 +28,8 @@ def contact_identified_payload
2828 test "returns 403 when event sent from unverified domain" do
2929 ip_not_in_allowlist = "192.168.1.1"
3030 ActionDispatch ::Request . any_instance . stubs ( :remote_ip ) . returns ( ip_not_in_allowlist )
31- post "/webhooks/incoming/click_funnels_webhooks?secret=#{ @endpoint_secret } " ,
32- params : contact_identified_payload . to_json
31+ post "/webhooks/incoming/click_funnels_webhooks?secret=#{ @endpoint_secret } " ,
32+ params : contact_identified_payload . to_json
3333
3434 assert_response :forbidden
3535 assert_equal "Webhook request from unauthorized domain" , response . parsed_body [ "error" ]
@@ -40,45 +40,45 @@ def contact_identified_payload
4040 ENV [ "CLICK_FUNNELS_IP_ALLOWLIST" ] = nil
4141
4242 post "/webhooks/incoming/click_funnels_webhooks?secret=#{ @endpoint_secret } " ,
43- params : contact_identified_payload . to_json
43+ params : contact_identified_payload . to_json
4444
4545 assert_response :forbidden
4646 assert_equal "Not ready to accept ClickFunnels webhooks because no ClickFunnels IP allowlist is configured." , response . parsed_body [ "error" ]
4747
4848 ENV [ "CLICK_FUNNELS_IP_ALLOWLIST" ] = original_allowlist
4949 end
50-
50+
5151 test "returns 403 when secret is invalid" do
5252 ActionDispatch ::Request . any_instance . stubs ( :remote_ip ) . returns ( @valid_ip )
53-
53+
5454 post "/webhooks/incoming/click_funnels_webhooks?secret=invalid_secret" ,
55- params : contact_identified_payload . to_json
55+ params : contact_identified_payload . to_json
5656
5757 assert_response :forbidden
5858 assert_equal "Invalid webhook secret" , response . parsed_body [ "error" ]
5959 end
60-
60+
6161 test "returns 403 when secret is missing" do
6262 ActionDispatch ::Request . any_instance . stubs ( :remote_ip ) . returns ( @valid_ip )
63-
63+
6464 post "/webhooks/incoming/click_funnels_webhooks" ,
65- params : contact_identified_payload . to_json
65+ params : contact_identified_payload . to_json
6666
6767 assert_response :forbidden
6868 assert_equal "Invalid webhook secret" , response . parsed_body [ "error" ]
6969 end
70-
70+
7171 test "returns 403 when endpoint secret is not configured" do
7272 original_secret = ENV [ "CLICK_FUNNELS_ENDPOINT_SECRET" ]
7373 ENV [ "CLICK_FUNNELS_ENDPOINT_SECRET" ] = nil
7474 ActionDispatch ::Request . any_instance . stubs ( :remote_ip ) . returns ( @valid_ip )
75-
75+
7676 post "/webhooks/incoming/click_funnels_webhooks?secret=#{ @endpoint_secret } " ,
77- params : contact_identified_payload . to_json
77+ params : contact_identified_payload . to_json
7878
7979 assert_response :forbidden
8080 assert_equal "Not ready to accept ClickFunnels webhooks because no endpoint secret is configured." , response . parsed_body [ "error" ]
81-
81+
8282 ENV [ "CLICK_FUNNELS_ENDPOINT_SECRET" ] = original_secret
8383 end
8484end
0 commit comments