Search in sources :

Example 6 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class ProvisioningProfileCopyStepTest method shouldSetProvisioningProfileFutureWhenStepIsRun.

@Test
public void shouldSetProvisioningProfileFutureWhenStepIsRun() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
    Future<Optional<ProvisioningProfileMetadata>> profileFuture = step.getSelectedProvisioningProfileFuture();
    step.execute(executionContext);
    assertTrue(profileFuture.isDone());
    assertNotNull(profileFuture.get());
}
Also used : DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Optional(java.util.Optional) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 7 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class ProvisioningProfileCopyStepTest method testFailsWithInvalidEntitlementsPlist.

@Test
public void testFailsWithInvalidEntitlementsPlist() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    thrown.expect(HumanReadableException.class);
    thrown.expectMessage(startsWith("Malformed entitlement .plist: "));
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.of(testdataDir.resolve("Invalid.plist")), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
    step.execute(executionContext);
}
Also used : DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 8 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class ProvisioningProfileCopyStepTest method testNoEntitlementsDoesNotMergeInvalidProfileKeys.

@Test
public void testNoEntitlementsDoesNotMergeInvalidProfileKeys() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.of("00000000-0000-0000-0000-000000000000"), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
    step.execute(executionContext);
    ProvisioningProfileMetadata selectedProfile = step.getSelectedProvisioningProfileFuture().get().get();
    ImmutableMap<String, NSObject> profileEntitlements = selectedProfile.getEntitlements();
    assertTrue(profileEntitlements.containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
    Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
    assertTrue(xcentContents.isPresent());
    NSDictionary xcentPlist = (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
    assertFalse(xcentPlist.containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
    assertEquals(xcentPlist.get("com.apple.developer.team-identifier"), profileEntitlements.get("com.apple.developer.team-identifier"));
}
Also used : NSObject(com.dd.plist.NSObject) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 9 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class ProvisioningProfileMetadataTest method testParseProvisioningProfileFile.

@Test
public void testParseProvisioningProfileFile() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
    Path testFile = testdataDir.resolve("sample.mobileprovision");
    ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testFile);
    assertThat(data.getExpirationDate(), is(equalTo(new NSDate("9999-03-05T01:33:40Z").getDate())));
    assertThat(data.getAppID(), is(equalTo(new Pair<>("ABCDE12345", "com.example.TestApp"))));
    assertThat(data.getUUID(), is(equalTo("00000000-0000-0000-0000-000000000000")));
    assertThat(data.getProfilePath(), is(equalTo(testFile)));
    assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
    // Test old-style provisioning profile without "Platforms" field
    data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("sample_without_platforms.mobileprovision"));
    assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
    thrown.expect(IOException.class);
    ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("invalid.mobileprovision"));
}
Also used : Path(java.nio.file.Path) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) NSDate(com.dd.plist.NSDate) Test(org.junit.Test)

Example 10 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class ProvisioningProfileMetadataTest method testFilteredEntitlementsStripOut.

@Test
public void testFilteredEntitlementsStripOut() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
    Path testFile = testdataDir.resolve("sample.mobileprovision");
    ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testFile);
    assertTrue(data.getEntitlements().containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
    assertFalse(data.getMergeableEntitlements().containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
}
Also used : Path(java.nio.file.Path) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Aggregations

TestConsole (com.facebook.buck.testutil.TestConsole)100 Test (org.junit.Test)74 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)27 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)27 ExecutionContext (com.facebook.buck.step.ExecutionContext)25 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)25 Path (java.nio.file.Path)21 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)16 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)16 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)16 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)16 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)16 BuckEventBus (com.facebook.buck.event.BuckEventBus)15 FakeProcess (com.facebook.buck.util.FakeProcess)14 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)13 ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)12 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)11 Clock (com.facebook.buck.timing.Clock)10 FakeProcessExecutor (com.facebook.buck.util.FakeProcessExecutor)9 BuildTarget (com.facebook.buck.model.BuildTarget)8