1111// See the License for the specific language governing permissions and
1212// limitations under the License.
1313
14- package io .nats .nkeys ;
14+ package io .nats .client . impl ;
1515
1616import io .ResourceUtils ;
1717import org .junit .jupiter .api .Test ;
2222import java .util .Base64 ;
2323import java .util .List ;
2424
25- import static io .nats .nkeys .Common .*;
26- import static io .nats .nkeys .NKey .removePaddingAndClear ;
2725import static org .junit .jupiter .api .Assertions .*;
2826
2927public class NKeyTests {
@@ -61,7 +59,7 @@ public void testCRC16() {
6159 for (int i = 0 ; i < inputs .length ; i ++) {
6260 byte [] input = inputs [i ];
6361 int crc = expected [i ];
64- int actual = crc16 (input );
62+ int actual = Common . crc16 (input );
6563 assertEquals (crc , actual , String .format ("CRC for \" %s\" , should be 0x%08X but was 0x%08X" , Arrays .toString (input ), crc , actual ));
6664 }
6765 }
@@ -72,16 +70,16 @@ public void testBase32() {
7270
7371 for (String expected : inputs ) {
7472 byte [] bytes = expected .getBytes (StandardCharsets .UTF_8 );
75- char [] encoded = base32Encode (bytes );
76- byte [] decoded = base32Decode (encoded );
73+ char [] encoded = Common . base32Encode (bytes );
74+ byte [] decoded = Common . base32Decode (encoded );
7775 String test = new String (decoded , StandardCharsets .UTF_8 );
7876 assertEquals (test , expected );
7977 }
8078
8179 // bad input for coverage
82- byte [] decoded = base32Decode ("/" .toCharArray ());
80+ byte [] decoded = Common . base32Decode ("/" .toCharArray ());
8381 assertEquals (0 , decoded .length );
84- decoded = base32Decode (Character .toChars (512 ));
82+ decoded = Common . base32Decode (Character .toChars (512 ));
8583 assertEquals (0 , decoded .length );
8684 }
8785
@@ -553,24 +551,24 @@ public void testInterop() throws Exception {
553551
554552 @ Test
555553 public void testTypeEnum () {
556- assertEquals (NKeyType .USER , NKeyType .fromPrefix (PREFIX_BYTE_USER ));
557- assertEquals (NKeyType .ACCOUNT , NKeyType .fromPrefix (PREFIX_BYTE_ACCOUNT ));
558- assertEquals (NKeyType .SERVER , NKeyType .fromPrefix (PREFIX_BYTE_SERVER ));
559- assertEquals (NKeyType .OPERATOR , NKeyType .fromPrefix (PREFIX_BYTE_OPERATOR ));
560- assertEquals (NKeyType .CLUSTER , NKeyType .fromPrefix (PREFIX_BYTE_CLUSTER ));
561- assertEquals (NKeyType .ACCOUNT , NKeyType .fromPrefix (PREFIX_BYTE_PRIVATE ));
554+ assertEquals (NKeyType .USER , NKeyType .fromPrefix (Common . PREFIX_BYTE_USER ));
555+ assertEquals (NKeyType .ACCOUNT , NKeyType .fromPrefix (Common . PREFIX_BYTE_ACCOUNT ));
556+ assertEquals (NKeyType .SERVER , NKeyType .fromPrefix (Common . PREFIX_BYTE_SERVER ));
557+ assertEquals (NKeyType .OPERATOR , NKeyType .fromPrefix (Common . PREFIX_BYTE_OPERATOR ));
558+ assertEquals (NKeyType .CLUSTER , NKeyType .fromPrefix (Common . PREFIX_BYTE_CLUSTER ));
559+ assertEquals (NKeyType .ACCOUNT , NKeyType .fromPrefix (Common . PREFIX_BYTE_PRIVATE ));
562560 assertThrows (IllegalArgumentException .class , () -> { NKeyType ignored = NKeyType .fromPrefix (9999 ); });
563561 }
564562
565563 @ Test
566564 public void testRemovePaddingAndClear () {
567565 char [] withPad = "!" .toCharArray ();
568- char [] removed = removePaddingAndClear (withPad );
566+ char [] removed = NKey . removePaddingAndClear (withPad );
569567 assertEquals (withPad .length , removed .length );
570568 assertEquals ('!' , removed [0 ]);
571569
572570 withPad = "a=" .toCharArray ();
573- removed = removePaddingAndClear (withPad );
571+ removed = NKey . removePaddingAndClear (withPad );
574572 assertEquals (1 , removed .length );
575573 assertEquals ('a' , removed [0 ]);
576574 }
0 commit comments