forked from cloudfoundry/uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove logging of non essential data
[#134322559] https://www.pivotaltracker.com/story/show/134322559
- Loading branch information
Showing
9 changed files
with
329 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
server/src/test/java/org/cloudfoundry/identity/uaa/audit/event/EntityDeletedEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* **************************************************************************** | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2016] Pivotal Software, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
* **************************************************************************** | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.audit.event; | ||
|
||
import org.cloudfoundry.identity.uaa.provider.IdentityProvider; | ||
import org.cloudfoundry.identity.uaa.provider.IdentityProviderValidationRequest; | ||
import org.cloudfoundry.identity.uaa.zone.IdentityZone; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.cloudfoundry.identity.uaa.audit.event.EntityDeletedEvent.dataFormat; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class EntityDeletedEventTest { | ||
|
||
|
||
private IdentityProvider provider; | ||
private IdentityZone zone; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
provider = new IdentityProvider(); | ||
provider.setId("id"); | ||
|
||
zone = IdentityZone.getUaa(); | ||
} | ||
|
||
@Test | ||
public void getAuditEvent_IdentityProvider() throws Exception { | ||
String expected = String.format(dataFormat, IdentityZone.class.getName(), zone.getId()); | ||
evalute(zone, expected); | ||
} | ||
|
||
@Test | ||
public void getAuditEvent_IdentityZone() throws Exception { | ||
String expected = String.format(dataFormat, IdentityProvider.class.getName(), provider.getId()); | ||
evalute(provider, expected); | ||
} | ||
|
||
public void evalute(Object o, String expected) { | ||
EntityDeletedEvent<Object> event = new EntityDeletedEvent(o, new IdentityProviderValidationRequest.UsernamePasswordAuthentication("username","password")); | ||
assertEquals(expected, event.getAuditEvent().getData()); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...test/java/org/cloudfoundry/identity/uaa/zone/event/IdentityProviderModifiedEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* **************************************************************************** | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2016] Pivotal Software, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
* **************************************************************************** | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.zone.event; | ||
|
||
import org.cloudfoundry.identity.uaa.constants.OriginKeys; | ||
import org.cloudfoundry.identity.uaa.provider.IdentityProvider; | ||
import org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition; | ||
import org.cloudfoundry.identity.uaa.provider.saml.BootstrapSamlIdentityProviderConfiguratorTests; | ||
import org.cloudfoundry.identity.uaa.zone.IdentityZone; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.security.oauth2.common.util.RandomValueStringGenerator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
|
||
public class IdentityProviderModifiedEventTest { | ||
|
||
private IdentityProvider<SamlIdentityProviderDefinition> provider; | ||
|
||
@Before | ||
public void setup() { | ||
String origin = "idp-mock-saml-"+new RandomValueStringGenerator().generate(); | ||
String metadata = String.format(BootstrapSamlIdentityProviderConfiguratorTests.xmlWithoutID, "http://localhost:9999/metadata/"+origin); | ||
provider = new IdentityProvider<>(); | ||
provider.setId("id"); | ||
provider.setActive(true); | ||
provider.setName(origin); | ||
provider.setIdentityZoneId(IdentityZone.getUaa().getId()); | ||
provider.setType(OriginKeys.SAML); | ||
provider.setIdentityZoneId(IdentityZone.getUaa().getId()); | ||
provider.setOriginKey(origin); | ||
SamlIdentityProviderDefinition samlDefinition = | ||
new SamlIdentityProviderDefinition() | ||
.setMetaDataLocation(metadata) | ||
.setLinkText("Test SAML Provider"); | ||
samlDefinition.setEmailDomain(Arrays.asList("test.com", "test2.com")); | ||
List<String> externalGroupsWhitelist = new ArrayList<>(); | ||
externalGroupsWhitelist.add("value"); | ||
Map<String, Object> attributeMappings = new HashMap<>(); | ||
attributeMappings.put("given_name", "first_name"); | ||
samlDefinition.setExternalGroupsWhitelist(externalGroupsWhitelist); | ||
samlDefinition.setAttributeMappings(attributeMappings); | ||
provider.setConfig(samlDefinition); | ||
} | ||
|
||
@Test | ||
public void identityProviderCreated() throws Exception { | ||
evaluateEventString(IdentityProviderModifiedEvent.identityProviderCreated(provider)); | ||
} | ||
|
||
@Test | ||
public void identityProviderModified() throws Exception { | ||
evaluateEventString(IdentityProviderModifiedEvent.identityProviderModified(provider)); | ||
} | ||
|
||
public void evaluateEventString(IdentityProviderModifiedEvent event) { | ||
String s = event.getAuditEvent().getData(); | ||
assertEquals( | ||
String.format(IdentityProviderModifiedEvent.dataFormat, | ||
provider.getId(), | ||
provider.getType(), | ||
provider.getOriginKey(), | ||
provider.getIdentityZoneId()), | ||
s); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...src/test/java/org/cloudfoundry/identity/uaa/zone/event/IdentityZoneModifiedEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* **************************************************************************** | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2016] Pivotal Software, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product includes a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of these | ||
* subcomponents is subject to the terms and conditions of the | ||
* subcomponent's license, as noted in the LICENSE file. | ||
* **************************************************************************** | ||
*/ | ||
|
||
package org.cloudfoundry.identity.uaa.zone.event; | ||
|
||
import org.cloudfoundry.identity.uaa.zone.IdentityZone; | ||
import org.cloudfoundry.identity.uaa.zone.IdentityZoneConfiguration; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
|
||
public class IdentityZoneModifiedEventTest { | ||
|
||
private IdentityZone zone; | ||
|
||
@Before | ||
public void setup() { | ||
zone = new IdentityZone(); | ||
zone.setId("id"); | ||
zone.setSubdomain("subdomain"); | ||
zone.setName("Test Zone"); | ||
zone.setDescription("Test Zone Description"); | ||
zone.setConfig(new IdentityZoneConfiguration()); | ||
zone.getConfig().getSamlConfig().setPrivateKey("key"); | ||
zone.getConfig().getSamlConfig().setPrivateKeyPassword("password"); | ||
zone.getConfig().getSamlConfig().setCertificate("certificate"); | ||
Map<String, String> keys = new HashMap<>(); | ||
keys.put("kid", "key"); | ||
zone.getConfig().getTokenPolicy().setKeys(keys); | ||
|
||
} | ||
|
||
@Test | ||
public void identityZoneCreated() throws Exception { | ||
evaluteZoneAuditData(IdentityZoneModifiedEvent.identityZoneCreated(zone)); | ||
} | ||
|
||
@Test | ||
public void identityZoneModified() throws Exception { | ||
evaluteZoneAuditData(IdentityZoneModifiedEvent.identityZoneModified(zone)); | ||
} | ||
|
||
public void evaluteZoneAuditData(IdentityZoneModifiedEvent event) { | ||
String s = event.getAuditEvent().getData(); | ||
assertEquals(String.format(IdentityZoneModifiedEvent.dataFormat, | ||
zone.getId(), | ||
zone.getSubdomain()), | ||
s); | ||
} | ||
|
||
} |
Oops, something went wrong.