@@ -2,16 +2,25 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
22import { Session } from "../../../../src/session.js" ;
33import { describeAtlas , withProject } from "./atlasHelpers.js" ;
44
5+ function generateRandomIp ( ) {
6+ const randomIp : number [ ] = [ 192 ] ;
7+ for ( let i = 0 ; i < 3 ; i ++ ) {
8+ randomIp . push ( Math . floor ( Math . random ( ) * 256 ) ) ;
9+ }
10+ return randomIp . join ( "." ) ;
11+ }
12+
513describeAtlas ( "ip access lists" , ( integration ) => {
614 withProject ( integration , ( { getProjectId } ) => {
7- let ipInfo : {
8- currentIpv4Address : string ;
9- } ;
15+ const ips = [ generateRandomIp ( ) , generateRandomIp ( ) ]
16+ const cidrBlocks = [ generateRandomIp ( ) + "/16" , generateRandomIp ( ) + "/24" ] ;
17+ const values = [ ... ips , ... cidrBlocks ] ;
1018
1119 beforeAll ( async ( ) => {
1220 const session : Session = integration . mcpServer ( ) . session ;
1321 session . ensureAuthenticated ( ) ;
14- ipInfo = await session . apiClient . getIpInfo ( ) ;
22+ const ipInfo = await session . apiClient . getIpInfo ( ) ;
23+ values . push ( ipInfo . currentIpv4Address ) ;
1524 } ) ;
1625
1726 afterAll ( async ( ) => {
@@ -20,32 +29,16 @@ describeAtlas("ip access lists", (integration) => {
2029
2130 const projectId = getProjectId ( ) ;
2231
23- await session . apiClient . deleteProjectIpAccessList ( {
24- params : {
25- path : {
26- groupId : projectId ,
27- entryValue : ipInfo . currentIpv4Address ,
28- } ,
29- } ,
30- } ) ;
31-
32- await session . apiClient . deleteProjectIpAccessList ( {
33- params : {
34- path : {
35- groupId : projectId ,
36- entryValue : "8.8.8.8" ,
32+ for ( const value of values ) {
33+ await session . apiClient . deleteProjectIpAccessList ( {
34+ params : {
35+ path : {
36+ groupId : projectId ,
37+ entryValue : value ,
38+ } ,
3739 } ,
38- } ,
39- } ) ;
40-
41- await session . apiClient . deleteProjectIpAccessList ( {
42- params : {
43- path : {
44- groupId : projectId ,
45- entryValue : "9.9.9.9/24" ,
46- } ,
47- } ,
48- } ) ;
40+ } ) ;
41+ }
4942 } ) ;
5043
5144 describe ( "atlas-create-access-list" , ( ) => {
@@ -69,8 +62,8 @@ describeAtlas("ip access lists", (integration) => {
6962 name : "atlas-create-access-list" ,
7063 arguments : {
7164 projectId,
72- ipAddresses : [ "8.8.8.8" ] ,
73- cidrBlocks : [ "9.9.9.9/24" ] ,
65+ ipAddresses : ips ,
66+ cidrBlocks : cidrBlocks ,
7467 currentIpAddress : true ,
7568 } ,
7669 } ) ) as CallToolResult ;
@@ -98,9 +91,9 @@ describeAtlas("ip access lists", (integration) => {
9891 . callTool ( { name : "atlas-inspect-access-list" , arguments : { projectId } } ) ) as CallToolResult ;
9992 expect ( response . content ) . toBeArray ( ) ;
10093 expect ( response . content ) . toHaveLength ( 1 ) ;
101- expect ( response . content [ 0 ] . text ) . toContain ( "8.8.8.8" ) ;
102- expect ( response . content [ 0 ] . text ) . toContain ( "9.9.9.9/24" ) ;
103- expect ( response . content [ 0 ] . text ) . toContain ( ipInfo . currentIpv4Address ) ;
94+ for ( const value of values ) {
95+ expect ( response . content [ 0 ] . text ) . toContain ( value ) ;
96+ }
10497 } ) ;
10598 } ) ;
10699 } ) ;
0 commit comments