Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d45541a11 | ||
|
|
066707ece6 | ||
|
|
c1f4a71963 | ||
|
|
cf2ddf21a1 |
@@ -19,12 +19,21 @@ class InvestmentTerritoryController extends Controller
|
|||||||
$data = $request->validate(['territory_id' => ['required', 'uuid']]);
|
$data = $request->validate(['territory_id' => ['required', 'uuid']]);
|
||||||
$profile = $request->is('minhas-oportunidades/*');
|
$profile = $request->is('minhas-oportunidades/*');
|
||||||
$management = $request->is('management/*') || $profile;
|
$management = $request->is('management/*') || $profile;
|
||||||
|
$actor = $request->user();
|
||||||
|
$access = app(PortalProfileAccess::class);
|
||||||
|
// The general consumers use this same endpoint while authenticated.
|
||||||
|
// Reuse the read access already granted by the private cadastral routes.
|
||||||
|
$profileAccess = $actor && $actor->hasVerifiedEmail()
|
||||||
|
&& ($access->grants($actor) !== [] || $access->superuser($actor));
|
||||||
|
$internal = $profileAccess || ($actor?->hasVerifiedEmail() && $actor->can('manage-portal'));
|
||||||
if ($management) {
|
if ($management) {
|
||||||
$access = app(PortalProfileAccess::class);
|
abort_unless($profile ? $profileAccess : $internal, 403);
|
||||||
abort_unless($profile ? ($access->grants($request->user()) !== [] || $access->superuser($request->user())) : $request->user()?->can('manage-portal'), 403);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(app(TerritoryGeometry::class)->context($data['territory_id'], $management));
|
return response()->json([
|
||||||
|
...app(TerritoryGeometry::class)->context($data['territory_id'], $internal),
|
||||||
|
'geometry_scope' => $internal ? 'authorized_internal' : 'public',
|
||||||
|
])->header('Cache-Control', 'private, no-store');
|
||||||
}
|
}
|
||||||
|
|
||||||
private const TABLES = ['opportunities' => 'opportunities', 'projects' => 'projects', 'clusters' => 'economic_clusters', 'corridors' => 'development_corridors', 'zones' => 'investment_zones'];
|
private const TABLES = ['opportunities' => 'opportunities', 'projects' => 'projects', 'clusters' => 'economic_clusters', 'corridors' => 'development_corridors', 'zones' => 'investment_zones'];
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ final class EnsureScopedPortalAdministration
|
|||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
$actor = $request->user();
|
$actor = $request->user();
|
||||||
abort_unless($actor, 403);
|
abort_unless($actor !== null, 403);
|
||||||
$scope = app(ScopedPortalAdministration::class);
|
$scope = app(ScopedPortalAdministration::class);
|
||||||
$path = $request->path();
|
$path = $request->path();
|
||||||
$interests = $request->is('management/interests', 'management/interests/*', 'api/v1/investment/admin/interests/*');
|
$interests = $request->is('management/interests', 'management/interests/*', 'api/v1/investment/admin/interests/*');
|
||||||
// Fiscal maintenance reuses authorised administration; unrelated gates remain unchanged.
|
// Fiscal maintenance reuses authorised administration; unrelated gates remain unchanged.
|
||||||
$catalogue = $request->is('management/territory-geometry-import', 'management/territory-geometry-import/*',
|
$geometryRead = $request->isMethod('GET') && $path === 'management/territory-geometries';
|
||||||
|
$catalogue = $geometryRead || $request->is('management/territory-geometry-import', 'management/territory-geometry-import/*',
|
||||||
'management/economic-references/lot-01', 'management/economic-references/lot-01/*',
|
'management/economic-references/lot-01', 'management/economic-references/lot-01/*',
|
||||||
'management/education', 'management/education/*', 'management/investment/references', 'management/investment/references/*', 'api/v1/investment/admin/references', 'api/v1/investment/admin/references/*',
|
'management/education', 'management/education/*', 'management/investment/references', 'management/investment/references/*', 'api/v1/investment/admin/references', 'api/v1/investment/admin/references/*',
|
||||||
'management/investment/zones', 'management/investment/zones/*', 'api/v2/investment/admin/zones', 'api/v2/investment/admin/zones/*',
|
'management/investment/zones', 'management/investment/zones/*', 'api/v2/investment/admin/zones', 'api/v2/investment/admin/zones/*',
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/** Public read projection authorized by Tempo; source rows and originals stay private. */
|
||||||
|
class ApprovedAdministrativeBoundaries
|
||||||
|
{
|
||||||
|
public const HASH = '06ab905fcf9b19115c3521bf81de03f37873880f7765f229b9e1f79d99df7adc';
|
||||||
|
|
||||||
|
/** @var array<string,array<string,string>>|null */
|
||||||
|
private ?array $items = null;
|
||||||
|
|
||||||
|
/** @return array<string,array<string,string>> */
|
||||||
|
public function snapshots(): array
|
||||||
|
{
|
||||||
|
if ($this->items !== null) {
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
$contents = file_get_contents(base_path('docs/investmoz/unification/approved-administrative-boundaries-20261024.json'));
|
||||||
|
if ($contents === false || ! hash_equals(self::HASH, hash('sha256', str_replace("\r\n", "\n", $contents)))) {
|
||||||
|
throw new RuntimeException('Approved administrative boundary manifest changed.');
|
||||||
|
}
|
||||||
|
$manifest = json_decode($contents, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
if (count($manifest['items']) !== 408) {
|
||||||
|
throw new RuntimeException('Exact 408-boundary scope required.');
|
||||||
|
}
|
||||||
|
$this->items = array_column($manifest['items'], null, 'id');
|
||||||
|
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function allows(string $id, string $territoryId, string $geometryHash, string $propertiesHash): bool
|
||||||
|
{
|
||||||
|
$item = $this->snapshots()[$id] ?? null;
|
||||||
|
|
||||||
|
return $item !== null && $item['territory_id'] === $territoryId
|
||||||
|
&& hash_equals($item['geometry_sha256'], $geometryHash)
|
||||||
|
&& hash_equals($item['properties_sha256'], $propertiesHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,13 +8,16 @@ use RuntimeException;
|
|||||||
/** Exact replay of the 28 accepted links into the transported project identities. */
|
/** Exact replay of the 28 accepted links into the transported project identities. */
|
||||||
final class ApprovedAnchorTerritories
|
final class ApprovedAnchorTerritories
|
||||||
{
|
{
|
||||||
public const HASH = 'dc3ae2014da51005d95780e2e4ae87e55e000e66e0765f0671c6e44a958026a0';
|
public const HASH = 'd2893d0a638d630435aca1890f79a8094dc58eb65bbdd65a470bb685fa075190';
|
||||||
|
|
||||||
/** @return array{manifest_sha256:string,projects:list<array<string,mixed>>,links:list<array<string,mixed>>} */
|
/** @return array{manifest_sha256:string,projects:list<array<string,mixed>>,links:list<array<string,mixed>>} */
|
||||||
public function plan(): array
|
public function plan(): array
|
||||||
{
|
{
|
||||||
$file = base_path('docs/investmoz/unification/approved-anchor-territories-20261023.json');
|
$file = base_path('docs/investmoz/unification/approved-anchor-territories-20261023.json');
|
||||||
$contents = is_file($file) ? file_get_contents($file) : false;
|
$contents = is_file($file) ? file_get_contents($file) : false;
|
||||||
|
if ($contents !== false) {
|
||||||
|
$contents = str_replace("\r\n", "\n", $contents);
|
||||||
|
}
|
||||||
if ($contents === false || ! hash_equals(self::HASH, hash('sha256', $contents))) {
|
if ($contents === false || ! hash_equals(self::HASH, hash('sha256', $contents))) {
|
||||||
throw new RuntimeException('Reviewed territorial manifest changed.');
|
throw new RuntimeException('Reviewed territorial manifest changed.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,31 @@ final class TerritoryGeometry
|
|||||||
abort_unless($geography->references($management)->where('id', $id)->exists(), 404);
|
abort_unless($geography->references($management)->where('id', $id)->exists(), 404);
|
||||||
$path = $geography->path($id, $management);
|
$path = $geography->path($id, $management);
|
||||||
$ids = array_map(fn ($node) => $node->id, $path);
|
$ids = array_map(fn ($node) => $node->id, $path);
|
||||||
|
$approved = app(ApprovedAdministrativeBoundaries::class);
|
||||||
$rows = DB::table('geo_geometries as g')->join('geo_locations as l', 'l.id', '=', 'g.geo_location_id')
|
$rows = DB::table('geo_geometries as g')->join('geo_locations as l', 'l.id', '=', 'g.geo_location_id')
|
||||||
->whereIn('g.geo_location_id', $ids)->whereNull('g.deleted_at')->whereNull('l.deleted_at')
|
->whereIn('g.geo_location_id', $ids)->whereNull('g.deleted_at')->whereNull('l.deleted_at')
|
||||||
->whereIn('g.data_classification', $management ? ['internal', 'public'] : ['public'])
|
->where(function ($query) use ($management, $approved) {
|
||||||
|
$query->where('g.data_classification', 'public');
|
||||||
|
$query->orWhere(function ($internal) use ($management, $approved) {
|
||||||
|
$internal->where('g.data_classification', 'internal');
|
||||||
|
if (! $management) {
|
||||||
|
$internal->whereIn('g.id', array_keys($approved->snapshots()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
->whereRaw("g.properties->>'purpose' = 'administrative_boundary'")
|
->whereRaw("g.properties->>'purpose' = 'administrative_boundary'")
|
||||||
->whereIn('g.geometry_type', ['polygon', 'multipolygon'])
|
->whereIn('g.geometry_type', ['polygon', 'multipolygon'])
|
||||||
->whereRaw('ST_IsValid(g.geom) AND NOT ST_IsEmpty(g.geom) AND ST_SRID(g.geom)=4326')
|
->whereRaw('ST_IsValid(g.geom) AND NOT ST_IsEmpty(g.geom) AND ST_SRID(g.geom)=4326')
|
||||||
->orderBy('g.geo_location_id')->orderBy('g.id')->limit(101)
|
->orderBy('g.geo_location_id')->orderBy('g.id')->limit(101)
|
||||||
->get(['g.id', 'g.geo_location_id', 'l.name', 'l.location_type', 'g.properties', 'g.data_classification',
|
->get(['g.id', 'g.geo_location_id', 'l.name', 'l.location_type', 'g.properties', 'g.data_classification',
|
||||||
DB::raw('ST_AsGeoJSON(ST_SimplifyPreserveTopology(g.geom,0.0001),6) as geometry')]);
|
DB::raw('ST_AsGeoJSON(ST_SimplifyPreserveTopology(g.geom,0.0001),6) as geometry'),
|
||||||
$areas = $rows->take(100)->map(function ($row) use ($id) {
|
DB::raw("encode(sha256(ST_AsEWKB(g.geom)),'hex') as geometry_sha256"),
|
||||||
|
DB::raw("encode(sha256(convert_to(g.properties::text,'UTF8')),'hex') as properties_sha256")]);
|
||||||
|
if (! $management) {
|
||||||
|
$rows = $rows->filter(fn ($row) => $row->data_classification === 'public'
|
||||||
|
|| $approved->allows($row->id, $row->geo_location_id, $row->geometry_sha256, $row->properties_sha256))->values();
|
||||||
|
}
|
||||||
|
$areas = $rows->take(100)->map(function ($row) use ($id, $management) {
|
||||||
$source = json_decode($row->properties, true, 512, JSON_THROW_ON_ERROR);
|
$source = json_decode($row->properties, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
return ['id' => $row->id, 'territory_id' => $row->geo_location_id, 'location_type' => $row->location_type,
|
return ['id' => $row->id, 'territory_id' => $row->geo_location_id, 'location_type' => $row->location_type,
|
||||||
@@ -31,7 +46,7 @@ final class TerritoryGeometry
|
|||||||
'title' => 'Limite administrativo: '.$row->name, 'purpose' => 'administrative_boundary',
|
'title' => 'Limite administrativo: '.$row->name, 'purpose' => 'administrative_boundary',
|
||||||
'source_reference' => $source['authority'] ?? null, 'source_date' => $source['source_version'] ?? null,
|
'source_reference' => $source['authority'] ?? null, 'source_date' => $source['source_version'] ?? null,
|
||||||
'source_url' => $source['source_url'] ?? null, 'source_sha256' => $source['source_sha256'] ?? null,
|
'source_url' => $source['source_url'] ?? null, 'source_sha256' => $source['source_sha256'] ?? null,
|
||||||
'data_classification' => $row->data_classification, 'legal_currentness' => $source['legal_currentness'] ?? 'not_determined', 'url' => ''];
|
'data_classification' => $management ? $row->data_classification : 'public', 'legal_currentness' => $source['legal_currentness'] ?? 'not_determined', 'url' => ''];
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
return ['territory_id' => $id, 'territory_registered' => true,
|
return ['territory_id' => $id, 'territory_registered' => true,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"status": "implemented_and_demonstrated_in_isolated_QA_not_yet_delivered",
|
"status": "installed_in_homologation_territories_recovered_delta_verified",
|
||||||
"date": "2026-10-23",
|
"date": "2026-10-23",
|
||||||
"base": "8036b9b0",
|
"base": "8036b9b0",
|
||||||
"accepted_delivery_receipt": "cdf8fcfb",
|
"accepted_delivery_receipt": "cdf8fcfb",
|
||||||
@@ -110,16 +110,14 @@
|
|||||||
"statistics",
|
"statistics",
|
||||||
"AI"
|
"AI"
|
||||||
],
|
],
|
||||||
"pending": [
|
"pending": [],
|
||||||
"Git integration and installation",
|
|
||||||
"Exact territorial recovery in homologation",
|
|
||||||
"Installed delta check"
|
|
||||||
],
|
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
"outputs/anchor-integration-20261023/qa-sector-location.png",
|
"outputs/anchor-integration-20261023/qa-sector-location.png",
|
||||||
"outputs/anchor-integration-20261023/qa-anchor-fiche.png",
|
"outputs/anchor-integration-20261023/qa-anchor-fiche.png",
|
||||||
"outputs/anchor-integration-20261023/qa-anchor-dossier.png",
|
"outputs/anchor-integration-20261023/qa-anchor-dossier.png",
|
||||||
"outputs/anchor-integration-20261023/qa-anchor-simulator.png"
|
"outputs/anchor-integration-20261023/qa-anchor-simulator.png",
|
||||||
|
"outputs/anchor-integration-20261023/homologation-sector-location.png",
|
||||||
|
"outputs/anchor-integration-20261023/homologation-anchor-fiche.png"
|
||||||
],
|
],
|
||||||
"visual_QA": {
|
"visual_QA": {
|
||||||
"anchor_code": "A06",
|
"anchor_code": "A06",
|
||||||
@@ -132,5 +130,204 @@
|
|||||||
"deliberate_title_preserved": true,
|
"deliberate_title_preserved": true,
|
||||||
"source_link_visible_in_dossier_and_simulator": true,
|
"source_link_visible_in_dossier_and_simulator": true,
|
||||||
"manifestation": "HTTP directed proof, including ownership, same-source identity and versioned binding; browser native confirmation cancelled after control timeout; no formal submission"
|
"manifestation": "HTTP directed proof, including ownership, same-source identity and versioned binding; browser native confirmation cancelled after control timeout; no formal submission"
|
||||||
|
},
|
||||||
|
"served_commit": "cf2ddf21a1457f4852fe6aa10069ec3b854f1567",
|
||||||
|
"functional_commits": [
|
||||||
|
"3fd5128c",
|
||||||
|
"cf2ddf21"
|
||||||
|
],
|
||||||
|
"installation": {
|
||||||
|
"service": "ExecMainStatus=0\nActiveState=inactive\nSubState=dead\n",
|
||||||
|
"installed": {
|
||||||
|
"status": "installed",
|
||||||
|
"commit": "cf2ddf21a1457f4852fe6aa10069ec3b854f1567",
|
||||||
|
"release": "/var/www/investmoz-homologacao/releases/cf2ddf21a1457f4852fe6aa10069ec3b854f1567-7749f82e",
|
||||||
|
"previous_release": "/var/www/investmoz-homologacao/releases/3fd5128c62296bc5c85dcd19f1458a7949de5784-803cd41e",
|
||||||
|
"database_migrations": 0,
|
||||||
|
"content_imports": 0
|
||||||
|
},
|
||||||
|
"latest_report": {
|
||||||
|
"status": "installed",
|
||||||
|
"commit": "cf2ddf21a1457f4852fe6aa10069ec3b854f1567",
|
||||||
|
"release": "/var/www/investmoz-homologacao/releases/cf2ddf21a1457f4852fe6aa10069ec3b854f1567-7749f82e",
|
||||||
|
"previous_release": "/var/www/investmoz-homologacao/releases/3fd5128c62296bc5c85dcd19f1458a7949de5784-803cd41e",
|
||||||
|
"database_migrations": 0,
|
||||||
|
"content_imports": 0,
|
||||||
|
"requested_commits": [
|
||||||
|
"cf2ddf21a1457f4852fe6aa10069ec3b854f1567"
|
||||||
|
],
|
||||||
|
"finished_at": "2026-10-23T17:21:57.897758+00:00"
|
||||||
|
},
|
||||||
|
"log_file": "1792776037181186915.log",
|
||||||
|
"summaries": [
|
||||||
|
"OK (1 test, 3106 assertions)",
|
||||||
|
"built in 24.44s",
|
||||||
|
"OK (57 tests, 309 assertions)",
|
||||||
|
"# tests 216",
|
||||||
|
"# pass 216",
|
||||||
|
"# fail 0"
|
||||||
|
],
|
||||||
|
"log_bytes": 92267
|
||||||
|
},
|
||||||
|
"recovery_preview": {
|
||||||
|
"mode": "preview",
|
||||||
|
"database": "teste_investidor",
|
||||||
|
"port": 5432,
|
||||||
|
"qa": false,
|
||||||
|
"manifest_sha256": "d2893d0a638d630435aca1890f79a8094dc58eb65bbdd65a470bb685fa075190",
|
||||||
|
"preview_sha256": "f59e324222ea480d176f1e8e6ae164efa184904c8244873d3fcf6af8497e0dac",
|
||||||
|
"relations": 28,
|
||||||
|
"projects": 13
|
||||||
|
},
|
||||||
|
"recovery_applied": {
|
||||||
|
"mode": "applied",
|
||||||
|
"database": "teste_investidor",
|
||||||
|
"port": 5432,
|
||||||
|
"qa": false,
|
||||||
|
"manifest_sha256": "d2893d0a638d630435aca1890f79a8094dc58eb65bbdd65a470bb685fa075190",
|
||||||
|
"preview_sha256": "f59e324222ea480d176f1e8e6ae164efa184904c8244873d3fcf6af8497e0dac",
|
||||||
|
"relations": 28,
|
||||||
|
"projects": 13,
|
||||||
|
"relations_restored": 28,
|
||||||
|
"projects_updated": 13,
|
||||||
|
"new_dossiers": 0,
|
||||||
|
"publication_changes": 0
|
||||||
|
},
|
||||||
|
"installed_delta": {
|
||||||
|
"published_fiches": 29,
|
||||||
|
"territorial_links": 28,
|
||||||
|
"affected_projects": 13,
|
||||||
|
"cluster_relations": 13,
|
||||||
|
"dossier_rows_unchanged": true,
|
||||||
|
"clusters_corridors_opportunity_relations_unchanged": true,
|
||||||
|
"historical_territorial_link_identities_preserved": true,
|
||||||
|
"only_project_metadata_version_timestamp_changed": true,
|
||||||
|
"functional_file_hashes_match_Git": {
|
||||||
|
"app/Http/Controllers/InvestmentPortfolioController.php": true,
|
||||||
|
"app/Http/Controllers/InvestorContextController.php": true,
|
||||||
|
"app/Services/ApprovedAnchorTerritories.php": true,
|
||||||
|
"app/Services/InvestorContext.php": true,
|
||||||
|
"resources/js/lib/investor-context.ts": true,
|
||||||
|
"resources/js/lib/project-dossier-report.ts": true,
|
||||||
|
"resources/js/lib/search-territory.ts": true,
|
||||||
|
"resources/js/pages/investment/submission.tsx": true,
|
||||||
|
"resources/js/pages/investor-path/context-start.tsx": true,
|
||||||
|
"resources/js/pages/investor-path/context.tsx": true,
|
||||||
|
"resources/js/pages/investor-path/show.tsx": true,
|
||||||
|
"resources/js/pages/portfolio/index.tsx": true,
|
||||||
|
"resources/js/pages/portfolio/show.tsx": true,
|
||||||
|
"routes/web.php": true,
|
||||||
|
"tools/restore-approved-anchor-territories.php": true
|
||||||
|
},
|
||||||
|
"pipeline_summaries": [
|
||||||
|
"OK (1 test, 3106 assertions)",
|
||||||
|
"built in 24.44s",
|
||||||
|
"OK (57 tests, 309 assertions)",
|
||||||
|
"# tests 216",
|
||||||
|
"# pass 216",
|
||||||
|
"# fail 0"
|
||||||
|
],
|
||||||
|
"table_preservation": {
|
||||||
|
"tables": 174,
|
||||||
|
"changed_tables": {
|
||||||
|
"audit_events": {
|
||||||
|
"before": {
|
||||||
|
"rows": 632,
|
||||||
|
"checksum": "d4f2e8b30c014080b33a588eb0d8afe2"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 645,
|
||||||
|
"checksum": "88c2047620eb3fad4d2a2837ed3daef5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cache": {
|
||||||
|
"before": {
|
||||||
|
"rows": 104,
|
||||||
|
"checksum": "463aff806806b9fa2e4dff3310f516ec"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 104,
|
||||||
|
"checksum": "4963d5a25fecf3352cf0d7aee73a1e63"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"project_locations": {
|
||||||
|
"before": {
|
||||||
|
"rows": 0,
|
||||||
|
"checksum": "d41d8cd98f00b204e9800998ecf8427e"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 28,
|
||||||
|
"checksum": "80b4e44b11208a023fcfb989e738b95a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"before": {
|
||||||
|
"rows": 16,
|
||||||
|
"checksum": "af127d727cfc1050c26b99130e397109"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 16,
|
||||||
|
"checksum": "17fb48a69b09e1e8ec81b0d30e29ce80"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sessions": {
|
||||||
|
"before": {
|
||||||
|
"rows": 11,
|
||||||
|
"checksum": "912e728cc332bfc41a7e0f94c84e118d"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 15,
|
||||||
|
"checksum": "713242c22c549258fab61d1b9cd993ef"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unchanged_tables": 169
|
||||||
|
},
|
||||||
|
"exact_29_approved_fiche_identities_preserved": true,
|
||||||
|
"synthetic_fiches_transported": 0
|
||||||
|
},
|
||||||
|
"Git_preservation": {
|
||||||
|
"accepted_base_receipt": "cdf8fcfb",
|
||||||
|
"previous_installed": "8036b9b0",
|
||||||
|
"candidate": "cf2ddf21a1457f4852fe6aa10069ec3b854f1567",
|
||||||
|
"protected_files_unchanged": {
|
||||||
|
"app/Services/InvestmentComplements.php": true,
|
||||||
|
"app/Services/InvestmentConsumerScope.php": true,
|
||||||
|
"app/Services/InvestorPath.php": true,
|
||||||
|
"app/Services/SimulationFormDrafts.php": true,
|
||||||
|
"resources/js/components/investment-complements.tsx": true,
|
||||||
|
"resources/js/components/dossier-prefill.tsx": true,
|
||||||
|
"resources/js/components/investment-requirements.tsx": true
|
||||||
|
},
|
||||||
|
"matrix_changed_rows_since_accepted_receipt": [
|
||||||
|
"AUD-REL-02",
|
||||||
|
"AUD-LEG-06"
|
||||||
|
],
|
||||||
|
"other_matrix_records_preserved": 3421,
|
||||||
|
"accepted_receipt_updates_preserved": [
|
||||||
|
"AUD-SIM-INT03",
|
||||||
|
"AUD-SIM-INT06"
|
||||||
|
],
|
||||||
|
"schema_migrations_added": [],
|
||||||
|
"stats_AI_code_changed": false,
|
||||||
|
"force_push": false
|
||||||
|
},
|
||||||
|
"manifest_verification": {
|
||||||
|
"Git_LF_sha256": "d2893d0a638d630435aca1890f79a8094dc58eb65bbdd65a470bb685fa075190",
|
||||||
|
"initial_QA_Windows_bytes_sha256": "dc3ae2014da51005d95780e2e4ae87e55e000e66e0765f0671c6e44a958026a0",
|
||||||
|
"canonicalization": "CRLF to LF only; identical JSON and accepted relations",
|
||||||
|
"first_active_preview": "refused before writes; corrected canonical preview and apply succeeded"
|
||||||
|
},
|
||||||
|
"next": "Tempo final navigation and presentation evaluation",
|
||||||
|
"not_a_claim_of_complete_transversal_implementation": true,
|
||||||
|
"installed_public_delta": {
|
||||||
|
"catalogue": "https://teste-investidor.tempo.co.mz/carteira?kind=project§or=Agro-ind%C3%BAstria%20e%20agricultura&province_id=f57ff041-6275-57b9-8800-c35e46e0d475",
|
||||||
|
"results": 1,
|
||||||
|
"fiche": "57a4ee7a-4c07-4e26-b8f5-e07726e41512",
|
||||||
|
"source": "portfolio:57a4ee7a-4c07-4e26-b8f5-e07726e41512",
|
||||||
|
"territories_visible": 4,
|
||||||
|
"search_return_preserves_filters": true,
|
||||||
|
"preparation_GET_same_identity_and_province": true,
|
||||||
|
"homologation_test_dossiers_or_submissions_created": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,123 @@
|
|||||||
|
{
|
||||||
|
"scope": "Shared administrative maps stabilization",
|
||||||
|
"source_revision": "cf2ddf21",
|
||||||
|
"candidate": "066707ec",
|
||||||
|
"owner_decision": "Tempo 2026-10-24: public consultation of the exact accepted administrative contours; originals private, no parcels or other internal layers",
|
||||||
|
"diagnosis": {
|
||||||
|
"data_loss": false,
|
||||||
|
"common_consumers": "Public-only filter excluded all 408 internal administrative boundaries",
|
||||||
|
"administration": "Legacy manage-portal gate excluded both approved superusers",
|
||||||
|
"comparison": "No change in common geometry service/controller/components between 30aed7cd and cf2ddf21",
|
||||||
|
"base_map": "Provider tiles and served assets respond; browser framing is checked after installation"
|
||||||
|
},
|
||||||
|
"qa": {
|
||||||
|
"database": "simulator_fiscal_delta_20261021_test",
|
||||||
|
"port": 55441,
|
||||||
|
"tests": 6,
|
||||||
|
"assertions": 64,
|
||||||
|
"result": "passed",
|
||||||
|
"phpstan": "passed",
|
||||||
|
"writes": "Only isolated QA transactions, rolled back"
|
||||||
|
},
|
||||||
|
"baseline": {
|
||||||
|
"published_fiches": 29,
|
||||||
|
"territorial_relations": 28,
|
||||||
|
"geometries": 408,
|
||||||
|
"geometry_rows_checksum": "7d8b71d3e65d89ffdc43c748b0572dbc"
|
||||||
|
},
|
||||||
|
"backup": {
|
||||||
|
"tables": 174,
|
||||||
|
"files_verified": 369,
|
||||||
|
"restore_tables_verified": 174,
|
||||||
|
"restore_network": "none",
|
||||||
|
"dump_sha256": "2fb5b4488799bb6072c38ee41ccf91fc2a55561363c19e280ab066363d9e0647"
|
||||||
|
},
|
||||||
|
"public_manifest_sha256": "06ab905fcf9b19115c3521bf81de03f37873880f7765f229b9e1f79d99df7adc",
|
||||||
|
"installed": {
|
||||||
|
"status": "installed",
|
||||||
|
"commit": "066707ece631f0a7c963031c211844fbdd68916b",
|
||||||
|
"release": "/var/www/investmoz-homologacao/releases/066707ece631f0a7c963031c211844fbdd68916b-6b7bb5bd",
|
||||||
|
"previous_release": "/var/www/investmoz-homologacao/releases/cf2ddf21a1457f4852fe6aa10069ec3b854f1567-7749f82e",
|
||||||
|
"database_migrations": 0,
|
||||||
|
"content_imports": 0
|
||||||
|
},
|
||||||
|
"deferred": [
|
||||||
|
"Statistics",
|
||||||
|
"AI"
|
||||||
|
],
|
||||||
|
"accepted_tests_repeated": false,
|
||||||
|
"public_projection": {
|
||||||
|
"available": 408,
|
||||||
|
"levels": {
|
||||||
|
"admin_post": 264,
|
||||||
|
"district": 133,
|
||||||
|
"province": 11
|
||||||
|
},
|
||||||
|
"failures": [],
|
||||||
|
"manifest_sha256": "06ab905fcf9b19115c3521bf81de03f37873880f7765f229b9e1f79d99df7adc"
|
||||||
|
},
|
||||||
|
"preservation": {
|
||||||
|
"tables": 174,
|
||||||
|
"changed_tables": {
|
||||||
|
"cache": {
|
||||||
|
"before": {
|
||||||
|
"rows": 104,
|
||||||
|
"checksum": "5d172b4d252c7b025f23ac70cf570cb6"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 104,
|
||||||
|
"checksum": "a60f3e47e1ae28937404f05f45e33135"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sessions": {
|
||||||
|
"before": {
|
||||||
|
"rows": 6,
|
||||||
|
"checksum": "dcdb7eba3f3e8f29f40ec3f7542be6ce"
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"rows": 7,
|
||||||
|
"checksum": "0059c0b0e16d532c6658fd420582f2e9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unchanged_tables": 172
|
||||||
|
},
|
||||||
|
"installed_file_sha256": {
|
||||||
|
"app/Services/ApprovedAdministrativeBoundaries.php": "401fd62795ca8f33106be6e07130d9207d6661695440bfc40f62f6f6b42bec64",
|
||||||
|
"app/Services/TerritoryGeometry.php": "00ce3e6dde92868b0d34b963b8e59a26e6663149cdc0398c645ef636ca382966",
|
||||||
|
"app/Http/Controllers/InvestmentTerritoryController.php": "3b184c6ea1b97f0abe86d01567d3d73444c49192c638478a6d53619e63d5d18d",
|
||||||
|
"app/Http/Middleware/EnsureScopedPortalAdministration.php": "1474db760f6bd6003a5325ae721698e90e2709a2354b51abde77f920a9dad81a",
|
||||||
|
"docs/investmoz/unification/approved-administrative-boundaries-20261024.json": "06ab905fcf9b19115c3521bf81de03f37873880f7765f229b9e1f79d99df7adc"
|
||||||
|
},
|
||||||
|
"pipeline_summaries": [
|
||||||
|
"OK (1 test, 3106 assertions)",
|
||||||
|
"built in 24.58s",
|
||||||
|
"OK (57 tests, 309 assertions)",
|
||||||
|
"# tests 216",
|
||||||
|
"# pass 216",
|
||||||
|
"# fail 0"
|
||||||
|
],
|
||||||
|
"proofs": {
|
||||||
|
"anonymous_http": {
|
||||||
|
"status": 200,
|
||||||
|
"territory_id": "dd219b89-cc17-5944-8c7d-d2766c82b526",
|
||||||
|
"selected": "DONDO",
|
||||||
|
"ancestor": "Sofala",
|
||||||
|
"areas": 2
|
||||||
|
},
|
||||||
|
"browser": {
|
||||||
|
"province_to_district": "passed",
|
||||||
|
"framing": "selected district with ancestor context",
|
||||||
|
"reload_preserves_selection": true,
|
||||||
|
"zoom": "passed",
|
||||||
|
"visible_tiles_loaded": 36,
|
||||||
|
"visible_tiles_failed": 0,
|
||||||
|
"screenshot": "outputs/map-stabilization-20261024/dondo-installed.png",
|
||||||
|
"screenshot_sha256": "7569f3b66aceb7ef9816c31bfaa172ebcdfa10e4911961b67a129a654b5cd349"
|
||||||
|
},
|
||||||
|
"business_rows_unchanged": true,
|
||||||
|
"active_synthetic_requests_created": 0
|
||||||
|
},
|
||||||
|
"status": "installed_delta_verified",
|
||||||
|
"remaining_in_scope": []
|
||||||
|
}
|
||||||
@@ -1,6 +1,20 @@
|
|||||||
# Rastreabilidade, utilização e formação
|
# Rastreabilidade, utilização e formação
|
||||||
|
|
||||||
## Projectos âncora — integração executável em QA, 23/10/2026
|
## Mapas — estabilização comum e divulgação delimitada, 24/10/2026
|
||||||
|
|
||||||
|
Diagnóstico por leitura autenticada na homologação `cf2ddf21`: **29 fichas, 28 relações territoriais e 408 geometrias válidas**, sem eliminação. Os 408 limites INE/2019 conservam classificação interna, propósito administrativo e SRID 4326. O fingerprint integral das linhas é `7d8b71d3e65d89ffdc43c748b0572dbc`. Não há RLS nas tabelas comparadas. O serviço comum não mudou desde `30aed7cd`: os consumidores gerais pediam exclusivamente geometrias públicas; o cadastro usava ainda `manage-portal`, ausente nos dois superutilizadores aprovados. A prova anterior demonstrava o cadastro privado, não a divulgação pública. O mapa base, tiles e assets carregam; a resposta territorial vazia explica a ausência de contornos e de enquadramento do território escolhido.
|
||||||
|
|
||||||
|
**Decisão expressa da Tempo nesta passagem:** «Sim, disponibilizar os contornos administrativos aceites». Implementada uma projecção pública de leitura dos [408 snapshots exactos](approved-administrative-boundaries-20261024.json), conferindo identidade e hashes da geometria original e metadados. Não há reimportação, reclassificação de linhas, publicação de parcelas, acesso aos ficheiros originais ou abertura de outras camadas internas. Alterações posteriores não recebem divulgação automática. Os perfis autorizados reutilizam o acesso privado já aprovado; a leitura administrativa conserva MFA. Respostas privadas não são guardadas em cache partilhada.
|
||||||
|
|
||||||
|
QA isolado `simulator_fiscal_delta_20261021_test:55441`: seis testes dirigidos, 64 asserções; selecção, gravação/recuperação no dossier e prefill do simulador com a mesma identidade, leitura pública autorizada, bloqueio de camadas não autorizadas e de snapshots alterados, permissões/MFA e fingerprint original preservado. PHPStan dos quatro ficheiros funcionais passou. Backup fresco: 174 tabelas, 369 ficheiros conferidos; restauro isolado sem rede reproduziu as 174 tabelas.
|
||||||
|
|
||||||
|
**Entregue na homologação em `066707ece631f0a7c963031c211844fbdd68916b`**, por avanço normal do Git, preservando `cf2ddf21` e as alterações concorrentes. Instalador: contrato 1/3106, PHP 57/309, frontend 216/216 e build aprovados; zero migrações e zero importações. Os cinco ficheiros funcionais instalados coincidem com o Git. Consulta pública pelo serviço instalado: **408/408 disponíveis**, 11 províncias, 133 distritos e 264 postos, zero falhas. HTTP anónimo recupera Dondo e Sofala pela identidade canónica, com Dondo seleccionado e Sofala como contexto ancestral. Conferência visual: mudança de província para distrito actualiza o contorno e enquadramento; escolha preservada após recarregar, zoom operacional e 36 tiles carregados sem falha na observação final. Houve falhas transitórias de tiles na janela anterior; os mesmos URLs responderam 200 e o recarregamento recuperou a base, sem alteração de configuração ou fornecedor.
|
||||||
|
|
||||||
|
Comparação das 174 tabelas: **172 iguais por contagem/hash**, diferenças apenas em `cache` e `sessions`; tabelas de negócio, geometrias, permissões e fontes intactas. Conservados 29 fichas, 28 relações e o fingerprint integral das 408 geometrias. Nenhum dossier/pedido sintético criado na homologação. [Recibo da estabilização](map-stabilization-receipt-20261024.json); prova visual em `outputs/map-stabilization-20261024/dondo-installed.png`. O saldo técnico desta reposição está encerrado; a avaliação de navegação e apresentação pela Tempo permanece o próximo trabalho.
|
||||||
|
|
||||||
|
Preservados os fechos `d8224ba8`, `55136b44`, `8036b9b0` e `cf2ddf21`/`c1f4a719`, sem repetição das provas aceites. Localidades sem polígono próprio conservam apenas o contexto ancestral explicitamente identificado; não são inventadas coordenadas ou parcelas. Estatísticas e IA permanecem adiadas. Esta estabilização não declara concluída a aplicação transversal nem substitui a avaliação de navegação e apresentação pela Tempo.
|
||||||
|
|
||||||
|
## Projectos âncora — entregues na homologação em cf2ddf21, 23/10/2026
|
||||||
|
|
||||||
Reconciliado o saldo de `6985f82e` com as provas territoriais de 7 de Outubro e os recibos de reposição. A leitura autenticada da homologação, com o papel da aplicação e transacção apenas de leitura, confirmou **29 fichas publicadas, 13 relações de clusters e zero ligações em `project_locations`**. As cinco tabelas comparadas não usam RLS. Os projectos transportados têm identificadores diferentes dos originais e perderam as 28 ligações territoriais e os respectivos metadados de citação; não desapareceram as 29 fichas. A reposição de visibilidade anterior não abrangia estas relações. A comparação delimita a omissão no transporte; não identifica por si só o instante em que ocorreu.
|
Reconciliado o saldo de `6985f82e` com as provas territoriais de 7 de Outubro e os recibos de reposição. A leitura autenticada da homologação, com o papel da aplicação e transacção apenas de leitura, confirmou **29 fichas publicadas, 13 relações de clusters e zero ligações em `project_locations`**. As cinco tabelas comparadas não usam RLS. Os projectos transportados têm identificadores diferentes dos originais e perderam as 28 ligações territoriais e os respectivos metadados de citação; não desapareceram as 29 fichas. A reposição de visibilidade anterior não abrangia estas relações. A comparação delimita a omissão no transporte; não identifica por si só o instante em que ocorreu.
|
||||||
|
|
||||||
@@ -10,7 +24,11 @@ Incrementos: pesquisa explícita pelo sector documental em conjunto com a locali
|
|||||||
|
|
||||||
Provas dirigidas: `InvestmentAnchorIntegrationTest` (4 casos, 116 asserções) e `anchor-integration.test.mjs` (2 casos); ver [recibo de QA e reconciliação](anchor-integration-receipt-20261023.json). Mantidos os percursos já aceites de carteira → oportunidade associada → dossier/simulador, complementos `d8224ba8`, consumidores `55136b44` e tratamento `8036b9b0`/recibo `cdf8fcfb`. Nenhuma nova impressão de PDF, prova Word/ZIP ou ronda dos fechos aceites. Estatísticas e IA permanecem adiadas.
|
Provas dirigidas: `InvestmentAnchorIntegrationTest` (4 casos, 116 asserções) e `anchor-integration.test.mjs` (2 casos); ver [recibo de QA e reconciliação](anchor-integration-receipt-20261023.json). Mantidos os percursos já aceites de carteira → oportunidade associada → dossier/simulador, complementos `d8224ba8`, consumidores `55136b44` e tratamento `8036b9b0`/recibo `cdf8fcfb`. Nenhuma nova impressão de PDF, prova Word/ZIP ou ronda dos fechos aceites. Estatísticas e IA permanecem adiadas.
|
||||||
|
|
||||||
Estado desta passagem: código e reposição demonstrados em QA; **a entrega na homologação e a aplicação das 28 relações no destino ainda não estão declaradas concluídas**. O saldo deste recorte é finito: instalar o incremento pelo Git, aplicar a reposição exacta após backup/restauro autenticado e conferir apenas esse delta. O backup já preparado do destino restaurou 174 tabelas iguais numa base isolada sem rede e verificou 369 ficheiros. A avaliação final de navegação e apresentação pela Tempo continua distinta deste fecho técnico.
|
**Entregue e delta conferido** na revisão `cf2ddf21a1457f4852fe6aa10069ec3b854f1567`, após integração `3fd5128c` e correcção delimitada da verificação de finais de linha do manifesto entre Windows e Git. A primeira prévia recusou o hash divergente antes de qualquer escrita; a prévia canónica passou. A reposição autenticada recuperou **28 relações em 13 projectos**, com 13 eventos de auditoria, zero novas fichas e zero alterações de publicação. As **29 identidades aprovadas, conteúdos e fontes** permanecem exactamente iguais; preservadas as 13 relações de clusters e os corredores. A comparação das 174 tabelas encontrou 169 iguais por contagem/hash; as diferenças de domínio limitam-se a projectos/metadados, relações territoriais e auditoria; cache e sessões tiveram alterações técnicas. O backup restaurou 174 tabelas iguais numa base isolada sem rede e verificou 369 ficheiros.
|
||||||
|
|
||||||
|
Os 15 ficheiros funcionais instalados coincidem com o Git. Instalador: zero migrações e zero importações automáticas; controlos habituais aprovados (contrato 1/3106, PHP 57/309 e frontend 216/216). Conferência pública apenas do delta: pesquisa A06 por sector documental e Sofala encontra a ficha original; quatro localizações e respectivas fontes recuperadas; retorno conserva filtros; a entrada para preparar ideia usa `portfolio:<id>` e a província escolhida. Nenhum dossier, pedido ou manifestação de ensaio foi criado na homologação. Os ensaios sintéticos continuam exclusivamente em QA.
|
||||||
|
|
||||||
|
**Saldo técnico deste recorte: sem pendências de código, reposição ou disponibilização identificadas.** Segue a avaliação final de navegação e apresentação pela Tempo. Este fecho não declara implementadas funcionalidades futuras nem a conclusão integral da aplicação transversal; Estatísticas e IA continuam adiadas. O inventário e as provas anteriores permanecem preservados, sem nova ronda dos casos aceites.
|
||||||
|
|
||||||
## Oportunidade em tratamento — entregue na homologação em 8036b9b0, 23/10/2026
|
## Oportunidade em tratamento — entregue na homologação em 8036b9b0, 23/10/2026
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\ApprovedAdministrativeBoundaries;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
final class TerritoryGeometryConsumerAccessTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
private User $actor;
|
||||||
|
|
||||||
|
private string $territory;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$identity = DB::selectOne('select current_database() as name,inet_server_port() as port');
|
||||||
|
$this->assertSame('simulator_fiscal_delta_20261021_test', $identity->name);
|
||||||
|
$this->assertSame(55441, (int) $identity->port);
|
||||||
|
$this->withoutVite();
|
||||||
|
$this->withoutMiddleware(ThrottleRequests::class);
|
||||||
|
config(['portal.profile_access_enabled' => true, 'portal.managers' => [], 'investor-path.enabled' => true, 'suitecrm.enabled' => false, 'investmoz_ai.enabled' => false]);
|
||||||
|
$this->actor = User::factory()->create(['two_factor_secret' => Crypt::encryptString('JBSWY3DPEHPK3PXP'), 'two_factor_confirmed_at' => now()]);
|
||||||
|
$other = User::factory()->create();
|
||||||
|
DB::table('portal_superuser_pair')->updateOrInsert(['id' => 1], ['first_user_id' => $this->actor->id, 'second_user_id' => $other->id, 'approved_by' => $other->id]);
|
||||||
|
$this->territory = DB::table('geo_geometries as g')->join('geo_locations as l', 'l.id', '=', 'g.geo_location_id')
|
||||||
|
->where('g.source_system', 'ine-cod-ab')->where('g.data_classification', 'internal')->where('l.location_type', 'province')->value('l.id');
|
||||||
|
$this->assertNotEmpty($this->territory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_general_consumer_uses_existing_authenticated_read_access_without_the_legacy_gate(): void
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->actor->can('manage-portal'));
|
||||||
|
$before = $this->fingerprint();
|
||||||
|
$this->actingAs($this->actor)->getJson('/api/v1/investment/territory-geometries?territory_id='.$this->territory)
|
||||||
|
->assertOk()->assertJsonPath('selected_geometry_available', true)->assertJsonPath('geometry_scope', 'authorized_internal')
|
||||||
|
->assertJsonPath('areas.0.territory_id', $this->territory)->assertHeader('Cache-Control', 'no-store, private');
|
||||||
|
$this->assertSame($before, $this->fingerprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_existing_administration_reaches_the_same_geometry_with_its_completed_mfa_session(): void
|
||||||
|
{
|
||||||
|
$this->actingAs($this->actor)->withSession(['portal.mfa_actor' => $this->actor->id, 'portal.mfa_at' => time(), 'portal.access_revision' => (int) $this->actor->portal_access_revision]);
|
||||||
|
$this->getJson('/management/territory-geometries?territory_id='.$this->territory)->assertOk()->assertJsonPath('selected_geometry_available', true);
|
||||||
|
session()->forget(['portal.mfa_actor', 'portal.mfa_at']);
|
||||||
|
$this->getJson('/management/territory-geometries?territory_id='.$this->territory)->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_anonymous_and_ordinary_accounts_do_not_receive_or_publish_internal_layers(): void
|
||||||
|
{
|
||||||
|
$before = $this->fingerprint();
|
||||||
|
$url = '/api/v1/investment/territory-geometries?territory_id='.$this->territory;
|
||||||
|
$this->getJson($url)->assertOk()->assertJsonPath('geometry_scope', 'public')->assertJsonPath('selected_geometry_available', false)->assertJsonCount(0, 'areas');
|
||||||
|
$this->actingAs(User::factory()->create())->getJson($url)->assertOk()->assertJsonPath('geometry_scope', 'public')->assertJsonCount(0, 'areas');
|
||||||
|
$this->getJson('/management/territory-geometries?territory_id='.$this->territory)->assertForbidden();
|
||||||
|
$this->assertSame($before, $this->fingerprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_saved_territory_is_recovered_in_dossier_and_simulator_and_the_map_uses_that_identity(): void
|
||||||
|
{
|
||||||
|
$this->actingAs($this->actor);
|
||||||
|
$id = $this->postJson('/investimentos', ['title' => 'SYNTHETIC QA - mapa recuperado', 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
|
||||||
|
$body = ['version' => $this->getJson('/investimentos/'.$id.'/contexto')->json('case.version'), 'selection' => ['territory' => 'territory:'.$this->territory]];
|
||||||
|
$preview = $this->postJson('/investimentos/'.$id.'/contexto/previa', $body)->assertOk()->json();
|
||||||
|
$this->postJson('/investimentos/'.$id.'/contexto/confirmar', [...$body, 'preview_hash' => $preview['preview_hash'], 'operation_key' => (string) Str::uuid(), 'confirm' => true])->assertOk();
|
||||||
|
$view = $this->getJson('/investimentos/'.$id.'/contexto')->assertOk()->json();
|
||||||
|
$this->assertSame($this->territory, $view['context']['selection']['territory']['id']);
|
||||||
|
$this->assertSame($this->territory, $view['prefill']['simulator']['province_id']);
|
||||||
|
$this->getJson('/api/v1/investment/territory-geometries?territory_id='.$view['prefill']['simulator']['province_id'])
|
||||||
|
->assertOk()->assertJsonPath('selected_geometry_available', true)->assertJsonPath('areas.0.selected_territory', true);
|
||||||
|
$this->assertSame($this->territory, $this->getJson('/investimentos/'.$id.'/contexto')->json('context.selection.territory.id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_only_the_approved_unchanged_snapshot_is_public_without_reclassifying_the_original(): void
|
||||||
|
{
|
||||||
|
$before = $this->fingerprint();
|
||||||
|
$row = DB::table('geo_geometries as g')->where('geo_location_id', $this->territory)->first([
|
||||||
|
'g.id', 'g.geo_location_id', DB::raw("encode(sha256(ST_AsEWKB(g.geom)),'hex') as geometry_sha256"),
|
||||||
|
DB::raw("encode(sha256(convert_to(g.properties::text,'UTF8')),'hex') as properties_sha256"),
|
||||||
|
]);
|
||||||
|
// The QA import has its own identities; never copy or replace production rows.
|
||||||
|
$approved = $this->partialMock(ApprovedAdministrativeBoundaries::class);
|
||||||
|
$approved->shouldReceive('snapshots')->andReturn([$row->id => [
|
||||||
|
'territory_id' => $row->geo_location_id, 'geometry_sha256' => $row->geometry_sha256,
|
||||||
|
'properties_sha256' => $row->properties_sha256,
|
||||||
|
]]);
|
||||||
|
$url = '/api/v1/investment/territory-geometries?territory_id='.$this->territory;
|
||||||
|
$this->getJson($url)->assertOk()->assertJsonPath('selected_geometry_available', true)
|
||||||
|
->assertJsonPath('areas.0.data_classification', 'public')->assertJsonPath('investment_site', false);
|
||||||
|
$this->actingAs(User::factory()->create())->getJson($url)->assertOk()->assertJsonPath('selected_geometry_available', true);
|
||||||
|
$this->assertSame($before, $this->fingerprint());
|
||||||
|
$this->assertSame('internal', DB::table('geo_geometries')->where('id', $row->id)->value('data_classification'));
|
||||||
|
DB::table('geo_geometries')->where('id', $row->id)->update(['properties' => DB::raw("properties || '{\"qa_changed\":true}'::jsonb")]);
|
||||||
|
$this->getJson($url)->assertOk()->assertJsonPath('selected_geometry_available', false)->assertJsonCount(0, 'areas');
|
||||||
|
$this->actingAs($this->actor)->getJson($url)->assertOk()->assertJsonPath('selected_geometry_available', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_public_manifest_has_the_exact_approved_scope_and_immutable_hash(): void
|
||||||
|
{
|
||||||
|
$items = app(ApprovedAdministrativeBoundaries::class)->snapshots();
|
||||||
|
$this->assertCount(408, $items);
|
||||||
|
$this->assertCount(408, array_unique(array_column($items, 'territory_id')));
|
||||||
|
$this->assertSame(['2019-06-07'], array_values(array_unique(array_column($items, 'source_version'))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fingerprint(): string
|
||||||
|
{
|
||||||
|
return DB::selectOne("select md5(string_agg(row_to_json(g)::text,E'\\n' order by id)) as hash from geo_geometries g")->hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user