Skip to content

Commit

Permalink
[ISSUE#5695] Summer2021 add unit test for CryptoManager (#6989)
Browse files Browse the repository at this point in the history
* add unit test for CryptoManager

* add unit test for CryptoManager
  • Loading branch information
li-xiao-shuang authored Sep 27, 2021
1 parent 5d19eef commit 1c9672e
Showing 1 changed file with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.nacos.api.config;

import org.junit.Assert;
import org.junit.Test;

/**
* CryptoManagerTest.
*
* @author lixiaoshuang
*/
public class CryptoManagerTest {

@Test
public void testInstance() {
CryptoSpi rsa = CryptoManager.instance("rsa");
Assert.assertNull(rsa);
}

@Test
public void testJoin() {
CryptoSpi cryptoSpi = new CryptoSpi() {
@Override
public String encrypt(String secretKey, String content) {
return null;
}

@Override
public String decrypt(String secretKey, String content) {
return null;
}

@Override
public String generateSecretKey() {
return null;
}

@Override
public String named() {
return "aes";
}
};
CryptoManager.join(cryptoSpi);
CryptoSpi aes = CryptoManager.instance("aes");
Assert.assertNotNull(aes);
}
}

0 comments on commit 1c9672e

Please sign in to comment.