@@ -736,6 +736,108 @@ public void testErrorPathDomainWithFailCustomMountCommand() {
736
736
checkPodReady (adminServerPodName , domainUid , domainNamespace );
737
737
}
738
738
739
+ /**
740
+ * Negative Test to create domain with file , created by user tester with permission read only
741
+ * and not accessible by oracle user in auxiliary image
742
+ * via provided Dockerfile.
743
+ * Check the error msg is in introspector pod log, domain events and operator pod log.
744
+ */
745
+ @ Test
746
+ @ Order (7 )
747
+ @ DisplayName ("Negative Test to create domain with file in auxiliary image not accessible by oracle user" )
748
+ public void testErrorPathFilePermission () {
749
+
750
+ OffsetDateTime timestamp = now ();
751
+ String errorPathAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage4" ;
752
+
753
+ final String auxiliaryImageVolumeName = "auxiliaryImageVolume1" ;
754
+ final String auxiliaryImagePath = "/auxiliary" ;
755
+
756
+ createSecretsForDomain (adminSecretName , encryptionSecretName , errorpathDomainNamespace );
757
+
758
+ // create stage dir for auxiliary image
759
+ Path errorpathAIPath1 = Paths .get (RESULTS_ROOT , "errorpathauxiimage4" );
760
+ assertDoesNotThrow (() -> FileUtils .deleteDirectory (errorpathAIPath1 .toFile ()));
761
+ assertDoesNotThrow (() -> Files .createDirectories (errorpathAIPath1 ));
762
+
763
+ Path errorpathAIPathToFile = Paths .get (RESULTS_ROOT , "errorpathauxiimage4/test1.txt" );
764
+ String content = "some text " ;
765
+ assertDoesNotThrow (() -> Files .write (errorpathAIPathToFile , content .getBytes ()),
766
+ "Can't write to file " + errorpathAIPathToFile );
767
+
768
+ // create models dir and copy model for image
769
+ Path modelsPath1 = Paths .get (errorpathAIPath1 .toString (), "models" );
770
+ assertDoesNotThrow (() -> Files .createDirectories (modelsPath1 ));
771
+ assertDoesNotThrow (() -> Files .copy (
772
+ Paths .get (MODEL_DIR , MII_BASIC_WDT_MODEL_FILE ),
773
+ Paths .get (modelsPath1 .toString (), MII_BASIC_WDT_MODEL_FILE ),
774
+ StandardCopyOption .REPLACE_EXISTING ));
775
+
776
+ // build app
777
+ assertTrue (buildAppArchive (defaultAppParams ()
778
+ .srcDirList (Collections .singletonList (MII_BASIC_APP_NAME ))
779
+ .appName (MII_BASIC_APP_NAME )),
780
+ String .format ("Failed to create app archive for %s" , MII_BASIC_APP_NAME ));
781
+
782
+ // copy app archive to models
783
+ assertDoesNotThrow (() -> Files .copy (
784
+ Paths .get (ARCHIVE_DIR , MII_BASIC_APP_NAME + ".zip" ),
785
+ Paths .get (modelsPath1 .toString (), MII_BASIC_APP_NAME + ".zip" ),
786
+ StandardCopyOption .REPLACE_EXISTING ));
787
+
788
+ // unzip WDT installation file into work dir
789
+ unzipWDTInstallationFile (errorpathAIPath1 .toString ());
790
+
791
+ // create image with model and wdt installation files
792
+ createAuxiliaryImage (errorpathAIPath1 .toString (),
793
+ Paths .get (RESOURCE_DIR , "auxiliaryimage" , "/negative/Dockerfile" ).toString (), errorPathAuxiliaryImage1 );
794
+
795
+ // push image to repo for multi node cluster
796
+ if (!DOMAIN_IMAGES_REPO .isEmpty ()) {
797
+ logger .info ("docker push image {0} to registry {1}" , errorPathAuxiliaryImage1 , DOMAIN_IMAGES_REPO );
798
+ assertTrue (dockerPush (errorPathAuxiliaryImage1 ),
799
+ String .format ("docker push failed for image %s" , errorPathAuxiliaryImage1 ));
800
+ }
801
+
802
+ // create domain custom resource using auxiliary images
803
+ logger .info ("Creating domain custom resource with domainUid {0} and auxiliary image {1}" ,
804
+ domainUid , errorPathAuxiliaryImage1 );
805
+ Domain domainCR = createDomainResource (domainUid , errorpathDomainNamespace ,
806
+ WEBLOGIC_IMAGE_NAME + ":" + WEBLOGIC_IMAGE_TAG , adminSecretName , OCIR_SECRET_NAME ,
807
+ encryptionSecretName , replicaCount , "cluster-1" , auxiliaryImagePath ,
808
+ auxiliaryImageVolumeName , errorPathAuxiliaryImage1 );
809
+
810
+ // create domain and verify it is failed
811
+ logger .info ("Creating domain {0} with auxiliary image {1} in namespace {2}" ,
812
+ domainUid , errorPathAuxiliaryImage1 , errorpathDomainNamespace );
813
+ assertDoesNotThrow (() -> createDomainCustomResource (domainCR ), "createDomainCustomResource throws Exception" );
814
+
815
+ // check the introspector pod log contains the expected error msg
816
+ String expectedErrorMsg = "cp: can't open '/auxiliary/test1.txt': Permission denied" ;
817
+ String introspectorPodName = assertDoesNotThrow (() -> getIntrospectorPodName (domainUid , errorpathDomainNamespace ));
818
+ checkPodLogContainsString (errorpathDomainNamespace , introspectorPodName , expectedErrorMsg );
819
+
820
+ // check the domain event contains the expected error msg
821
+ checkDomainEventContainsExpectedMsg (opNamespace , errorpathDomainNamespace , domainUid , DOMAIN_PROCESSING_FAILED ,
822
+ "Warning" , timestamp , expectedErrorMsg );
823
+
824
+ // check the operator pod log contains the expected error msg
825
+ String operatorPodName =
826
+ assertDoesNotThrow (() -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
827
+ checkPodLogContainsString (opNamespace , operatorPodName , expectedErrorMsg );
828
+
829
+ // check there are no admin server and managed server pods and services not created
830
+ checkPodDoesNotExist (adminServerPodName , domainUid , errorpathDomainNamespace );
831
+ checkServiceDoesNotExist (adminServerPodName , errorpathDomainNamespace );
832
+ for (int i = 1 ; i <= replicaCount ; i ++) {
833
+ checkPodDoesNotExist (managedServerPrefix + i , domainUid , errorpathDomainNamespace );
834
+ checkServiceDoesNotExist (managedServerPrefix + i , errorpathDomainNamespace );
835
+ }
836
+
837
+ // delete domain1
838
+ deleteDomainResource (errorpathDomainNamespace , domainUid );
839
+ }
840
+
739
841
private static void patchDomainWithAuxiliaryImageAndVerify (String oldImageName , String newImageName ,
740
842
String domainUid , String domainNamespace ) {
741
843
String adminServerPodName = domainUid + "-admin-server" ;
0 commit comments