//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCreateASelfSignedCertificate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCreateASelfSignedCertificate() { // Given PkiUtils sslFactory = new PkiUtils(); File cPath = new File(_testDirectory.directory(), "certificate"); File pkPath = new File(_testDirectory.directory(), "key"); // When sslFactory.CreateSelfSignedCertificate(cPath, pkPath, "myhost"); // Then // Attempt to load certificate Certificate[] certificates = sslFactory.LoadCertificates(cPath); assertThat(certificates.Length, @is(greaterThan(0))); // Attempt to load private key PrivateKey pk = sslFactory.LoadPrivateKey(pkPath); assertThat(pk, notNullValue()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createSelfSignedCertificateWithCorrectPermissions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateSelfSignedCertificateWithCorrectPermissions() { assumeTrue(!SystemUtils.IS_OS_WINDOWS); PkiUtils certificates = new PkiUtils(); certificates.CreateSelfSignedCertificate(TestDirectory.file("certificate"), TestDirectory.file("privateKey"), "localhost"); PosixFileAttributes certificateAttributes = Files.getFileAttributeView(TestDirectory.file("certificate").toPath(), typeof(PosixFileAttributeView)).readAttributes(); assertTrue(certificateAttributes.permissions().contains(PosixFilePermission.OWNER_READ)); assertTrue(certificateAttributes.permissions().contains(PosixFilePermission.OWNER_WRITE)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.OWNER_EXECUTE)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.GROUP_READ)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.GROUP_WRITE)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.GROUP_EXECUTE)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.OTHERS_READ)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.OTHERS_WRITE)); assertFalse(certificateAttributes.permissions().contains(PosixFilePermission.OTHERS_EXECUTE)); PosixFileAttributes privateKey = Files.getFileAttributeView(TestDirectory.file("privateKey").toPath(), typeof(PosixFileAttributeView)).readAttributes(); assertTrue(privateKey.permissions().contains(PosixFilePermission.OWNER_READ)); assertTrue(privateKey.permissions().contains(PosixFilePermission.OWNER_WRITE)); assertFalse(privateKey.permissions().contains(PosixFilePermission.OWNER_EXECUTE)); assertFalse(privateKey.permissions().contains(PosixFilePermission.GROUP_READ)); assertFalse(privateKey.permissions().contains(PosixFilePermission.GROUP_WRITE)); assertFalse(privateKey.permissions().contains(PosixFilePermission.GROUP_EXECUTE)); assertFalse(privateKey.permissions().contains(PosixFilePermission.OTHERS_READ)); assertFalse(privateKey.permissions().contains(PosixFilePermission.OTHERS_WRITE)); assertFalse(privateKey.permissions().contains(PosixFilePermission.OTHERS_EXECUTE)); }