diff --git a/.env.example b/.env.example index a3fcc1341..2f0f9ce05 100644 --- a/.env.example +++ b/.env.example @@ -171,6 +171,13 @@ GRAPHER_BACKEND_MRTG_DBTYPE="rrd" # GRAPHER_BACKEND_SMOKEPING_URL="http://www.example.com/smokeping" +################################################################################# +## IX-F Member Export - see: https://docs.ixpmanager.org/features/ixf-export/ + + +IXP_API_JSONEXPORTSCHEMA_PUBLIC=true + + ####################################################################################### ### Skinning # diff --git a/app/Http/Controllers/Api/V4/MemberExportController.php b/app/Http/Controllers/Api/V4/MemberExportController.php index d1220ac23..4085b84f9 100644 --- a/app/Http/Controllers/Api/V4/MemberExportController.php +++ b/app/Http/Controllers/Api/V4/MemberExportController.php @@ -24,7 +24,7 @@ */ use Auth; -use Illuminate\Http\Response; +use Illuminate\Http\{Request,Response}; use IXP\Utils\Export\JsonSchema as JsonSchemaExporter; @@ -35,17 +35,20 @@ class MemberExportController extends Controller { /** * API call to generate DNS ARPA records in a given format * + * @param Request $r * @param string $version Version fo schema to export * @return Response */ - public function ixf( string $version = JsonSchemaExporter::EUROIX_JSON_LATEST ) { + public function ixf( Request $r, string $version = JsonSchemaExporter::EUROIX_JSON_LATEST ) { if( !Auth::check() && !config( 'ixp_api.json_export_schema.public', false ) ) { abort(401, 'Public access not permitted' ); } + $withTags = $r->query('withtags', null) === "1"; + $exporter = new JsonSchemaExporter; - return response()->json( $exporter->get( $version, true, Auth::check() ), 200, [], JSON_PRETTY_PRINT ) + return response()->json( $exporter->get( $version, true, Auth::check(), $withTags ), 200, [], JSON_PRETTY_PRINT ) ->header( "Access-Control-Allow-Origin", "*" ); } diff --git a/app/Utils/Export/JsonSchema.php b/app/Utils/Export/JsonSchema.php index f63d8a6a1..f0eac2229 100644 --- a/app/Utils/Export/JsonSchema.php +++ b/app/Utils/Export/JsonSchema.php @@ -66,10 +66,11 @@ class JsonSchema * * @param string $version The version to get (or, if null / not present then the latest) * @param bool $asArray Do not convert to JSON but rather return the PHP array - * @param bool $detailed Create the very detailed version (usualy for logged in users) + * @param bool $detailed Create the very detailed version (usually for logged in users) + * @param bool $tags Include customer tags * @return string|array */ - public function get( $version = null, $asArray = false, $detailed = true ) + public function get( $version = null, $asArray = false, $detailed = true, $tags = false ) { if( $version === null ) { $version = self::EUROIX_JSON_LATEST; @@ -84,13 +85,13 @@ public function get( $version = null, $asArray = false, $detailed = true ) $output['timestamp'] = date( 'Y-m-d', time() ) . 'T' . date( 'H:i:s', time() ) . 'Z'; $output['ixp_list'] = $this->getIXPInfo( $version ); - $output['member_list'] = $this->getMemberInfo( $version, $detailed ); + $output['member_list'] = $this->getMemberInfo( $version, $detailed, $tags ); if( $asArray ) { return $output; } - return json_encode( $output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )."\n"; + return json_encode( $output, JSON_PRETTY_PRINT )."\n"; } /** @@ -222,7 +223,7 @@ private function getSwitchInfo( $version, Infrastructure $infra ) * @param string $version The version to collate the detail for * @return array */ - private function getMemberInfo( string $version, bool $detailed ) + private function getMemberInfo( string $version, bool $detailed, bool $tags ) { $memberinfo = []; @@ -376,6 +377,15 @@ private function getMemberInfo( string $version, bool $detailed ) } + if( $tags ) { + $memberinfo[$cnt]['ixp_manager']['tags'] = []; + foreach( $c->getTags() as $tag ) { + if( !$tag->isInternalOnly() || $detailed ) { + $memberinfo[$cnt]['ixp_manager']['tags'][ $tag->getTag() ] = $tag->getDisplayAs(); + } + } + } + $memberinfo[$cnt]['connection_list'] = $connlist; $cnt++; diff --git a/data/travis-ci/known-good/api-v4-member-export-0.6-auth.json b/data/travis-ci/known-good/api-v4-member-export-0.6-auth.json new file mode 100644 index 000000000..fe55f60ec --- /dev/null +++ b/data/travis-ci/known-good/api-v4-member-export-0.6-auth.json @@ -0,0 +1,356 @@ +{ + "version": "0.6", + "timestamp": "2018-06-19T13:57:26Z", + "ixp_list": [ + { + "shortname": "Infrastructure #1", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 48, + "ixf_id": 20, + "ixp_id": 1, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 1, + "name": "switch1", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***" + } + ] + }, + { + "shortname": "Infrastructure #2", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 387, + "ixf_id": 645, + "ixp_id": 2, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 2, + "name": "switch2", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***" + } + ] + } + ], + "member_list": [ + { + "asnum": 42, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "PCH DNS", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 100 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.36", + "as_macro": "AS-PCH", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 2000 + } + } + ] + } + ] + }, + { + "asnum": 112, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "AS112", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1", + "test-tag2": "Test Tag2" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.6", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 20 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.6", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 20 + } + } + ] + } + ] + }, + { + "asnum": 1213, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "HEAnet", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + }, + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:1::10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:2::11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + } + ] + }, + { + "asnum": 2128, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.siep.com\/", + "name": "INEX", + "peering_policy": "mandatory", + "member_type": "ixp", + "contact_email": [ + "peering@siep.net" + ], + "contact_phone": [ + "+353 1 123 4567" + ], + "peering_policy_url": "http:\/\/www.siep.com\/noc\/", + "contact_hours": "24x7", + "ixp_manager": { + "tags": { + "test-tag2": "Test Tag2" + } + }, + "connection_list": [] + }, + { + "asnum": 25441, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "Imagine", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv6": { + "address": "2001:db8:1::8", + "as_macro": "AS-IBIS", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:2::46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + } + ] + } + ] +} diff --git a/data/travis-ci/known-good/api-v4-member-export-0.6-unauth.json b/data/travis-ci/known-good/api-v4-member-export-0.6-unauth.json new file mode 100644 index 000000000..739726083 --- /dev/null +++ b/data/travis-ci/known-good/api-v4-member-export-0.6-unauth.json @@ -0,0 +1,311 @@ +{ + "version": "0.6", + "timestamp": "2018-06-19T13:57:43Z", + "ixp_list": [ + { + "shortname": "Infrastructure #1", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 48, + "ixf_id": 20, + "ixp_id": 1, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 1, + "name": "switch1", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***" + } + ] + }, + { + "shortname": "Infrastructure #2", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 387, + "ixf_id": 645, + "ixp_id": 2, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 2, + "name": "switch2", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***" + } + ] + } + ], + "member_list": [ + { + "asnum": 42, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "PCH DNS", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 100 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.36", + "as_macro": "AS-PCH", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 112, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "AS112", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.6", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.6", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 1213, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "HEAnet", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + }, + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:1::10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:2::11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 2128, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.siep.com\/", + "name": "INEX", + "peering_policy": "mandatory", + "member_type": "ixp", + "ixp_manager": { + "tags": [] + }, + "connection_list": [] + }, + { + "asnum": 25441, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "Imagine", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv6": { + "address": "2001:db8:1::8", + "as_macro": "AS-IBIS", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:2::46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [] + } + } + ] + } + ] + } + ] +} diff --git a/data/travis-ci/known-good/api-v4-member-export-0.7-auth.json b/data/travis-ci/known-good/api-v4-member-export-0.7-auth.json new file mode 100644 index 000000000..d6d115956 --- /dev/null +++ b/data/travis-ci/known-good/api-v4-member-export-0.7-auth.json @@ -0,0 +1,360 @@ +{ + "version": "0.7", + "timestamp": "2018-06-19T13:57:11Z", + "ixp_list": [ + { + "shortname": "Infrastructure #1", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 48, + "ixf_id": 20, + "ixp_id": 1, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 1, + "name": "switch1", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "manufacturer": "Brocade", + "model": "FESX624" + } + ] + }, + { + "shortname": "Infrastructure #2", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 387, + "ixf_id": 645, + "ixp_id": 2, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 2, + "name": "switch2", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "manufacturer": "Brocade", + "model": "FESX624" + } + ] + } + ], + "member_list": [ + { + "asnum": 42, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "PCH DNS", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 100 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.36", + "as_macro": "AS-PCH", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 2000 + } + } + ] + } + ] + }, + { + "asnum": 112, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "AS112", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1", + "test-tag2": "Test Tag2" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.6", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 20 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.6", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 20 + } + } + ] + } + ] + }, + { + "asnum": 1213, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "HEAnet", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + }, + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:1::10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:2::11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + } + ] + }, + { + "asnum": 2128, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.siep.com\/", + "name": "INEX", + "peering_policy": "mandatory", + "member_type": "ixp", + "contact_email": [ + "peering@siep.net" + ], + "contact_phone": [ + "+353 1 123 4567" + ], + "peering_policy_url": "http:\/\/www.siep.com\/noc\/", + "contact_hours": "24x7", + "ixp_manager": { + "tags": { + "test-tag2": "Test Tag2" + } + }, + "connection_list": [] + }, + { + "asnum": 25441, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "Imagine", + "peering_policy": "open", + "member_type": "peering", + "contact_email": [ + "peering@example.com" + ], + "contact_phone": [ + "" + ], + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv6": { + "address": "2001:db8:1::8", + "as_macro": "AS-IBIS", + "routeserver": true, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [], + "max_prefix": 1000 + }, + "ipv6": { + "address": "2001:db8:2::46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [], + "max_prefix": 1000 + } + } + ] + } + ] + } + ] +} diff --git a/data/travis-ci/known-good/api-v4-member-export-0.7-unauth.json b/data/travis-ci/known-good/api-v4-member-export-0.7-unauth.json new file mode 100644 index 000000000..7ca6f4cf1 --- /dev/null +++ b/data/travis-ci/known-good/api-v4-member-export-0.7-unauth.json @@ -0,0 +1,315 @@ +{ + "version": "0.7", + "timestamp": "2018-06-19T13:57:41Z", + "ixp_list": [ + { + "shortname": "Infrastructure #1", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 48, + "ixf_id": 20, + "ixp_id": 1, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 1, + "name": "switch1", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "manufacturer": "Brocade", + "model": "FESX624" + } + ] + }, + { + "shortname": "Infrastructure #2", + "name": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "url": "*** CONFIG IDENTITY IN .env ***", + "peeringdb_id": 387, + "ixf_id": 645, + "ixp_id": 2, + "support_email": "*** CONFIG IDENTITY IN .env ***", + "support_phone": "*** CONFIG IDENTITY IN .env ***", + "support_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "emergency_email": "*** CONFIG IDENTITY IN .env ***", + "emergency_phone": "*** CONFIG IDENTITY IN .env ***", + "emergency_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_contact_hours": "*** CONFIG IDENTITY IN .env ***", + "billing_email": "*** CONFIG IDENTITY IN .env ***", + "billing_phone": "*** CONFIG IDENTITY IN .env ***", + "peering_policy_list": [ + "open", + "selective", + "mandatory", + "closed" + ], + "vlan": [], + "switch": [ + { + "id": 2, + "name": "switch2", + "colo": "Location 1", + "city": "*** CONFIG IDENTITY IN .env ***", + "country": "*** CONFIG IDENTITY IN .env ***", + "manufacturer": "Brocade", + "model": "FESX624" + } + ] + } + ], + "member_list": [ + { + "asnum": 42, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "PCH DNS", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 100 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.36", + "as_macro": "AS-PCH", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 112, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "AS112", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.6", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.6", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 1213, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "HEAnet", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": [] + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + }, + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv4": { + "address": "10.1.0.10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:1::10", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:2::11", + "as_macro": "AS-HEANET", + "routeserver": true, + "mac_addresses": [] + } + } + ] + } + ] + }, + { + "asnum": 2128, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.siep.com\/", + "name": "INEX", + "peering_policy": "mandatory", + "member_type": "ixp", + "ixp_manager": { + "tags": [] + }, + "connection_list": [] + }, + { + "asnum": 25441, + "member_since": "2014-01-06T00:00:00Z", + "url": "http:\/\/www.example.com\/", + "name": "Imagine", + "peering_policy": "open", + "member_type": "peering", + "ixp_manager": { + "tags": { + "test-tag1": "Test Tag1" + } + }, + "connection_list": [ + { + "ixp_id": 1, + "state": "active", + "if_list": [ + { + "switch_id": 1, + "if_speed": 1000 + } + ], + "vlan_list": [ + { + "vlan_id": 1, + "ipv6": { + "address": "2001:db8:1::8", + "as_macro": "AS-IBIS", + "routeserver": true, + "mac_addresses": [] + } + } + ] + }, + { + "ixp_id": 2, + "state": "active", + "if_list": [ + { + "switch_id": 2, + "if_speed": 10000 + } + ], + "vlan_list": [ + { + "vlan_id": 2, + "ipv4": { + "address": "10.2.0.46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [] + }, + "ipv6": { + "address": "2001:db8:2::46", + "as_macro": "AS-IBIS", + "routeserver": false, + "mac_addresses": [] + } + } + ] + } + ] + } + ] +} diff --git a/resources/views/customer/overview.foil.php b/resources/views/customer/overview.foil.php index 3a6c6f8a1..306228f81 100644 --- a/resources/views/customer/overview.foil.php +++ b/resources/views/customer/overview.foil.php @@ -135,21 +135,18 @@ - getTags()->count() ): ?> -
-
- insert( 'customer/cust-type', [ 'cust' => $t->c ] ); ?> - - getTags() as $tag ): ?> - getDisplayAs() ?> - - -
- findAll() ) ): ?> -
+
+
insert( 'customer/cust-type', [ 'cust' => $t->c ] ); ?> -  Add tags... - + getTags()->count() ): ?> + getTags() as $tag ): ?> + getDisplayAs() ?> + + + findAll() ) ): ?> +  Add tags... + +
diff --git a/tests/Utils/IxfMemberExportTest.php b/tests/Utils/IxfMemberExportTest.php new file mode 100644 index 000000000..384742939 --- /dev/null +++ b/tests/Utils/IxfMemberExportTest.php @@ -0,0 +1,67 @@ + + * @category Tests + * @copyright Copyright (C) 2009-2018 Internet Neutral Exchange Association Company Limited By Guarantee + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL V2.0 + */ +class IxfMemberExportTest extends TestCase +{ + public $versions = [ '0.7', '0.6' ]; + + public function testIxfMemberExportGeneration() + { + $exporter = new JsonSchemaExporter; + + foreach( $this->versions as $v ) { + + foreach( [ false, true ] as $auth ) { + + $json = $exporter->get( $v, false, $auth, true ); + + $a = ( $auth ? '' : 'un' ) . 'auth'; + + $knownGoodConf = file_get_contents( base_path() . "/data/travis-ci/known-good/api-v4-member-export-{$v}-{$a}.json" ); + $this->assertFalse( $knownGoodConf === false, "IX-F Member Export - could not load known good file api-v4-member-export-{$v}-{$a}.json" ); + + // clean the exports to set timestamp the same + $json = preg_replace( '/^\s+\"timestamp\": \"[0-9:\-TZ]+\",$/m', "", $json ); + $knownGoodConf = preg_replace( '/^\s+\"timestamp\": \"[0-9:\-TZ]+\",$/m', "", $knownGoodConf ); + + $this->assertEquals( $knownGoodConf, $json, "Known good and generated IX-F Member Export for {$v}-{$a} do not match" ); + } + } + + } + +}