Tell data proxy the enterprise to update

This commit is contained in:
Maikel Linke
2025-10-06 15:55:25 +11:00
parent 2761cee5e6
commit 86774b3e4e
3 changed files with 9 additions and 6 deletions

View File

@@ -40,7 +40,9 @@ module DfcProvider
)
end
ProxyNotifier.new.refresh(key)
urls = DfcProvider::Engine.routes.url_helpers
enterprise_url = urls.enterprise_url(current_enterprise.id)
ProxyNotifier.new.refresh(key, enterprise_url)
render json: platform(key)
end

View File

@@ -5,9 +5,9 @@ require "private_address_check/tcpsocket_ext"
# Call a webhook to notify a data proxy about changes in our data.
class ProxyNotifier
def refresh(platform)
def refresh(platform, enterprise_url)
PrivateAddressCheck.only_public_connections do
notify_proxy(platform)
notify_proxy(platform, enterprise_url)
end
end
@@ -31,11 +31,11 @@ class ProxyNotifier
response.body["access_token"]
end
def notify_proxy(platform)
def notify_proxy(platform, enterprise_url)
token = request_token(platform)
data = {
eventType: "refresh",
enterpriseUrlid: DfcProvider::Engine.routes.url_helpers.enterprises_url,
enterpriseUrlid: enterprise_url,
scope: "ReadEnterprise",
}

View File

@@ -9,6 +9,7 @@ require_relative "../spec_helper"
# OPENID_APP_SECRET="..."
RSpec.describe ProxyNotifier do
let(:platform) { "cqcm-dev" }
let(:enterprise_url) { "http://ofn.example.net/api/dfc/enterprises/10000" }
it "receives an access token", :vcr do
token = subject.request_token(platform)
@@ -21,7 +22,7 @@ RSpec.describe ProxyNotifier do
# If you don't have valid credentials, you'll get an unauthorized error.
# Correctly authenticated, the server fails to update its data.
expect {
subject.refresh(platform)
subject.refresh(platform, enterprise_url)
}.to raise_error Faraday::ServerError
end
end