Skip to content

Commit

Permalink
Merge pull request #1749 from jjiwooLim/postBuildCheck
Browse files Browse the repository at this point in the history
VerifyUserFeature test - move postBuild check to test
  • Loading branch information
cherylking authored Oct 30, 2023
2 parents 193f1fa + 6dc6999 commit 3314608
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

import org.apache.commons.io.FileUtils;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.io.FileInputStream;

public class VerifyUsrFeatureTest {

Expand All @@ -46,5 +50,48 @@ public void testVerifyUsrFeature() throws Exception {
throw new AssertionError ("Fail to install user feature.", e);
}
}

@Test
public void testVerifyAll() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("all") && System.getProperty("keyid").equals("0x05534365803788CE"));
String VERIFIED_MESSAGE = "All features were successfully verified.";
assertTrue(buildLogCheck(VERIFIED_MESSAGE));
}

@Test
public void testVerifyWarnWrongKeyId() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("warn") && System.getProperty("keyid").equals("0xWRONGKEYID"));
//CWWKF1514E: The 0X05534365803788CE public key ID does not match the 0xWRONGKEYID provided key ID.
String CWWKF1514E_MESSAGE = "CWWKF1514E";
assertTrue(buildLogCheck(CWWKF1514E_MESSAGE));
}

@Test
public void testVerifyEnforceWithoutUserKeyId() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("enforce") && System.getProperty("keyid") == null);
//CWWKF1508E: The public key ID for the src/test/resources/SimpleActivatorValidKey.asc key URL was not provided.
String CWWKF1508E_MESSAGE = "CWWKF1508E";
assertTrue(buildLogCheck(CWWKF1508E_MESSAGE));
}



public boolean buildLogCheck(String msg) throws Exception {
File buildLog = new File("build.log");
assertTrue(buildLog.exists());

try (InputStream buildOutput = new FileInputStream(buildLog); InputStreamReader in = new InputStreamReader(buildOutput); Scanner s = new Scanner(in);) {
while (s.hasNextLine()) {
String line = s.nextLine();
if(line.contains(msg)) {
return true;
}
}
} catch (Exception e) {
System.out.println("Error checking build.log " + e.getMessage());
}

return false;
}

}

0 comments on commit 3314608

Please sign in to comment.