AccessKeyAuthenticator implements Authenticator { AccessKeyPair getAccessKeyPair(Invocation invocation, URL url) { AccessKeyStorage accessKeyStorage = ExtensionLoader.getExtensionLoader(AccessKeyStorage.class) .getExtension(url.getParameter(Constants.ACCESS_KEY_STORAGE_KEY, Constants.DEFAULT_ACCESS_KEY_STORAGE)); AccessKeyPair accessKeyPair = null; try { accessKeyPair = accessKeyStorage.getAccessKey(url, invocation); if (accessKeyPair == null || StringUtils.isEmpty(accessKeyPair.getAccessKey()) || StringUtils.isEmpty(accessKeyPair.getSecretKey())) { throw new AccessKeyNotFoundException("AccessKeyId or secretAccessKey not found"); } } catch (Exception e) { throw new RuntimeException("Can't load the AccessKeyPair from accessKeyStorage", e); } return accessKeyPair; }  @Override void sign(Invocation invocation, URL url); @Override void authenticate(Invocation invocation, URL url);  }
@Test void testGetAccessKeyPairFailed() { URL url = URL.valueOf("dubbo: .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak"); AccessKeyAuthenticator helper = new AccessKeyAuthenticator(); Invocation invocation = mock(Invocation.class); assertThrows(RuntimeException.class, () -> helper.getAccessKeyPair(invocation, url)); }