diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/delivery/controller/DeliveryController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/delivery/controller/DeliveryController.java index 04feaed0..fc4ffbd2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/delivery/controller/DeliveryController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/delivery/controller/DeliveryController.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.puris.backend.delivery.controller; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -48,6 +49,7 @@ import org.springframework.web.server.ResponseStatusException; import javax.management.openmbean.KeyAlreadyExistsException; +import java.util.Base64; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -92,7 +94,8 @@ public class DeliveryController { @ResponseBody @Operation(summary = "Get all planned deliveries for the given Material", description = "Get all planned deliveries for the given material number. Optionally a bpns and partner bpnl can be provided to filter the deliveries further.") - public List getAllDeliveries(String ownMaterialNumber, Optional bpns, Optional bpnl) { + public List getAllDeliveries(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional bpns, Optional bpnl) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); Material material = materialService.findByOwnMaterialNumber(ownMaterialNumber); if (material == null) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Material does not exist."); @@ -179,7 +182,9 @@ public void deleteDelivery(@PathVariable UUID id) { summary = "Refreshes all reported deliveries", description = "Refreshes all reported deliveries from the delivery request API." ) - public ResponseEntity> refreshReportedDeliveries(@RequestParam String ownMaterialNumber) { + public ResponseEntity> refreshReportedDeliveries( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java index 6b19339e..e36363bc 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java @@ -20,6 +20,7 @@ See the NOTICE file(s) distributed with this work for additional package org.eclipse.tractusx.puris.backend.demand.controller; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -46,6 +47,7 @@ See the NOTICE file(s) distributed with this work for additional import org.springframework.web.server.ResponseStatusException; import javax.management.openmbean.KeyAlreadyExistsException; +import java.util.Base64; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -88,7 +90,8 @@ public class DemandController { @GetMapping() @ResponseBody @Operation(summary = "Get all own demands for the given Material", description = "Get all own demands for the given material number. Optionally the demanding site can be filtered by its bpns.") - public List getAllDemands(String ownMaterialNumber, Optional site) { + public List getAllDemands(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional site) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); return ownDemandService.findAllByFilters(Optional.of(ownMaterialNumber), Optional.empty(), site, Optional.empty()) .stream().map(this::convertToDto).collect(Collectors.toList()); } @@ -167,8 +170,11 @@ public void deleteDemand(@PathVariable UUID id) { summary = "Get all demands of partners for a material", description = "Get all demands of partners for a material number. Optionally the partners can be filtered by their bpnl and the demanding site can be filtered by its bpns." ) - public List getAllDemandsForPartner(String ownMaterialNumber, Optional bpnl, + public List getAllDemandsForPartner(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional bpnl, Optional site) { + if (ownMaterialNumber != null) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } return reportedDemandService.findAllByFilters(Optional.of(ownMaterialNumber), bpnl, site, Optional.empty()) .stream().map(this::convertToDto).collect(Collectors.toList()); } @@ -179,7 +185,9 @@ public List getAllDemandsForPartner(String ownMaterialNumber, Optiona summary = "Refreshes all reported demands", description = "Refreshes all reported demands from the demand request API." ) - public ResponseEntity> refreshReportedProductions(@RequestParam String ownMaterialNumber) { + public ResponseEntity> refreshReportedProductions( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/controller/ErpAdapterController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/controller/ErpAdapterController.java index 595e4cf6..d0ae9159 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/controller/ErpAdapterController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/controller/ErpAdapterController.java @@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Arrays; +import java.util.Base64; import java.util.Date; import java.util.UUID; @@ -71,10 +72,12 @@ public class ErpAdapterController { @PostMapping("/trigger") public ResponseEntity scheduleErpUpdate( @RequestParam("partner-bpnl") String bpnl, - @RequestParam("own-materialnumber") String materialNumber, + @RequestParam("own-materialnumber") + @Parameter(description = "encoded in base64") String materialNumber, @RequestParam("asset-type") AssetType assetType, @RequestParam(required = false, value = "direction") DirectionCharacteristic directionCharacteristic ) { + materialNumber = new String(Base64.getDecoder().decode(materialNumber)); boolean valid = BPNL_PATTERN.matcher(bpnl).matches() && NON_EMPTY_NON_VERTICAL_WHITESPACE_PATTERN.matcher(materialNumber).matches(); if (valid && mprService.find(bpnl, materialNumber) != null) { diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java index 938aa966..1027a73d 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java @@ -38,6 +38,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.Base64; import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -135,8 +136,9 @@ public ResponseEntity updateMaterial(@RequestBody MaterialEntityDto materialD @ApiResponse(responseCode = "404", description = "Requested Material was not found.", content = @Content) }) public ResponseEntity getMaterial(@Parameter(name = "ownMaterialNumber", - description = "The Material Number that is used in your own company to identify the Material.", - example = "MNR-7307-AU340474.002") @RequestParam String ownMaterialNumber) { + description = "The Material Number that is used in your own company to identify the Material, encoded in base64" + ) @RequestParam String ownMaterialNumber) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); if(!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java index a6ea206d..8031d9bb 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java @@ -38,6 +38,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.Base64; import java.util.regex.Pattern; @RestController @@ -70,12 +71,12 @@ public class MaterialPartnerRelationsController { @ApiResponse(responseCode = "500", description = "Internal Server Error.") }) public ResponseEntity createMaterialPartnerRelation( - @Parameter(description = "The Material Number that is used in your own company to identify the Material.", - example = "MNR-7307-AU340474.002") @RequestParam String ownMaterialNumber, + @Parameter(description = "The Material Number that is used in your own company to identify the Material, "+ + "encoded in base64") @RequestParam String ownMaterialNumber, @Parameter(description = "The unique BPNL that was assigned to that Partner.", example = "BPNL2222222222RR") @RequestParam() String partnerBpnl, - @Parameter(description = "The Material Number that this Partner is using in his own company to identify the Material.", - example = "MNR-8101-ID146955.001") @RequestParam String partnerMaterialNumber, + @Parameter(description = "The Material Number that this Partner is using in his own company to identify the Material, " + + "encoded in base64") @RequestParam String partnerMaterialNumber, @Parameter(description = "The CatenaX Number that this Partner uses", example = "860fb504-b884-4009-9313-c6fb6cdc776b") @RequestParam(required = false) String partnerCXNumber, @Parameter(description = "The informal name that this Partner uses", @@ -85,6 +86,8 @@ public ResponseEntity createMaterialPartnerRelation( @Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.", example = "true") @RequestParam boolean partnerBuys) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber)); if (!materialPattern.matcher(ownMaterialNumber).matches() || !materialPattern.matcher(partnerMaterialNumber).matches() || !bpnlPattern.matcher(partnerBpnl).matches()) { log.warn("Rejected message parameters. "); @@ -129,12 +132,12 @@ public ResponseEntity createMaterialPartnerRelation( @ApiResponse(responseCode = "500", description = "Internal Server Error.") }) public ResponseEntity updateMaterialPartnerRelation( - @Parameter(description = "The Material Number that is used in your own company to identify the Material.", - example = "MNR-7307-AU340474.002") @RequestParam String ownMaterialNumber, + @Parameter(description = "The Material Number that is used in your own company to identify the Material, " + + "encoded in base64") @RequestParam String ownMaterialNumber, @Parameter(description = "The unique BPNL that was assigned to that Partner.", example = "BPNL2222222222RR") @RequestParam() String partnerBpnl, - @Parameter(description = "The Material Number that this Partner is using in his own company to identify the Material.", - example = "MNR-8101-ID146955.001") @RequestParam(required = false) String partnerMaterialNumber, + @Parameter(description = "The Material Number that this Partner is using in his own company to identify the Material, " + + "encoded in base64") @RequestParam(required = false) String partnerMaterialNumber, @Parameter(description = "The CatenaX Number that this Partner uses", example = "860fb504-b884-4009-9313-c6fb6cdc776b") @RequestParam(required = false) String partnerCXNumber, @Parameter(description = "The informal name that this Partner uses", @@ -143,6 +146,7 @@ public ResponseEntity updateMaterialPartnerRelation( example = "true") @RequestParam(required = false) Boolean partnerSupplies, @Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.", example = "true") @RequestParam(required = false) Boolean partnerBuys) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); MaterialPartnerRelation existingRelation = null; if (!bpnlPattern.matcher(partnerBpnl).matches() || !materialPattern.matcher(ownMaterialNumber).matches() || diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/production/controller/ProductionController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/production/controller/ProductionController.java index 774ff1ea..f83af740 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/production/controller/ProductionController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/production/controller/ProductionController.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.puris.backend.production.controller; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -47,6 +48,7 @@ import org.springframework.web.server.ResponseStatusException; import javax.management.openmbean.KeyAlreadyExistsException; +import java.util.Base64; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -89,7 +91,10 @@ public class ProductionController { @GetMapping() @ResponseBody @Operation(summary = "Get all planned productions for the given Material", description = "Get all planned productions for the given material number. Optionally the production site can be filtered by its bpns.") - public List getAllProductions(String ownMaterialNumber, Optional site) { + public List getAllProductions(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional site) { + if (ownMaterialNumber != null) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } return ownProductionService.findAllByFilters(Optional.of(ownMaterialNumber), Optional.empty(), site, Optional.empty()) .stream().map(this::convertToDto).collect(Collectors.toList()); } @@ -204,8 +209,11 @@ public void deleteProduction(@PathVariable UUID id) { summary = "Get all productions of partners for a material", description = "Get all productions of partners for a material number. Optionally the partners can be filtered by their bpnl and the production site can be filtered by its bpns." ) - public List getAllProductionsForPartner(String ownMaterialNumber, Optional bpnl, + public List getAllProductionsForPartner(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional bpnl, Optional site) { + if (ownMaterialNumber != null) { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } return reportedProductionService.findAllByFilters(Optional.of(ownMaterialNumber), bpnl, site, Optional.empty()) .stream().map(this::convertToDto).collect(Collectors.toList()); } @@ -216,7 +224,8 @@ public List getAllProductionsForPartner(String ownMaterialNumber, summary = "Refreshes all reported productions", description = "Refreshes all reported productions from the production request API." ) - public ResponseEntity> refreshReportedProductions(@RequestParam String ownMaterialNumber) { + public ResponseEntity> refreshReportedProductions( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java index c2145a25..cdfb2eba 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -50,10 +51,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -121,7 +119,13 @@ public List getMaterials() { " \"BPNL1234567890ZZ\": \"MNR-8101-ID146955.001\"," + " \"BPNL4444444444XX\": \"MNR-7307-AU340474.002\"}")})), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content)}) - public ResponseEntity> getMaterialNumbers(@RequestParam String ownMaterialNumber) { + public ResponseEntity> getMaterialNumbers( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyMap()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -433,7 +437,13 @@ private MaterialItemStock convertToEntity(MaterialStockDto dto) { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> getSupplierMaterialStocks(@RequestParam String ownMaterialNumber) { + public ResponseEntity> getSupplierMaterialStocks( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -469,7 +479,13 @@ private ReportedMaterialStockDto convertToDto(ReportedMaterialItemStock entity) @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> getCustomerProductStocks(@RequestParam String ownMaterialNumber) { + public ResponseEntity> getCustomerProductStocks( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -504,7 +520,13 @@ private ReportedProductStockDto convertToDto(ReportedProductItemStock entity) { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> getCustomerPartnersOrderingMaterial(@RequestParam String ownMaterialNumber) { + public ResponseEntity> getCustomerPartnersOrderingMaterial( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -519,7 +541,13 @@ public ResponseEntity> getCustomerPartnersOrderingMaterial(@Req @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> getSupplierPartnersSupplyingMaterial(@RequestParam String ownMaterialNumber) { + public ResponseEntity> getSupplierPartnersSupplyingMaterial( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -538,7 +566,13 @@ public ResponseEntity> getSupplierPartnersSupplyingMaterial(@Re @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> triggerReportedMaterialStockUpdateForMaterialNumber(@RequestParam String ownMaterialNumber) { + public ResponseEntity> triggerReportedMaterialStockUpdateForMaterialNumber( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } @@ -567,7 +601,13 @@ public ResponseEntity> triggerReportedMaterialStockUpdateForMat @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content) }) - public ResponseEntity> triggerReportedProductStockUpdateForMaterialNumber(@RequestParam String ownMaterialNumber) { + public ResponseEntity> triggerReportedProductStockUpdateForMaterialNumber( + @RequestParam @Parameter(description = "encoded in base64") String ownMaterialNumber) { + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + } catch (IllegalArgumentException e) { + return ResponseEntity.badRequest().body(Collections.emptyList()); + } if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/SupplyController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/SupplyController.java index 3a102e76..33ef35f1 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/SupplyController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/SupplyController.java @@ -20,20 +20,21 @@ package org.eclipse.tractusx.puris.backend.supply.controller; -import java.util.List; - +import io.swagger.v3.oas.annotations.Operation; import org.eclipse.tractusx.puris.backend.supply.domain.model.Supply; import org.eclipse.tractusx.puris.backend.supply.logic.dto.SupplyDto; import org.eclipse.tractusx.puris.backend.supply.logic.service.CustomerSupplyService; import org.eclipse.tractusx.puris.backend.supply.logic.service.SupplierSupplyService; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.List; @RestController @RequestMapping("days-of-supply") @@ -49,32 +50,40 @@ public class SupplyController { @GetMapping("customer") @ResponseBody @Operation(summary = "Calculate days of supply for customer for given number of days.", - description = "Calculate days of supply for customer for given number of days. Filtered by given material number, partner bpnl and site bpns.") + description = "Calculate days of supply for customer for given number of days. Filtered by given material number, partner bpnl and site bpns. " + + "materialNumber is expected to be base64 encoded") public List calculateCustomerDaysOfSupply(String materialNumber, String bpnl, String siteBpns, int numberOfDays) { + materialNumber = new String(Base64.getDecoder().decode(materialNumber.getBytes(StandardCharsets.UTF_8))); return customerSupplyService.calculateCustomerDaysOfSupply(materialNumber, bpnl, siteBpns, numberOfDays) .stream().map(this::convertToDto).toList(); } @GetMapping("customer/reported") @Operation(summary = "Get days of supply for customer.", - description = "Get days of supply for customer for given material number and partner bpnl.") + description = "Get days of supply for customer for given material number and partner bpnl. " + + "materialNumber is expected to be base64 encoded") public List getCustomerDaysOfSupply(String materialNumber, String bpnl) { + materialNumber = new String(Base64.getDecoder().decode(materialNumber.getBytes(StandardCharsets.UTF_8))); return customerSupplyService.findByPartnerBpnlAndOwnMaterialNumber(materialNumber, bpnl) .stream().map(this::convertToDto).toList(); } @GetMapping("supplier") @Operation(summary = "Calculate days of supply for supplier for given number of days.", - description = "Calculate days of supply for supplier for given number of days. Filtered by given material number, partner bpnl and site bpns.") + description = "Calculate days of supply for supplier for given number of days. Filtered by given material number, partner bpnl and site bpns. "+ + "materialNumber is expected to be base64 encoded") public List calculateSupplierDaysOfSupply(String materialNumber, String bpnl, String siteBpns, int numberOfDays) { + materialNumber = new String(Base64.getDecoder().decode(materialNumber.getBytes(StandardCharsets.UTF_8))); return supplierSupplyService.calculateSupplierDaysOfSupply(materialNumber, bpnl, siteBpns, numberOfDays) .stream().map(this::convertToDto).toList(); } @GetMapping("supplier/reported") @Operation(summary = "Get days of supply for supplier.", - description = "Get days of supply for supplier for given material number and partner bpnl.") + description = "Get days of supply for supplier for given material number and partner bpnl. " + + "materialNumber is expected to be base64 encoded") public List getSupplierDaysOfSupply(String materialNumber, String bpnl) { + materialNumber = new String(Base64.getDecoder().decode(materialNumber.getBytes(StandardCharsets.UTF_8))); return supplierSupplyService.findByPartnerBpnlAndOwnMaterialNumber(materialNumber, bpnl) .stream().map(this::convertToDto).toList(); } diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialControllerTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialControllerTest.java index dffae954..425fde22 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialControllerTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialControllerTest.java @@ -39,6 +39,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import java.util.Arrays; +import java.util.Base64; import java.util.List; import java.util.UUID; @@ -103,7 +104,7 @@ void getMaterialTest() throws Exception { // then mockMvc.perform(get("/materials") - .param("ownMaterialNumber", materialNumber)) + .param("ownMaterialNumber", new String(Base64.getEncoder().encode(materialNumber.getBytes())))) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.ownMaterialNumber").value(materialNumber)); diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsControllerTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsControllerTest.java index 22b70b83..6d9cafed 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsControllerTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsControllerTest.java @@ -39,6 +39,7 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import java.util.Base64; import java.util.UUID; import static org.mockito.ArgumentMatchers.any; @@ -84,6 +85,7 @@ public class MaterialPartnerRelationsControllerTest { public void createMaterialPartnerRelationTest() throws Exception { // given String partnerMaterialNumber = "MNR-8101-ID146955.001"; + System.out.println(partnerMaterialNumber + " -> " + new String(Base64.getEncoder().encode(partnerMaterialNumber.getBytes()))); MaterialPartnerRelation newMpr = new MaterialPartnerRelation(material, partner, partnerMaterialNumber, true, true); @@ -96,9 +98,9 @@ public void createMaterialPartnerRelationTest() throws Exception { // then mockMvc.perform(post("/materialpartnerrelations") - .param("ownMaterialNumber", materialNumber) + .param("ownMaterialNumber", new String(Base64.getEncoder().encode(materialNumber.getBytes()))) .param("partnerBpnl", bpnl) - .param("partnerMaterialNumber", partnerMaterialNumber) + .param("partnerMaterialNumber", new String(Base64.getEncoder().encode(partnerMaterialNumber.getBytes()))) .param("partnerSupplies", "true") .param("partnerBuys", "true")) .andExpect(status().isOk()); @@ -131,9 +133,9 @@ public void createMaterialPartnerRelationTestPatternMatchShouldFail() throws Exc // then mockMvc.perform(post("/materialpartnerrelations") - .param("ownMaterialNumber", materialNumber) + .param("ownMaterialNumber", new String(Base64.getEncoder().encode(materialNumber.getBytes()))) .param("partnerBpnl", bpnlWrong) - .param("partnerMaterialNumber", partnerMaterialNumber) + .param("partnerMaterialNumber", new String(Base64.getEncoder().encode(partnerMaterialNumber.getBytes()))) .param("partnerSupplies", "true") .param("partnerBuys", "true")) .andExpect(status().is4xxClientError()); @@ -160,9 +162,9 @@ public void updateMaterialPartnerRelationTest() throws Exception { // then mockMvc.perform(put("/materialpartnerrelations") - .param("ownMaterialNumber", materialNumber) + .param("ownMaterialNumber", new String(Base64.getEncoder().encode(materialNumber.getBytes()))) .param("partnerBpnl", bpnl) - .param("partnerMaterialNumber", partnerMaterialNumber2) + .param("partnerMaterialNumber", new String(Base64.getEncoder().encode(partnerMaterialNumber2.getBytes()))) .param("partnerSupplies", "true") .param("partnerBuys", "true") .contentType(MediaType.APPLICATION_JSON)) @@ -200,9 +202,9 @@ public void updateMaterialPartnerRelationTestWrongPatternShouldFail() throws Exc // then mockMvc.perform(put("/materialpartnerrelations") - .param("ownMaterialNumber", materialNumber) + .param("ownMaterialNumber", new String(Base64.getEncoder().encode(materialNumber.getBytes()))) .param("partnerBpnl", bpnlWrong) - .param("partnerMaterialNumber", partnerMaterialNumber2) + .param("partnerMaterialNumber", new String(Base64.getEncoder().encode(partnerMaterialNumber.getBytes()))) .param("partnerSupplies", "true") .param("partnerBuys", "true") .contentType(MediaType.APPLICATION_JSON)) diff --git a/frontend/src/features/dashboard/hooks/useDelivery.ts b/frontend/src/features/dashboard/hooks/useDelivery.ts index b73a7701..ed310b4f 100644 --- a/frontend/src/features/dashboard/hooks/useDelivery.ts +++ b/frontend/src/features/dashboard/hooks/useDelivery.ts @@ -24,6 +24,9 @@ import { Delivery } from '@models/types/data/delivery'; import { BPNS } from '@models/types/edc/bpn'; export const useDelivery = (materialNumber: string | null, site: BPNS | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const { data: deliveries, error: deliveriesError, diff --git a/frontend/src/features/dashboard/hooks/useDemand.ts b/frontend/src/features/dashboard/hooks/useDemand.ts index 8f0a7994..ee45d3f2 100644 --- a/frontend/src/features/dashboard/hooks/useDemand.ts +++ b/frontend/src/features/dashboard/hooks/useDemand.ts @@ -24,6 +24,9 @@ import { Demand } from '@models/types/data/demand'; import { BPNS } from '@models/types/edc/bpn'; export const useDemand = (materialNumber: string | null, site: BPNS | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const {data: demands, error: demandsError, isLoading: isLoadingDemands, refresh: refreshDemand } = useFetch(materialNumber && site ? `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_DEMAND}?ownMaterialNumber=${materialNumber}&site=${site}` : undefined); return { demands, diff --git a/frontend/src/features/dashboard/hooks/useProduction.ts b/frontend/src/features/dashboard/hooks/useProduction.ts index 626813c2..f8c2130f 100644 --- a/frontend/src/features/dashboard/hooks/useProduction.ts +++ b/frontend/src/features/dashboard/hooks/useProduction.ts @@ -23,6 +23,9 @@ import { Production } from '@models/types/data/production'; import { BPNS } from '@models/types/edc/bpn'; export const useProduction = (materialNumber: string | null, site: BPNS | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const {data: productions, error: productionsError, isLoading: isLoadingProductions, refresh: refreshProduction } = useFetch(materialNumber && site ? `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_PRODUCTION}?ownMaterialNumber=${materialNumber}&site=${site}` : undefined); return { productions, diff --git a/frontend/src/features/dashboard/hooks/useReportedDemand.ts b/frontend/src/features/dashboard/hooks/useReportedDemand.ts index 7f772c85..5e8b98fe 100644 --- a/frontend/src/features/dashboard/hooks/useReportedDemand.ts +++ b/frontend/src/features/dashboard/hooks/useReportedDemand.ts @@ -23,6 +23,9 @@ import { config } from '@models/constants/config'; import { Demand } from '@models/types/data/demand'; export const useReportedDemand = (materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const {data: reportedDemands, error: reportedDemandsError, isLoading: isLoadingReportedDemands, refresh: refreshReportedDemands } = useFetch(materialNumber ? `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_DEMAND}/reported?ownMaterialNumber=${materialNumber}` : undefined); return { reportedDemands, diff --git a/frontend/src/features/dashboard/hooks/useReportedProduction.ts b/frontend/src/features/dashboard/hooks/useReportedProduction.ts index 8068ff5f..b1862a20 100644 --- a/frontend/src/features/dashboard/hooks/useReportedProduction.ts +++ b/frontend/src/features/dashboard/hooks/useReportedProduction.ts @@ -22,6 +22,9 @@ import { config } from '@models/constants/config' import { Production } from '@models/types/data/production'; export const useReportedProduction = (materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const {data: reportedProductions, error: reportedProductionsError, isLoading: isLoadingReportedProductions, refresh: refreshProduction } = useFetch(materialNumber ? `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_PRODUCTION}/reported?ownMaterialNumber=${materialNumber}` : undefined); return { reportedProductions, diff --git a/frontend/src/features/stock-view/components/StockDetailsView.tsx b/frontend/src/features/stock-view/components/StockDetailsView.tsx index 326a3770..9774ca6b 100644 --- a/frontend/src/features/stock-view/components/StockDetailsView.tsx +++ b/frontend/src/features/stock-view/components/StockDetailsView.tsx @@ -44,7 +44,7 @@ export const StockDetailsView = ({ type }: StockDetailsView const [selectedMaterial, setSelectedMaterial] = useState(null); const { partnerStocks } = usePartnerStocks( type, - type === 'product' ? selectedMaterial?.material?.materialNumberSupplier : selectedMaterial?.material?.materialNumberCustomer + type === 'product' ? selectedMaterial?.material?.materialNumberSupplier ?? null : selectedMaterial?.material?.materialNumberCustomer ?? null ); const [saving, setSaving] = useState(false); const [refreshing, setRefreshing] = useState(false); diff --git a/frontend/src/features/stock-view/hooks/usePartnerStocks.ts b/frontend/src/features/stock-view/hooks/usePartnerStocks.ts index 6a16b92b..c103a3c4 100644 --- a/frontend/src/features/stock-view/hooks/usePartnerStocks.ts +++ b/frontend/src/features/stock-view/hooks/usePartnerStocks.ts @@ -23,6 +23,9 @@ import { Stock, StockType } from '@models/types/data/stock'; import { useFetch } from '@hooks/useFetch'; export const usePartnerStocks = (type: T, materialNumber?: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const url = type === 'material' ? config.app.ENDPOINT_REPORTED_MATERIAL_STOCKS : config.app.ENDPOINT_REPORTED_PRODUCT_STOCKS; const { data: partnerStocks, diff --git a/frontend/src/features/stock-view/hooks/usePartners.ts b/frontend/src/features/stock-view/hooks/usePartners.ts index cdfab62e..d92d4cf9 100644 --- a/frontend/src/features/stock-view/hooks/usePartners.ts +++ b/frontend/src/features/stock-view/hooks/usePartners.ts @@ -23,6 +23,9 @@ import { config } from '@models/constants/config'; import { Partner } from '@models/types/edc/partner'; export const usePartners = (type: 'material' | 'product', materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const endpoint = type === 'product' ? config.app.ENDPOINT_CUSTOMER : config.app.ENDPOINT_SUPPLIER; const { data: partners, isLoading: isLoadingPartners } = useFetch( `${config.app.BACKEND_BASE_URL}${endpoint}${materialNumber}` diff --git a/frontend/src/services/delivery-service.ts b/frontend/src/services/delivery-service.ts index b6f3ab33..fc2553e4 100644 --- a/frontend/src/services/delivery-service.ts +++ b/frontend/src/services/delivery-service.ts @@ -52,6 +52,9 @@ export const deleteDelivery = async (id: UUID) => { } export const requestReportedDeliveries = async (materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const res = await fetch(`${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_DELIVERY}/reported/refresh?ownMaterialNumber=${materialNumber}`, { method: 'GET', headers: { diff --git a/frontend/src/services/demands-service.ts b/frontend/src/services/demands-service.ts index 9d2a6d40..01329a71 100644 --- a/frontend/src/services/demands-service.ts +++ b/frontend/src/services/demands-service.ts @@ -52,6 +52,9 @@ export const deleteDemand = async (id: UUID) => { } export const requestReportedDemands = async (materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const res = await fetch(`${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_DEMAND}/reported/refresh?ownMaterialNumber=${materialNumber}`, { method: 'GET', headers: { diff --git a/frontend/src/services/erp-service.ts b/frontend/src/services/erp-service.ts index 246d587a..b3c1c47f 100644 --- a/frontend/src/services/erp-service.ts +++ b/frontend/src/services/erp-service.ts @@ -32,7 +32,9 @@ export const scheduleErpUpdate = async (partnerBpnl: string | null, materialNumb if (type != AssetType.ItemStock) { throw new Error("The ERP Adapter currently only implements ItemStock, you tried " + AssetType.ItemStock); } - + if (materialNumber != null) { + materialNumber = btoa(materialNumber) + } const endpoint = config.app.ENDPOINT_ERP_SCHEDULE_UPDATE; const res = await fetch(`${config.app.BACKEND_BASE_URL}${endpoint}?${PARAM_BPNL}=${partnerBpnl}&${PARAM_MATERIAL_NUMBER}=${materialNumber}&${PARAM_ASSET_TYPE}=${type}&${PARAM_DIRECTION}=${direction}`, { method: 'POST', diff --git a/frontend/src/services/productions-service.ts b/frontend/src/services/productions-service.ts index 0f2a2ba3..2c3a74f4 100644 --- a/frontend/src/services/productions-service.ts +++ b/frontend/src/services/productions-service.ts @@ -51,6 +51,9 @@ export const deleteProduction = async (id: UUID) => { } export const requestReportedProductions = async (materialNumber: string | null) => { + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const res = await fetch(`${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_PRODUCTION}/reported/refresh?ownMaterialNumber=${materialNumber}`, { method: 'GET', headers: { diff --git a/frontend/src/services/stocks-service.ts b/frontend/src/services/stocks-service.ts index f4c29332..828497ad 100644 --- a/frontend/src/services/stocks-service.ts +++ b/frontend/src/services/stocks-service.ts @@ -59,6 +59,9 @@ export const putStocks = async (type: StockType, stock: Stock) => { export const requestReportedStocks = async (type: StockType, materialNumber: string | null) => { const endpoint = type === 'product' ? config.app.ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS : config.app.ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS; + if (materialNumber != null) { + materialNumber = btoa(materialNumber); + } const res = await fetch(`${config.app.BACKEND_BASE_URL}${endpoint}${materialNumber}`, { method: 'GET', headers: { diff --git a/local/postman/puris-integration-test.postman_collection.json b/local/postman/puris-integration-test.postman_collection.json index 160be90a..0521d4e1 100644 --- a/local/postman/puris-integration-test.postman_collection.json +++ b/local/postman/puris-integration-test.postman_collection.json @@ -1,10 +1,10 @@ { "info": { - "_postman_id": "366237ef-086a-48bb-b723-c0da31f8e1ca", + "_postman_id": "c7fb4ed1-3c2c-48cf-b41d-ad2b1af73a35", "name": "puris-integration-test", "description": "The collection assumes the following roles:\n\n- Customer PURIS (upper tier)\n- Supplier PURIS (lower tier)\n \n\nIt creates the opposite partner and the respective view on the semiconductor material or product.\n\nTo run the tests correctly, take the environment and fill the respective secrets:\n\n- CUSTOMER_EDC_API_KEY\n- CUSTOMER_PURIS_BACKEND_API_KEY\n- CUSTOMER__MANAGE_CLIENT_SECRET\n- SUPPLIER_EDC_API_KEY\n- SUPPLIER_PURIS_BACKEND_API_KEY\n- SUPPLIER_MANAGE_CLIENT_SECRET\n \n\nWhen using the another environment, update / create a new environment.", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "26605468" + "_exporter_id": "29870166" }, "item": [ { @@ -371,7 +371,23 @@ " pm.response.to.have.status(200);", "})" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" + ], + "type": "text/javascript", + "packages": {} } } ], @@ -379,7 +395,7 @@ "method": "POST", "header": [], "url": { - "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/materialpartnerrelations?partnerBpnl={{SUPPLIER_BPNL}}&ownMaterialNumber={{MATERIAL_NUMBER_CUSTOMER}}&partnerMaterialNumber={{MATERIAL_NUMBER_SUPPLIER}}&partnerSupplies=true&partnerBuys=false", + "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/materialpartnerrelations?partnerBpnl={{SUPPLIER_BPNL}}&ownMaterialNumber={{B64_MNR_CUSTOMER}}&partnerMaterialNumber={{B64_MNR_SUPPLIER}}&partnerSupplies=true&partnerBuys=false", "host": [ "{{CUSTOMER_PURIS_BACKEND}}" ], @@ -394,11 +410,11 @@ }, { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_CUSTOMER}}" + "value": "{{B64_MNR_CUSTOMER}}" }, { "key": "partnerMaterialNumber", - "value": "{{MATERIAL_NUMBER_SUPPLIER}}" + "value": "{{B64_MNR_SUPPLIER}}" }, { "key": "partnerSupplies", @@ -429,7 +445,8 @@ " .and.have.jsonBody(pm.environment.get(\"CUSTOMER_BPNL\"), pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\"));", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], @@ -437,7 +454,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/stockView/materialnumbers-mapping?ownMaterialNumber={{MATERIAL_NUMBER_CUSTOMER}}", + "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/stockView/materialnumbers-mapping?ownMaterialNumber={{B64_MNR_CUSTOMER}}", "host": [ "{{CUSTOMER_PURIS_BACKEND}}" ], @@ -449,7 +466,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_CUSTOMER}}" + "value": "{{B64_MNR_CUSTOMER}}" } ] } @@ -789,7 +806,23 @@ " pm.response.to.have.status(200);", "})" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" + ], + "type": "text/javascript", + "packages": {} } } ], @@ -797,7 +830,7 @@ "method": "POST", "header": [], "url": { - "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/materialpartnerrelations?partnerBpnl={{CUSTOMER_BPNL}}&ownMaterialNumber={{MATERIAL_NUMBER_SUPPLIER}}&partnerMaterialNumber={{MATERIAL_NUMBER_CUSTOMER}}&partnerSupplies=false&partnerBuys=true", + "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/materialpartnerrelations?partnerBpnl={{CUSTOMER_BPNL}}&ownMaterialNumber={{B64_MNR_SUPPLIER}}&partnerMaterialNumber={{B64_MNR_CUSTOMER}}&partnerSupplies=false&partnerBuys=true", "host": [ "{{SUPPLIER_PURIS_BACKEND}}" ], @@ -812,11 +845,11 @@ }, { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_SUPPLIER}}" + "value": "{{B64_MNR_SUPPLIER}}" }, { "key": "partnerMaterialNumber", - "value": "{{MATERIAL_NUMBER_CUSTOMER}}" + "value": "{{B64_MNR_CUSTOMER}}" }, { "key": "partnerSupplies", @@ -847,7 +880,8 @@ " .and.have.jsonBody(pm.environment.get(\"CUSTOMER_BPNL\"), pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\"));", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], @@ -855,7 +889,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/stockView/materialnumbers-mapping?ownMaterialNumber={{MATERIAL_NUMBER_SUPPLIER}}", + "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/stockView/materialnumbers-mapping?ownMaterialNumber={{B64_MNR_SUPPLIER}}", "host": [ "{{SUPPLIER_PURIS_BACKEND}}" ], @@ -867,7 +901,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_SUPPLIER}}" + "value": "{{B64_MNR_SUPPLIER}}" } ] } @@ -1513,7 +1547,12 @@ "listen": "prerequest", "script": { "exec": [ - "" + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" ], "type": "text/javascript", "packages": {} @@ -1524,7 +1563,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/demand?ownMaterialNumber={{MATERIAL_NUMBER_CUSTOMER}}", + "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/demand?ownMaterialNumber={{B64_MNR_CUSTOMER}}", "host": [ "{{CUSTOMER_PURIS_BACKEND}}" ], @@ -1535,7 +1574,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_CUSTOMER}}" + "value": "{{B64_MNR_CUSTOMER}}" } ] } @@ -2177,7 +2216,12 @@ "listen": "prerequest", "script": { "exec": [ - "" + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" ], "type": "text/javascript", "packages": {} @@ -2188,7 +2232,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/delivery?ownMaterialNumber={{MATERIAL_NUMBER_CUSTOMER}}", + "raw": "{{CUSTOMER_PURIS_BACKEND}}/catena/delivery?ownMaterialNumber={{B64_MNR_CUSTOMER}}", "host": [ "{{CUSTOMER_PURIS_BACKEND}}" ], @@ -2199,7 +2243,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_CUSTOMER}}" + "value": "{{B64_MNR_CUSTOMER}}" } ] } @@ -2620,7 +2664,12 @@ "listen": "prerequest", "script": { "exec": [ - "" + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" ], "type": "text/javascript", "packages": {} @@ -2631,7 +2680,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/production?ownMaterialNumber={{MATERIAL_NUMBER_SUPPLIER}}", + "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/production?ownMaterialNumber={{B64_MNR_SUPPLIER}}", "host": [ "{{SUPPLIER_PURIS_BACKEND}}" ], @@ -2642,7 +2691,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_SUPPLIER}}" + "value": "{{B64_MNR_SUPPLIER}}" } ] } @@ -3284,7 +3333,12 @@ "listen": "prerequest", "script": { "exec": [ - "" + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_CUSTOMER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_CUSTOMER\", encoded)", + "var plain = pm.collectionVariables.get(\"MATERIAL_NUMBER_SUPPLIER\")", + "var encoded = Buffer.from(plain).toString(\"base64\")", + "pm.collectionVariables.set(\"B64_MNR_SUPPLIER\", encoded)" ], "type": "text/javascript", "packages": {} @@ -3295,7 +3349,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/delivery?ownMaterialNumber={{MATERIAL_NUMBER_SUPPLIER}}", + "raw": "{{SUPPLIER_PURIS_BACKEND}}/catena/delivery?ownMaterialNumber={{B64_MNR_SUPPLIER}}", "host": [ "{{SUPPLIER_PURIS_BACKEND}}" ], @@ -3306,7 +3360,7 @@ "query": [ { "key": "ownMaterialNumber", - "value": "{{MATERIAL_NUMBER_SUPPLIER}}" + "value": "{{B64_MNR_SUPPLIER}}" } ] } @@ -4292,6 +4346,16 @@ "key": "SUPPLIER_BEARER_TOKEN", "value": "", "type": "string" + }, + { + "key": "B64_MNR_CUSTOMER", + "value": "", + "type": "string" + }, + { + "key": "B64_MNR_SUPPLIER", + "value": "", + "type": "string" } ] -} +} \ No newline at end of file