Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #264

Merged
merged 5 commits into from
Feb 27, 2013
Merged

Dev #264

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.microsoft.windowsazure.services.media.models.Locator;
import com.microsoft.windowsazure.services.media.models.LocatorInfo;
import com.microsoft.windowsazure.services.media.models.LocatorType;
import com.microsoft.windowsazure.services.media.models.ProtectionKey;
import com.microsoft.windowsazure.services.media.models.Task;
import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;

Expand Down Expand Up @@ -288,12 +289,15 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException {
@Test
public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException {
// Arrange
String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed";
String originalTestName = testAssetPrefix + "linkAssetContentKeySuccess";
AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName)
.setOptions(AssetOption.StorageEncrypted));

String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption));
String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID());
String encryptedContentKey = "dummyEncryptedContentKey";
service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey));
service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)
.setProtectionKeyId(protectionKeyId));

// Act
service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.microsoft.windowsazure.services.media.models.ContentKey;
import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
import com.microsoft.windowsazure.services.media.models.ContentKeyType;
import com.microsoft.windowsazure.services.media.models.ProtectionKey;
import com.microsoft.windowsazure.services.media.models.ProtectionKeyType;

public class ContentKeyIntegrationTest extends IntegrationTestBase {
Expand Down Expand Up @@ -65,32 +66,37 @@ public void canCreateContentKey() throws Exception {
// Arrange
String testCanCreateContentKeyId = createRandomContentKeyId();
String testCanCreateContentKeyName = "testCanCreateContentKey";
String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType));

// Act
ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testCanCreateContentKeyId, testContentKeyType,
testEncryptedContentKey).setName(testCanCreateContentKeyName));
ContentKeyInfo contentKeyInfo = service.create(ContentKey
.create(testCanCreateContentKeyId, testContentKeyType, testEncryptedContentKey)
.setName(testCanCreateContentKeyName).setProtectionKeyId(protectionKeyId));

// Assert
verifyContentKeyProperties("ContentKey", testCanCreateContentKeyId, testContentKeyType,
testEncryptedContentKey, testCanCreateContentKeyName, "", ProtectionKeyType.fromCode(0), "",
contentKeyInfo);
testEncryptedContentKey, testCanCreateContentKeyName, protectionKeyId, ProtectionKeyType.fromCode(0),
"", contentKeyInfo);
}

@Test
public void canGetSingleContentKeyById() throws Exception {
// Arrange
String expectedName = testContentKeyPrefix + "GetOne";
String testGetSingleContentKeyByIdId = createRandomContentKeyId();
ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testGetSingleContentKeyByIdId,
testContentKeyType, testEncryptedContentKey).setName(expectedName));
String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType));
ContentKeyInfo ContentKeyToGet = service.create(ContentKey
.create(testGetSingleContentKeyByIdId, testContentKeyType, testEncryptedContentKey)
.setName(expectedName).setProtectionKeyId(protectionKeyId));

// Act
ContentKeyInfo retrievedContentKeyInfo = service.get(ContentKey.get(ContentKeyToGet.getId()));

// Assert
assertEquals(ContentKeyToGet.getId(), retrievedContentKeyInfo.getId());
verifyContentKeyProperties("ContentKey", testGetSingleContentKeyByIdId, testContentKeyType,
testEncryptedContentKey, expectedName, "", ProtectionKeyType.fromCode(0), "", retrievedContentKeyInfo);
testEncryptedContentKey, expectedName, protectionKeyId, ProtectionKeyType.fromCode(0), "",
retrievedContentKeyInfo);
}

@Test
Expand All @@ -102,18 +108,22 @@ public void cannotGetSingleContentKeyByInvalidId() throws Exception {

@Test
public void canRetrieveListOfContentKeys() throws Exception {
// Arrange
String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListOne", testContentKeyPrefix + "ListTwo" };
String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType));

List<ContentKeyInfo> expectedContentKeys = new ArrayList<ContentKeyInfo>();
for (int i = 0; i < ContentKeyNames.length; i++) {
String testCanRetrieveListOfContentKeysId = createRandomContentKeyId();
ContentKeyInfo contentKey = service.create(ContentKey.create(testCanRetrieveListOfContentKeysId,
testContentKeyType, testEncryptedContentKey));
testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId));
expectedContentKeys.add(contentKey);
}

// Act
List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list());

// Assert
verifyListResultContains("listContentKeyss", expectedContentKeys, actualContentKeys, new ComponentDelegate() {
@Override
public void verifyEquals(String message, Object expected, Object actual) {
Expand All @@ -124,32 +134,41 @@ public void verifyEquals(String message, Object expected, Object actual) {

@Test
public void canUseQueryParametersWhenListingContentKeys() throws Exception {
// Arrange
String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListThree",
testContentKeyPrefix + "ListFour", testContentKeyPrefix + "ListFive", testContentKeyPrefix + "ListSix",
testContentKeyPrefix + "ListSeven" };
String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType));

List<ContentKeyInfo> expectedContentKeys = new ArrayList<ContentKeyInfo>();
for (int i = 0; i < ContentKeyNames.length; i++) {
ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(createRandomContentKeyId(),
testContentKeyType, testEncryptedContentKey));
testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId));
expectedContentKeys.add(contentKeyInfo);
}

// Act
List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list().setTop(2));

// Assert
assertEquals(2, actualContentKeys.size());
}

@Test
public void canDeleteContentKeyById() throws Exception {
// Arrange
String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType));
String contentKeyName = testContentKeyPrefix + "ToDelete";
ContentKeyInfo contentKeyToDelete = service.create(ContentKey.create(createRandomContentKeyId(),
testContentKeyType, testEncryptedContentKey).setName(contentKeyName));
ContentKeyInfo contentKeyToDelete = service.create(ContentKey
.create(createRandomContentKeyId(), testContentKeyType, testEncryptedContentKey)
.setName(contentKeyName).setProtectionKeyId(protectionKeyId));
List<ContentKeyInfo> listContentKeysResult = service.list(ContentKey.list());
int ContentKeyCountBaseline = listContentKeysResult.size();

// Act
service.delete(ContentKey.delete(contentKeyToDelete.getId()));

// Assert
listContentKeysResult = service.list(ContentKey.list());
assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listContentKeysResult.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ public void canGetTasksFromJob() throws Exception {

@Test
public void canGetErrorDetailsFromTask() throws Exception {
cleanupEnvironment();
String name = testJobPrefix + "canGetErrorDetailsFromTask";

JobInfo actualJob = service.create(Job.create().setName(name).addInputMediaAsset(assetInfo.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException {
assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size());
MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0);
verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10",
"Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3", mediaProcessorInfo);
"Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3.0", mediaProcessorInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce
// Optional parameters
String configuration = new String(Base64.encode(commonConfiguration), "UTF8");
String name = "My encoding Task " + UUID.randomUUID().toString();
int priority = 0;
int jobPriority = 3;
TaskOption options = TaskOption.ProtectedConfiguration;
// Use a fake id, to simulate real use.
String encryptionKeyId = "nb:kid:UUID:" + UUID.randomUUID().toString();
Expand All @@ -81,7 +81,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce
String initializationVector = new String(Base64.encode(new byte[16]), "UTF8");

CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBody).setConfiguration(configuration)
.setName(name).setPriority(priority).setOptions(options).setEncryptionKeyId(encryptionKeyId)
.setName(name).setPriority(jobPriority).setOptions(options).setEncryptionKeyId(encryptionKeyId)
.setEncryptionScheme(encryptionScheme).setEncryptionVersion(encryptionVersion)
.setInitializationVector(initializationVector);
jobCreator.addTaskCreator(taskCreator);
Expand All @@ -92,8 +92,9 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce

// Assert
assertEquals("taskInfos count", 1, taskInfos.size());
verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, priority,
encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, taskInfos.get(0));
verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name,
jobPriority, encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector,
taskInfos.get(0));
}

@Test
Expand All @@ -108,7 +109,7 @@ public void createTwoTasksSuccess() throws ServiceException {
String configuration = commonConfiguration;
String baseName = "My encoding Task " + UUID.randomUUID().toString();
String[] suffixes = new String[] { " 1", " 2" };
int priority = 0;
int jobPriority = 3;
TaskOption options = TaskOption.None;

List<CreateBatchOperation> taskCreators = new ArrayList<CreateBatchOperation>();
Expand All @@ -128,7 +129,7 @@ public void createTwoTasksSuccess() throws ServiceException {
assertEquals("taskInfos count", taskCreators.size(), taskInfos.size());
for (int i = 0; i < taskCreators.size(); i++) {
verifyTaskPropertiesJustStartedNoEncryption("taskInfo", mediaProcessorId, options, taskBodies[i],
configuration, baseName + suffixes[i], priority, taskInfos.get(i));
configuration, baseName + suffixes[i], jobPriority, taskInfos.get(i));
}
}

Expand Down Expand Up @@ -184,7 +185,7 @@ public void cancelTaskSuccess() throws ServiceException, InterruptedException {
List<TaskInfo> taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink()));
for (TaskInfo taskInfo : taskInfos) {
verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody,
configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo);
configuration, name, 3, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss
configuration = "VC1 Broadband SD 4x3";
break;
case StorageDecryption:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3");
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3.0");
configuration = null;
break;
default:
Expand Down