Skip to content

Commit

Permalink
[apacheGH-445] Added StrictKexTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyor Goldstein committed Dec 22, 2023
1 parent 1c11e3a commit 44015d4
Showing 1 changed file with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "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
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.sshd.common.kex.extension;

import org.apache.sshd.client.SshClient;
import org.apache.sshd.core.CoreModuleProperties;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

/**
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
* @see <A HREF="https://github.com/apache/mina-sshd/issues/445">Terrapin Mitigation: &quot;strict-kex&quot;</A>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class StrictKexTest extends BaseTestSupport {
private SshServer sshd;
private SshClient client;

public StrictKexTest() {
super();
}

@Override
protected SshServer setupTestServer() {
SshServer server = super.setupTestServer();
CoreModuleProperties.USE_STRICT_KEX.set(server, true);
return server;
}

@Override
protected SshClient setupTestClient() {
SshClient sshc = super.setupTestClient();
CoreModuleProperties.USE_STRICT_KEX.set(sshc, true);
return sshc;
}

@Before
public void setUp() throws Exception {
sshd = setupTestServer();
client = setupTestClient();
}

@After
public void tearDown() throws Exception {
if (sshd != null) {
sshd.stop(true);
}
if (client != null) {
client.stop();
}
}

@Test
public void testConnectionClosedIfFirstPacketNotKexInit() throws Exception {
// TODO
}

@Test
public void testStrictKexIgnoredIfNotFirstKexInit() throws Exception {
// TODO
}

@Test
public void testRekeyResetsPacketSequenceNumbers() throws Exception {
// TODO
}

@Test
public void testStrictKexNotActivatedIfClientDoesNotSupportIt() throws Exception {
CoreModuleProperties.USE_STRICT_KEX.set(client, false);
// TODO
}

@Test
public void testStrictKexNotActivatedIfServerDoesNotSupportIt() throws Exception {
CoreModuleProperties.USE_STRICT_KEX.set(sshd, false);
// TODO
}
}

0 comments on commit 44015d4

Please sign in to comment.