Skip to content

Commit

Permalink
refactor: fix AtConstants-related deprecation lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gkc committed Oct 13, 2023
1 parent f8d966b commit ed8ab13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/at_auth/lib/src/at_auth_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AtAuthImpl implements AtAuth {
}
if (atAuthKeys == null) {
throw AtAuthenticationException(
'AtAuthKeys is not set in the request/cannot be read from provided keysfile');
'keys either were not provided in the AtAuthRequest, or could not be read from provided keys file');
}
var pkamPrivateKey = atAuthKeys.apkamPrivateKey;

Expand Down Expand Up @@ -125,7 +125,7 @@ class AtAuthImpl implements AtAuth {
// update pkam public key to server if enrollment is not set in preference
_logger.finer('Updating PkamPublicKey to remote secondary');
final pkamPublicKey = atAuthKeys.apkamPublicKey;
String updateCommand = 'update:$AT_PKAM_PUBLIC_KEY $pkamPublicKey\n';
String updateCommand = 'update:${AtConstants.atPkamPublicKey} $pkamPublicKey\n';
String? pkamUpdateResult =
await atLookUp!.executeCommand(updateCommand, auth: false);
_logger.finer('PkamPublicKey update result: $pkamUpdateResult');
Expand Down Expand Up @@ -169,7 +169,7 @@ class AtAuthImpl implements AtAuth {
_logger.info('Encryption public key update result $encryptKeyUpdateResult');
// deleting cram secret from the keystore as cram auth is complete
DeleteVerbBuilder deleteBuilder = DeleteVerbBuilder()
..atKey = AT_CRAM_SECRET;
..atKey = AtConstants.atCramSecret;
String? deleteResponse = await atLookUp!.executeVerb(deleteBuilder);
_logger.info('Cram secret delete response : $deleteResponse');
atOnboardingResponse.isSuccessful = true;
Expand Down Expand Up @@ -228,7 +228,7 @@ class AtAuthImpl implements AtAuth {
enrollResult = enrollResult.replaceFirst('data:', '');
_logger.finer('enrollResult: $enrollResult');
var enrollResultJson = jsonDecode(enrollResult);
var enrollmentIdFromServer = enrollResultJson[enrollmentId];
var enrollmentIdFromServer = enrollResultJson[AtConstants.enrollmentId];
var enrollmentStatus = enrollResultJson['status'];
if (enrollmentStatus != 'approved') {
throw AtAuthenticationException(
Expand Down Expand Up @@ -269,7 +269,7 @@ class AtAuthImpl implements AtAuth {
.result;
}
securityKeys.apkamSymmetricKey = jsonData[auth_constants.apkamSymmetricKey];
securityKeys.enrollmentId = jsonData[enrollmentId];
securityKeys.enrollmentId = jsonData[AtConstants.enrollmentId];
return securityKeys;
}

Expand All @@ -282,7 +282,7 @@ class AtAuthImpl implements AtAuth {
}
if (!File(atKeysFilePath).existsSync()) {
throw AtException(
'provided keys file doesnot exists. Please check whether the file path $atKeysFilePath is valid');
'provided keys file does not exist. Please check whether the file path $atKeysFilePath is valid');
}
String atAuthData = await File(atKeysFilePath).readAsString();
Map<String, String> jsonData = <String, String>{};
Expand Down
4 changes: 2 additions & 2 deletions packages/at_auth/test/pkam_authenticator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ void main() {

test('authenticate() should throw UnAuthenticatedException on failure',
() async {
when(() => mockAtLookup.pkamAuthenticate(enrollmentId: enrollmentId))
when(() => mockAtLookup.pkamAuthenticate(enrollmentId: AtConstants.enrollmentId))
.thenThrow(UnAuthenticatedException('Unauthenticated'));

expect(
() async =>
await pkamAuthenticator.authenticate(enrollmentId: enrollmentId),
await pkamAuthenticator.authenticate(enrollmentId: AtConstants.enrollmentId),
throwsA(isA<UnAuthenticatedException>()));
});
});
Expand Down

0 comments on commit ed8ab13

Please sign in to comment.