mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 14:10:44 +00:00
Compare commits
12 Commits
snapshot-f
...
snapshot-f
Author | SHA1 | Date | |
---|---|---|---|
161591405b | |||
3cc0cfd86c | |||
f457fd0860 | |||
89cf23a65a | |||
57b0d6c29b | |||
6702c06ed0 | |||
c90def42f5 | |||
9dfbd839c8 | |||
724d5779cc | |||
1fef376e65 | |||
47e27d5ffc | |||
494ec00b84 |
2
pom.xml
2
pom.xml
@ -46,7 +46,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<revision>0.21.0-SNAPSHOT</revision>
|
||||
<revision>0.22.0-SNAPSHOT</revision>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@ -225,7 +225,13 @@ public class AuditAction extends AbstractQActionFunction<AuditInput, AuditOutput
|
||||
{
|
||||
if(auditSingleInput.getSecurityKeyValues() == null || !auditSingleInput.getSecurityKeyValues().containsKey(recordSecurityLock.getSecurityKeyType()))
|
||||
{
|
||||
throw (new QException("Missing securityKeyValue [" + recordSecurityLock.getSecurityKeyType() + "] in audit request for table " + auditSingleInput.getAuditTableName()));
|
||||
///////////////////////////////////////////////////////
|
||||
// originally, this case threw... //
|
||||
// but i think it's better to record the audit, just //
|
||||
// missing its security key value, then to fail... //
|
||||
///////////////////////////////////////////////////////
|
||||
// throw (new QException("Missing securityKeyValue [" + recordSecurityLock.getSecurityKeyType() + "] in audit request for table " + auditSingleInput.getAuditTableName()));
|
||||
LOG.info("Missing securityKeyValue in audit request", logPair("table", auditSingleInput.getAuditTableName()), logPair("securityKey", recordSecurityLock.getSecurityKeyType()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,10 @@ public class CompositeWidgetData extends AbstractBlockWidgetData<CompositeWidget
|
||||
{
|
||||
private List<AbstractBlockWidgetData<?, ?, ?, ?>> blocks = new ArrayList<>();
|
||||
|
||||
private Map<String, Serializable> styleOverrides = new HashMap<>();
|
||||
|
||||
private Layout layout;
|
||||
private Layout layout;
|
||||
private Map<String, Serializable> styleOverrides = new HashMap<>();
|
||||
private String overlayHtml;
|
||||
private Map<String, Serializable> overlayStyleOverrides = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
@ -218,4 +219,91 @@ public class CompositeWidgetData extends AbstractBlockWidgetData<CompositeWidget
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for overlayHtml
|
||||
*******************************************************************************/
|
||||
public String getOverlayHtml()
|
||||
{
|
||||
return (this.overlayHtml);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for overlayHtml
|
||||
*******************************************************************************/
|
||||
public void setOverlayHtml(String overlayHtml)
|
||||
{
|
||||
this.overlayHtml = overlayHtml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for overlayHtml
|
||||
*******************************************************************************/
|
||||
public CompositeWidgetData withOverlayHtml(String overlayHtml)
|
||||
{
|
||||
this.overlayHtml = overlayHtml;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for overlayStyleOverrides
|
||||
*******************************************************************************/
|
||||
public Map<String, Serializable> getOverlayStyleOverrides()
|
||||
{
|
||||
return (this.overlayStyleOverrides);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for overlayStyleOverrides
|
||||
*******************************************************************************/
|
||||
public void setOverlayStyleOverrides(Map<String, Serializable> overlayStyleOverrides)
|
||||
{
|
||||
this.overlayStyleOverrides = overlayStyleOverrides;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for overlayStyleOverrides
|
||||
*******************************************************************************/
|
||||
public CompositeWidgetData withOverlayStyleOverrides(Map<String, Serializable> overlayStyleOverrides)
|
||||
{
|
||||
this.overlayStyleOverrides = overlayStyleOverrides;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public CompositeWidgetData withOverlayStyleOverride(String key, Serializable value)
|
||||
{
|
||||
addOverlayStyleOverride(key, value);
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void addOverlayStyleOverride(String key, Serializable value)
|
||||
{
|
||||
if(this.overlayStyleOverrides == null)
|
||||
{
|
||||
this.overlayStyleOverrides = new HashMap<>();
|
||||
}
|
||||
this.overlayStyleOverrides.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.core.model.dashboard.widgets.blocks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.CompositeWidgetData;
|
||||
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.QWidgetData;
|
||||
|
||||
|
||||
@ -203,6 +204,19 @@ public abstract class AbstractBlockWidgetData<
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tooltip
|
||||
**
|
||||
*******************************************************************************/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T withTooltip(CompositeWidgetData data)
|
||||
{
|
||||
this.tooltip = new BlockTooltip(data);
|
||||
return (T) (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -398,6 +412,7 @@ public abstract class AbstractBlockWidgetData<
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for blockId
|
||||
*******************************************************************************/
|
||||
@ -428,5 +443,4 @@ public abstract class AbstractBlockWidgetData<
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,14 +22,18 @@
|
||||
package com.kingsrook.qqq.backend.core.model.dashboard.widgets.blocks;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.CompositeWidgetData;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** A tooltip used within a (widget) block.
|
||||
**
|
||||
*******************************************************************************/
|
||||
public class BlockTooltip
|
||||
{
|
||||
private String title;
|
||||
private Placement placement = Placement.BOTTOM;
|
||||
private CompositeWidgetData blockData;
|
||||
private String title;
|
||||
private Placement placement = Placement.BOTTOM;
|
||||
|
||||
|
||||
|
||||
@ -62,6 +66,17 @@ public class BlockTooltip
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Constructor
|
||||
**
|
||||
*******************************************************************************/
|
||||
public BlockTooltip(CompositeWidgetData blockData)
|
||||
{
|
||||
this.blockData = blockData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for title
|
||||
*******************************************************************************/
|
||||
@ -122,4 +137,35 @@ public class BlockTooltip
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for blockData
|
||||
*******************************************************************************/
|
||||
public CompositeWidgetData getBlockData()
|
||||
{
|
||||
return (this.blockData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for blockData
|
||||
*******************************************************************************/
|
||||
public void setBlockData(CompositeWidgetData blockData)
|
||||
{
|
||||
this.blockData = blockData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for blockData
|
||||
*******************************************************************************/
|
||||
public BlockTooltip withBlockData(CompositeWidgetData blockData)
|
||||
{
|
||||
this.blockData = blockData;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -247,10 +247,7 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface
|
||||
//////////////////////////////////////////////////////////////
|
||||
// allow customizer to do custom things here, if so desired //
|
||||
//////////////////////////////////////////////////////////////
|
||||
if(getCustomizer() != null)
|
||||
{
|
||||
getCustomizer().finalCustomizeSession(qInstance, qSession);
|
||||
}
|
||||
finalCustomizeSession(qInstance, qSession);
|
||||
|
||||
return (qSession);
|
||||
}
|
||||
@ -311,10 +308,7 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface
|
||||
//////////////////////////////////////////////////////////////
|
||||
// allow customizer to do custom things here, if so desired //
|
||||
//////////////////////////////////////////////////////////////
|
||||
if(getCustomizer() != null)
|
||||
{
|
||||
getCustomizer().finalCustomizeSession(qInstance, qSession);
|
||||
}
|
||||
finalCustomizeSession(qInstance, qSession);
|
||||
|
||||
return (qSession);
|
||||
}
|
||||
@ -360,6 +354,23 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
private void finalCustomizeSession(QInstance qInstance, QSession qSession)
|
||||
{
|
||||
if(getCustomizer() != null)
|
||||
{
|
||||
QContext.withTemporaryContext(QContext.capture(), () ->
|
||||
{
|
||||
QContext.setQSession(getChickenAndEggSession());
|
||||
getCustomizer().finalCustomizeSession(qInstance, qSession);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Insert a session as a new record into userSession table
|
||||
*******************************************************************************/
|
||||
|
@ -30,6 +30,8 @@ import java.util.Optional;
|
||||
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.logging.QCollectingLogger;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.audits.AuditInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.audits.AuditSingleInput;
|
||||
import com.kingsrook.qqq.backend.core.model.audits.AuditsMetaDataProvider;
|
||||
@ -40,6 +42,7 @@ import com.kingsrook.qqq.backend.core.model.session.QUser;
|
||||
import com.kingsrook.qqq.backend.core.processes.utils.GeneralProcessUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@ -83,6 +86,7 @@ class AuditActionTest extends BaseTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
@Disabled("this behavior has been changed to just log... should this be a setting?")
|
||||
void testFailWithoutSecurityKey() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
@ -117,6 +121,50 @@ class AuditActionTest extends BaseTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testLogWithoutSecurityKey() throws QException
|
||||
{
|
||||
int recordId = 1701;
|
||||
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String userName = "John Doe";
|
||||
QContext.init(qInstance, new QSession().withUser(new QUser().withFullName(userName)));
|
||||
|
||||
QCollectingLogger collectingLogger = QLogger.activateCollectingLoggerForClass(AuditAction.class);
|
||||
AuditAction.execute(TestUtils.TABLE_NAME_ORDER, recordId, Map.of(), "Test Audit");
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// it should not throw, but it should also not insert the audit. //
|
||||
///////////////////////////////////////////////////////////////////
|
||||
Optional<QRecord> auditRecord = GeneralProcessUtils.getRecordByField("audit", "recordId", recordId);
|
||||
assertTrue(auditRecord.isPresent());
|
||||
|
||||
assertThat(collectingLogger.getCollectedMessages()).anyMatch(m -> m.getMessage().contains("Missing securityKeyValue in audit request"));
|
||||
collectingLogger.clear();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// try again with a null value in the key - that should be ok - as at least you were thinking //
|
||||
// about the key and put in SOME value (null has its own semantics in security keys) //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Map<String, Serializable> securityKeys = new HashMap<>();
|
||||
securityKeys.put(TestUtils.SECURITY_KEY_TYPE_STORE, null);
|
||||
AuditAction.execute(TestUtils.TABLE_NAME_ORDER, recordId, securityKeys, "Test Audit");
|
||||
|
||||
/////////////////////////////////////
|
||||
// now the audit should be stored. //
|
||||
/////////////////////////////////////
|
||||
auditRecord = GeneralProcessUtils.getRecordByField("audit", "recordId", recordId);
|
||||
assertTrue(auditRecord.isPresent());
|
||||
assertThat(collectingLogger.getCollectedMessages()).noneMatch(m -> m.getMessage().contains("Missing securityKeyValue in audit request"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -1 +1 @@
|
||||
0.21.0
|
||||
0.22.0
|
||||
|
Reference in New Issue
Block a user