use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNAUTHORIZED in project hedera-services by hashgraph.
the class FileUpdateTransitionLogicTest method doesntAllowSysAdminToUpdateImmutableNonSysFile.
@Test
void doesntAllowSysAdminToUpdateImmutableNonSysFile() {
givenTxnCtxUpdating(EnumSet.of(UpdateTarget.CONTENTS), nonSysFileTarget);
given(txnCtx.activePayer()).willReturn(sysAdmin);
// and:
given(hfs.exists(nonSysFileTarget)).willReturn(true);
given(hfs.getattr(nonSysFileTarget)).willReturn(immutableAttr);
// and:
given(hfs.overwrite(any(), any())).willReturn(new SimpleUpdateResult(false, true, SUCCESS));
given(hfs.setattr(any(), any())).willReturn(new SimpleUpdateResult(true, false, SUCCESS));
// when:
subject.doStateTransition();
// then:
verify(hfs, never()).overwrite(argThat(nonSysFileTarget::equals), argThat(bytes -> Arrays.equals(newContents, bytes)));
verify(txnCtx).setStatus(UNAUTHORIZED);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNAUTHORIZED in project hedera-services by hashgraph.
the class PermissionSemanticsSpec method supportsImmutableFiles.
private HapiApiSpec supportsImmutableFiles() {
long extensionSecs = 666L;
AtomicLong approxExpiry = new AtomicLong();
return defaultHapiSpec("SupportsImmutableFiles").given(newKeyNamed("neverToBeUsed").type(KeyFactory.KeyType.LIST), cryptoCreate("civilian"), fileCreate("eternal").payingWith("civilian").unmodifiable()).when(fileDelete("eternal").payingWith("civilian").signedBy("civilian").hasKnownStatus(UNAUTHORIZED), fileAppend("eternal").payingWith("civilian").signedBy("civilian").content("Ignored.").hasKnownStatus(UNAUTHORIZED), fileUpdate("eternal").payingWith("civilian").signedBy("civilian").contents("Ignored.").hasKnownStatus(UNAUTHORIZED), fileUpdate("eternal").payingWith("civilian").signedBy("civilian", "neverToBeUsed").wacl("neverToBeUsed").hasKnownStatus(UNAUTHORIZED)).then(withOpContext((spec, opLog) -> {
approxExpiry.set(spec.registry().getTimestamp("eternal").getSeconds());
}), fileUpdate("eternal").payingWith("civilian").signedBy("civilian").extendingExpiryBy(extensionSecs), getFileInfo("eternal").isUnmodifiable().hasExpiryPassing(l -> Math.abs(l - approxExpiry.get() - extensionSecs) < 5));
}
Aggregations