mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-08 16:18:05 +03:00
license headers in tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package net.schmizz.sshj;/*
|
/*
|
||||||
* Copyright 2010 Shikhar Bhushan
|
* Copyright 2010 Shikhar Bhushan
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -13,6 +13,7 @@ package net.schmizz.sshj;/*
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package net.schmizz.sshj;
|
||||||
|
|
||||||
import net.schmizz.sshj.transport.TransportException;
|
import net.schmizz.sshj.transport.TransportException;
|
||||||
import net.schmizz.sshj.userauth.UserAuthException;
|
import net.schmizz.sshj.userauth.UserAuthException;
|
||||||
@@ -48,7 +49,8 @@ public class SmokeTest {
|
|||||||
private static final String fingerprint = "ce:a7:c1:cf:17:3f:96:49:6a:53:1a:05:0b:ba:90:db";
|
private static final String fingerprint = "ce:a7:c1:cf:17:3f:96:49:6a:53:1a:05:0b:ba:90:db";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws IOException {
|
public void setUp()
|
||||||
|
throws IOException {
|
||||||
ServerSocket s = new ServerSocket(0);
|
ServerSocket s = new ServerSocket(0);
|
||||||
port = s.getLocalPort();
|
port = s.getLocalPort();
|
||||||
s.close();
|
s.close();
|
||||||
@@ -65,20 +67,23 @@ public class SmokeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearUp() throws IOException, InterruptedException {
|
public void tearUp()
|
||||||
|
throws IOException, InterruptedException {
|
||||||
ssh.disconnect();
|
ssh.disconnect();
|
||||||
sshd.stop();
|
sshd.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthenticate() throws IOException {
|
public void testAuthenticate()
|
||||||
|
throws IOException {
|
||||||
connect();
|
connect();
|
||||||
authenticate();
|
authenticate();
|
||||||
assertTrue(ssh.isAuthenticated());
|
assertTrue(ssh.isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConnect() throws IOException {
|
public void testConnect()
|
||||||
|
throws IOException {
|
||||||
connect();
|
connect();
|
||||||
assertTrue(ssh.isConnected());
|
assertTrue(ssh.isConnected());
|
||||||
}
|
}
|
||||||
@@ -97,11 +102,13 @@ public class SmokeTest {
|
|||||||
// assertFalse(shell.isOpen());
|
// assertFalse(shell.isOpen());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void authenticate() throws UserAuthException, TransportException {
|
private void authenticate()
|
||||||
|
throws UserAuthException, TransportException {
|
||||||
ssh.authPassword("same", "same");
|
ssh.authPassword("same", "same");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect() throws IOException {
|
private void connect()
|
||||||
|
throws IOException {
|
||||||
ssh.connect(hostname, port);
|
ssh.connect(hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright 2010 Shikhar Bhushan
|
||||||
* or more contributor license agreements. See the NOTICE file
|
*
|
||||||
* distributed with this work for additional information
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* you may not use this file except in compliance with the License.
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* You may obtain a copy of the License at
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
package net.schmizz.sshj.keyprovider;
|
package net.schmizz.sshj.keyprovider;
|
||||||
|
|
||||||
@@ -82,7 +79,8 @@ public class OpenSSHKeyFileTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blankingOut() throws IOException, GeneralSecurityException {
|
public void blankingOut()
|
||||||
|
throws IOException, GeneralSecurityException {
|
||||||
FileKeyProvider dsa = new OpenSSHKeyFile();
|
FileKeyProvider dsa = new OpenSSHKeyFile();
|
||||||
dsa.init(new File("src/test/resources/id_dsa"), PasswordUtils.createOneOff(correctPassphrase));
|
dsa.init(new File("src/test/resources/id_dsa"), PasswordUtils.createOneOff(correctPassphrase));
|
||||||
assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
|
assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
|
||||||
@@ -93,7 +91,8 @@ public class OpenSSHKeyFileTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getters() throws IOException, GeneralSecurityException {
|
public void getters()
|
||||||
|
throws IOException, GeneralSecurityException {
|
||||||
FileKeyProvider dsa = new OpenSSHKeyFile();
|
FileKeyProvider dsa = new OpenSSHKeyFile();
|
||||||
dsa.init(new File("src/test/resources/id_dsa"), onlyGivesWhenReady);
|
dsa.init(new File("src/test/resources/id_dsa"), onlyGivesWhenReady);
|
||||||
assertEquals(dsa.getType(), KeyType.DSA);
|
assertEquals(dsa.getType(), KeyType.DSA);
|
||||||
@@ -103,14 +102,16 @@ public class OpenSSHKeyFileTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retries() throws IOException, GeneralSecurityException {
|
public void retries()
|
||||||
|
throws IOException, GeneralSecurityException {
|
||||||
FileKeyProvider dsa = new OpenSSHKeyFile();
|
FileKeyProvider dsa = new OpenSSHKeyFile();
|
||||||
dsa.init(new File("src/test/resources/id_dsa"), givesOn3rdTry);
|
dsa.init(new File("src/test/resources/id_dsa"), givesOn3rdTry);
|
||||||
assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
|
assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws UnsupportedEncodingException, GeneralSecurityException {
|
public void setup()
|
||||||
|
throws UnsupportedEncodingException, GeneralSecurityException {
|
||||||
if (!SecurityUtils.isBouncyCastleRegistered())
|
if (!SecurityUtils.isBouncyCastleRegistered())
|
||||||
throw new AssertionError("bouncy castle needed");
|
throw new AssertionError("bouncy castle needed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright 2010 Shikhar Bhushan
|
||||||
* or more contributor license agreements. See the NOTICE file
|
*
|
||||||
* distributed with this work for additional information
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* you may not use this file except in compliance with the License.
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* You may obtain a copy of the License at
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
package net.schmizz.sshj.keyprovider;
|
package net.schmizz.sshj.keyprovider;
|
||||||
|
|
||||||
@@ -42,20 +39,23 @@ public class PKCS8KeyFileTest {
|
|||||||
static final String privExp = "57bcee2e2656eb2c94033d802dd62d726c6705fabad1fd0df86b67600a96431301620d395cbf5871c7af3d3974dfe5c30f5c60d95d7e6e75df69ed6c5a36a9c8aef554b5058b76a719b8478efa08ad1ebf08c8c25fe4b9bc0bfbb9be5d4f60e6213b4ab1c26ad33f5bba7d93e1cd65f65f5a79eb6ebfb32f930a2b0244378b4727acf83b5fb376c38d4abecc5dc3fc399e618e792d4c745d2dbbb9735242e5033129f2985ca3e28fa33cad2afe3e70e1b07ed2b6ec8a3f843fb4bffe3385ad211c6600618488f4ac70397e8eb036b82d811283dc728504cddbe1533c4dd31b1ec99ffa74fd0e3883a9cb3e2315cc1a56f55d38ed40520dd9ec91b4d2dd790d1b";
|
static final String privExp = "57bcee2e2656eb2c94033d802dd62d726c6705fabad1fd0df86b67600a96431301620d395cbf5871c7af3d3974dfe5c30f5c60d95d7e6e75df69ed6c5a36a9c8aef554b5058b76a719b8478efa08ad1ebf08c8c25fe4b9bc0bfbb9be5d4f60e6213b4ab1c26ad33f5bba7d93e1cd65f65f5a79eb6ebfb32f930a2b0244378b4727acf83b5fb376c38d4abecc5dc3fc399e618e792d4c745d2dbbb9735242e5033129f2985ca3e28fa33cad2afe3e70e1b07ed2b6ec8a3f843fb4bffe3385ad211c6600618488f4ac70397e8eb036b82d811283dc728504cddbe1533c4dd31b1ec99ffa74fd0e3883a9cb3e2315cc1a56f55d38ed40520dd9ec91b4d2dd790d1b";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws UnsupportedEncodingException, GeneralSecurityException {
|
public void setUp()
|
||||||
|
throws UnsupportedEncodingException, GeneralSecurityException {
|
||||||
if (!SecurityUtils.isBouncyCastleRegistered())
|
if (!SecurityUtils.isBouncyCastleRegistered())
|
||||||
throw new AssertionError("bouncy castle needed");
|
throw new AssertionError("bouncy castle needed");
|
||||||
rsa.init(new File("src/test/resources/id_rsa"));
|
rsa.init(new File("src/test/resources/id_rsa"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeys() throws IOException, GeneralSecurityException {
|
public void testKeys()
|
||||||
|
throws IOException, GeneralSecurityException {
|
||||||
assertEquals(KeyUtil.newRSAPublicKey(modulus, pubExp), rsa.getPublic());
|
assertEquals(KeyUtil.newRSAPublicKey(modulus, pubExp), rsa.getPublic());
|
||||||
assertEquals(KeyUtil.newRSAPrivateKey(modulus, privExp), rsa.getPrivate());
|
assertEquals(KeyUtil.newRSAPrivateKey(modulus, privExp), rsa.getPrivate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testType() throws IOException {
|
public void testType()
|
||||||
|
throws IOException {
|
||||||
assertEquals(rsa.getType(), KeyType.RSA);
|
assertEquals(rsa.getType(), KeyType.RSA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user