public virtual void TestFinalState() { StartupProgressTestHelper.SetStartupProgressForFinalState(startupProgress); string respBody = DoGetAndReturnResponseBody(); NUnit.Framework.Assert.IsNotNull(respBody); IDictionary <string, object> expected = ImmutableMap.Builder <string, object>().Put ("percentComplete", 1.0f).Put("phases", Arrays.AsList <object>(ImmutableMap.Builder <string, object>().Put("name", "LoadingFsImage").Put("desc", "Loading fsimage"). Put("status", "COMPLETE").Put("percentComplete", 1.0f).Put("steps", Sharpen.Collections .SingletonList <object>(ImmutableMap.Builder <string, object>().Put("name", "Inodes" ).Put("desc", "inodes").Put("count", 100L).Put("total", 100L).Put("percentComplete" , 1.0f).Build())).Build(), ImmutableMap.Builder <string, object>().Put("name", "LoadingEdits" ).Put("desc", "Loading edits").Put("status", "COMPLETE").Put("percentComplete", 1.0f).Put("steps", Sharpen.Collections.SingletonList <object>(ImmutableMap.Builder <string, object>().Put("count", 200L).Put("file", "file").Put("size", 1000L).Put ("total", 200L).Put("percentComplete", 1.0f).Build())).Build(), ImmutableMap.Builder <string, object>().Put("name", "SavingCheckpoint").Put("desc", "Saving checkpoint" ).Put("status", "COMPLETE").Put("percentComplete", 1.0f).Put("steps", Sharpen.Collections .SingletonList <object>(ImmutableMap.Builder <string, object>().Put("name", "Inodes" ).Put("desc", "inodes").Put("count", 300L).Put("total", 300L).Put("percentComplete" , 1.0f).Build())).Build(), ImmutableMap.Builder <string, object>().Put("name", "SafeMode" ).Put("desc", "Safe mode").Put("status", "COMPLETE").Put("percentComplete", 1.0f ).Put("steps", Sharpen.Collections.SingletonList <object>(ImmutableMap.Builder <string , object>().Put("name", "AwaitingReportedBlocks").Put("desc", "awaiting reported blocks" ).Put("count", 400L).Put("total", 400L).Put("percentComplete", 1.0f).Build())).Build ())).Build(); NUnit.Framework.Assert.AreEqual(JSON.ToString(expected), FilterJson(respBody)); }
public virtual void TestInitialState() { string respBody = DoGetAndReturnResponseBody(); NUnit.Framework.Assert.IsNotNull(respBody); IDictionary <string, object> expected = ImmutableMap.Builder <string, object>().Put ("percentComplete", 0.0f).Put("phases", Arrays.AsList <object>(ImmutableMap.Builder <string, object>().Put("name", "LoadingFsImage").Put("desc", "Loading fsimage"). Put("status", "PENDING").Put("percentComplete", 0.0f).Put("steps", Collections.EmptyList ()).Build(), ImmutableMap.Builder <string, object>().Put("name", "LoadingEdits"). Put("desc", "Loading edits").Put("status", "PENDING").Put("percentComplete", 0.0f ).Put("steps", Collections.EmptyList()).Build(), ImmutableMap.Builder <string, object >().Put("name", "SavingCheckpoint").Put("desc", "Saving checkpoint").Put("status" , "PENDING").Put("percentComplete", 0.0f).Put("steps", Collections.EmptyList()). Build(), ImmutableMap.Builder <string, object>().Put("name", "SafeMode").Put("desc" , "Safe mode").Put("status", "PENDING").Put("percentComplete", 0.0f).Put("steps" , Collections.EmptyList()).Build())).Build(); NUnit.Framework.Assert.AreEqual(JSON.ToString(expected), FilterJson(respBody)); }
// This method first checks if "key.acl.name" attribute is present as an // attribute in the provider Options. If yes, use the aclName for any // subsequent access checks, else use the keyName as the aclName and set it // as the value of the "key.acl.name" in the key's metadata. /// <exception cref="System.IO.IOException"/> private void AuthorizeCreateKey(string keyName, KeyProvider.Options options, UserGroupInformation ugi) { Preconditions.CheckNotNull(ugi, "UserGroupInformation cannot be null"); IDictionary <string, string> attributes = options.GetAttributes(); string aclName = attributes[KeyAclName]; bool success = false; if (Strings.IsNullOrEmpty(aclName)) { if (acls.IsACLPresent(keyName, KeyAuthorizationKeyProvider.KeyOpType.Management)) { options.SetAttributes(ImmutableMap.Builder <string, string>().PutAll(attributes).Put (KeyAclName, keyName).Build()); success = acls.HasAccessToKey(keyName, ugi, KeyAuthorizationKeyProvider.KeyOpType .Management) || acls.HasAccessToKey(keyName, ugi, KeyAuthorizationKeyProvider.KeyOpType .All); } else { success = false; } } else { success = acls.IsACLPresent(aclName, KeyAuthorizationKeyProvider.KeyOpType.Management ) && (acls.HasAccessToKey(aclName, ugi, KeyAuthorizationKeyProvider.KeyOpType.Management ) || acls.HasAccessToKey(aclName, ugi, KeyAuthorizationKeyProvider.KeyOpType.All )); } if (!success) { throw new AuthorizationException(string.Format("User [%s] is not" + " authorized to create key !!" , ugi.GetShortUserName())); } }