[DEV] update and correct test

This commit is contained in:
Edouard DUPIN 2023-10-23 00:35:21 +02:00
parent 00295b94d1
commit 5256278219
3 changed files with 38 additions and 29 deletions

View File

@ -44,8 +44,17 @@ public class RightResource {
logger.debug("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
if (rightsDescriptions != null && rightsDescriptions.size() != 0) {
final List<Right> rights = getRawUserRight(userId, applicationId);
logger.debug("Get some user right: {}userID={}", rights.size(), userId);
logger.debug("Get some user right: count={} userID={}", rights.size(), userId);
logger.debug("Rights:");
for (final Right elem : rights) {
logger.debug(" - applId={} rightDescriptionId={} value={}", elem.applicationId, elem.rightDescriptionId, elem.value);
}
logger.debug("RightDescription:");
for (final RightDescription elem : rightsDescriptions) {
logger.debug(" - id={} key={} type={} default={}", elem.id, elem.key, elem.type, elem.defaultValue);
}
for (final RightDescription description : rightsDescriptions) {
if (description == null) {
// TODO: this is a really strange case to manage later...
continue;

View File

@ -47,29 +47,29 @@ public class Initialization extends MigrationSqlStep {
('EMAIL_VALIDATION_REQUIRED', 'rwr-r-', 'BOOLEAN', 'false');
""");
addAction("""
INSERT INTO `rightDescription` (`id`, `applicationId`, `key`, `title`, `description`, `type`) VALUES
(1, 1, 'ADMIN', 'Administrator', 'Full administrator Right', 'BOOLEAN');
INSERT INTO `rightDescription` (`id`, `applicationId`, `key`, `title`, `description`, `type`, `defaultValue`) VALUES
(1, 1, 'ADMIN', 'Administrator', 'Full administrator Right', 'BOOLEAN', 'false');
""");
addAction("""
INSERT INTO `right` (`applicationId`, `userId`, `rightDescriptionId`, `value`) VALUES
(1, 1, 1, 'true');
""");
// we generate an offset to permit to manage some generic upgrade in the future...
// we generate an offset to permit to manage some generic upgrade in the future... (can not be done in sqlite)
addAction("""
ALTER TABLE `application` AUTO_INCREMENT = 1000;
""");
""", "mysql");
addAction("""
ALTER TABLE `user` AUTO_INCREMENT = 1000;
""");
""", "mysql");
addAction("""
ALTER TABLE `settings` AUTO_INCREMENT = 1000;
""");
""", "mysql");
addAction("""
ALTER TABLE `right` AUTO_INCREMENT = 1000;
""");
""", "mysql");
addAction("""
ALTER TABLE `rightDescription` AUTO_INCREMENT = 1000;
""");
""", "mysql");
display();
}

View File

@ -100,7 +100,7 @@ public class TestBase {
// check userID
final String userUID = ret.getSubject();
final long id = Long.parseLong(userUID);
Assertions.assertEquals(0, id);
Assertions.assertEquals(1, id);
final String name = (String) ret.getClaim("login");
Assertions.assertEquals("karadmin", name);
@ -248,7 +248,7 @@ public class TestBase {
public void testMeWithToken() throws Exception {
loginAdmin();
final String result = api.get(String.class, "users/me");
Assertions.assertEquals("{\"id\":0,\"login\":\"karadmin\"}", result);
Assertions.assertEquals("{\"id\":1,\"login\":\"karadmin\"}", result);
}