22import { ApiClient } from "../../src/common/atlas/apiClient.js" ;
33import { ensureCurrentIpInAccessList } from "../../src/common/atlas/accessListUtils.js" ;
44import { jest } from "@jest/globals" ;
5+ import { ApiClientError } from "../../src/common/atlas/apiClientError.js" ;
56
6- describe ( "ensureCurrentIpInAccessList " , ( ) => {
7+ describe ( "accessListUtils " , ( ) => {
78 it ( "should add the current IP to the access list" , async ( ) => {
89 const apiClient = {
910 getIpInfo : jest . fn ( ) . mockResolvedValue ( { currentIpv4Address : "127.0.0.1" } as never ) ,
@@ -12,19 +13,30 @@ describe("ensureCurrentIpInAccessList", () => {
1213 await ensureCurrentIpInAccessList ( apiClient , "projectId" ) ;
1314 expect ( apiClient . createProjectIpAccessList ) . toHaveBeenCalledWith ( {
1415 params : { path : { groupId : "projectId" } } ,
15- body : [ { groupId : "projectId" , ipAddress : "127.0.0.1" , comment : "Added by MCP pre-run access list helper" } ] ,
16+ body : [
17+ { groupId : "projectId" , ipAddress : "127.0.0.1" , comment : "Added by MCP pre-run access list helper" } ,
18+ ] ,
1619 } ) ;
1720 } ) ;
1821
1922 it ( "should not fail if the current IP is already in the access list" , async ( ) => {
2023 const apiClient = {
2124 getIpInfo : jest . fn ( ) . mockResolvedValue ( { currentIpv4Address : "127.0.0.1" } as never ) ,
22- createProjectIpAccessList : jest . fn ( ) . mockRejectedValue ( { response : { status : 409 } } as never ) ,
25+ createProjectIpAccessList : jest
26+ . fn ( )
27+ . mockRejectedValue (
28+ ApiClientError . fromError (
29+ { status : 409 , statusText : "Conflict" } as Response ,
30+ { message : "Conflict" } as never
31+ ) as never
32+ ) ,
2333 } as unknown as ApiClient ;
2434 await ensureCurrentIpInAccessList ( apiClient , "projectId" ) ;
2535 expect ( apiClient . createProjectIpAccessList ) . toHaveBeenCalledWith ( {
2636 params : { path : { groupId : "projectId" } } ,
27- body : [ { groupId : "projectId" , ipAddress : "127.0.0.1" , comment : "Added by MCP pre-run access list helper" } ] ,
37+ body : [
38+ { groupId : "projectId" , ipAddress : "127.0.0.1" , comment : "Added by MCP pre-run access list helper" } ,
39+ ] ,
2840 } ) ;
2941 } ) ;
3042} ) ;
0 commit comments