1313 build_mcp_server_url ,
1414 _get_current_environment ,
1515 _get_mcp_platform_base_url ,
16- get_ppapi_token_scope ,
16+ get_mcp_platform_authentication_scope ,
1717 MCP_PLATFORM_PROD_BASE_URL ,
1818 PPAPI_TOKEN_SCOPE ,
19- PPAPI_TEST_TOKEN_SCOPE ,
19+ PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE ,
2020)
2121
2222
@@ -31,6 +31,7 @@ def setup_method(self):
3131 for key in [
3232 "ENVIRONMENT" ,
3333 "MCP_PLATFORM_ENDPOINT" ,
34+ "MCP_PLATFORM_AUTHENTICATION_SCOPE" ,
3435 ]
3536 }
3637
@@ -52,7 +53,7 @@ def test_get_tooling_gateway_for_digital_worker(self):
5253 result = get_tooling_gateway_for_digital_worker (agent_user_id )
5354
5455 # Assert
55- expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agentGateway/agentApplicationInstances /{ agent_user_id } /mcpServers"
56+ expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agents /{ agent_user_id } /mcpServers"
5657 assert result == expected
5758
5859 @patch .dict (os .environ , {"MCP_PLATFORM_ENDPOINT" : "https://custom.endpoint.com" }, clear = False )
@@ -65,7 +66,7 @@ def test_get_tooling_gateway_with_custom_endpoint(self):
6566 result = get_tooling_gateway_for_digital_worker (agent_user_id )
6667
6768 # Assert
68- expected = "https://custom.endpoint.com/agentGateway/agentApplicationInstances /test-agent-456/mcpServers"
69+ expected = "https://custom.endpoint.com/agents /test-agent-456/mcpServers"
6970 assert result == expected
7071
7172 def test_get_mcp_base_url_production (self ):
@@ -77,7 +78,7 @@ def test_get_mcp_base_url_production(self):
7778 result = get_mcp_base_url ()
7879
7980 # Assert
80- expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /mcp/environments "
81+ expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agents/servers "
8182 assert result == expected
8283
8384 @patch .dict (os .environ , {"MCP_PLATFORM_ENDPOINT" : "https://custom.endpoint.com" }, clear = False )
@@ -87,38 +88,19 @@ def test_get_mcp_base_url_with_custom_endpoint(self):
8788 result = get_mcp_base_url ()
8889
8990 # Assert
90- expected = "https://custom.endpoint.com/mcp/environments "
91+ expected = "https://custom.endpoint.com/agents/servers "
9192 assert result == expected
9293
9394 def test_build_mcp_server_url_production (self ):
9495 """Test build_mcp_server_url in production environment."""
9596 # Arrange
96- environment_id = "prod-env-123"
9797 server_name = "mail_server"
9898
9999 # Act
100- result = build_mcp_server_url (environment_id , server_name )
100+ result = build_mcp_server_url (server_name )
101101
102102 # Assert
103- expected = (
104- f"{ MCP_PLATFORM_PROD_BASE_URL } /mcp/environments/{ environment_id } /servers/{ server_name } "
105- )
106- assert result == expected
107-
108- @patch .dict (os .environ , {"ENVIRONMENT" : "Development" }, clear = False )
109- def test_build_mcp_server_url_development_platform_mode (self ):
110- """Test build_mcp_server_url in development with platform mode."""
111- # Arrange
112- environment_id = "dev-env-456"
113- server_name = "platform_server"
114-
115- # Act
116- result = build_mcp_server_url (environment_id , server_name )
117-
118- # Assert
119- expected = (
120- f"{ MCP_PLATFORM_PROD_BASE_URL } /mcp/environments/{ environment_id } /servers/{ server_name } "
121- )
103+ expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agents/servers/{ server_name } "
122104 assert result == expected
123105
124106 def test_get_current_environment_default (self ):
@@ -161,36 +143,34 @@ def test_get_mcp_platform_base_url_custom(self):
161143 # Assert
162144 assert result == "https://test.platform.com"
163145
164- def test_get_ppapi_token_scope_production (self ):
165- """Test get_ppapi_token_scope returns production scope."""
166- # Arrange - Set environment to production explicitly
167- os .environ .pop ("ENVIRONMENT" , None )
168- # The _get_current_environment defaults to "Development", so we need to set it to something else
169- os .environ ["ENVIRONMENT" ] = "Production"
146+ def test_get_mcp_platform_authentication_scope_production (self ):
147+ """Test get_mcp_platform_authentication_scope returns production scope."""
148+ # Arrange - Clear environment variable to use default
149+ os .environ .pop ("MCP_PLATFORM_AUTHENTICATION_SCOPE" , None )
170150
171151 # Act
172- result = get_ppapi_token_scope ()
152+ result = get_mcp_platform_authentication_scope ()
173153
174154 # Assert
175- expected = [PPAPI_TOKEN_SCOPE + "/.default" ]
155+ expected = [PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE ]
176156 assert result == expected
177157
178- @patch .dict (os .environ , {"ENVIRONMENT " : "Development " }, clear = False )
179- def test_get_ppapi_token_scope_development (self ):
180- """Test get_ppapi_token_scope returns test scope in development ."""
158+ @patch .dict (os .environ , {"MCP_PLATFORM_AUTHENTICATION_SCOPE " : "custom-scope/.default " }, clear = False )
159+ def test_get_mcp_platform_authentication_scope_custom (self ):
160+ """Test get_mcp_platform_authentication_scope returns custom scope from environment ."""
181161 # Act
182- result = get_ppapi_token_scope ()
162+ result = get_mcp_platform_authentication_scope ()
183163
184164 # Assert
185- expected = [PPAPI_TEST_TOKEN_SCOPE + " /.default" ]
165+ expected = ["custom-scope /.default" ]
186166 assert result == expected
187167
188168 def test_constants_values (self ):
189169 """Test that constants have expected values."""
190170 # Assert
191171 assert MCP_PLATFORM_PROD_BASE_URL == "https://agent365.svc.cloud.microsoft"
192172 assert PPAPI_TOKEN_SCOPE == "https://api.powerplatform.com"
193- assert PPAPI_TEST_TOKEN_SCOPE == "https://api.test.powerplatform.com "
173+ assert PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE == "ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default "
194174
195175 def test_get_tooling_gateway_empty_agent_id (self ):
196176 """Test get_tooling_gateway_for_digital_worker with empty agent ID."""
@@ -201,20 +181,17 @@ def test_get_tooling_gateway_empty_agent_id(self):
201181 result = get_tooling_gateway_for_digital_worker (agent_user_id )
202182
203183 # Assert - Function should still work but produce invalid URL
204- expected = (
205- f"{ MCP_PLATFORM_PROD_BASE_URL } /agentGateway/agentApplicationInstances//mcpServers"
206- )
184+ expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agents//mcpServers"
207185 assert result == expected
208186
209187 def test_build_mcp_server_url_empty_params (self ):
210188 """Test build_mcp_server_url with empty parameters."""
211189 # Arrange
212- environment_id = ""
213190 server_name = ""
214191
215192 # Act
216- result = build_mcp_server_url (environment_id , server_name )
193+ result = build_mcp_server_url (server_name )
217194
218195 # Assert
219- expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /mcp/environments/ /servers/"
196+ expected = f"{ MCP_PLATFORM_PROD_BASE_URL } /agents /servers/"
220197 assert result == expected
0 commit comments