forked from spinnaker/orca
-
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.
fix(notifications): Propagate auth for application notifications (spi…
…nnaker#2609) Application and pipeline level notifications fails for protected apps, because orca is not propagating authentication to front50. That's sad if you want both security _and_ notifications. But I'm pleased to announce that with this PR, you can have your cake AND eat it too.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,14 @@ import com.netflix.spinnaker.orca.front50.model.ApplicationNotifications | |
import com.netflix.spinnaker.orca.front50.model.ApplicationNotifications.Notification | ||
import com.netflix.spinnaker.orca.pipeline.model.Execution | ||
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor | ||
import com.netflix.spinnaker.security.AuthenticatedRequest | ||
import org.slf4j.MDC | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
|
||
import static com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.PIPELINE | ||
|
||
class EchoNotifyingExecutionListenerSpec extends Specification { | ||
|
||
def echoService = Mock(EchoService) | ||
|
@@ -173,4 +177,23 @@ class EchoNotifyingExecutionListenerSpec extends Specification { | |
1 * echoService.recordEvent(_) | ||
0 * _ | ||
} | ||
|
||
def "propagates authentication details to front50"() { | ||
given: | ||
def pipeline = new Execution(PIPELINE, "myapp") | ||
pipeline.setAuthentication(new Execution.AuthenticationDetails("[email protected]", "someAccount", "anotherAccount")) | ||
|
||
when: | ||
echoListener.beforeExecution(null, pipeline) | ||
|
||
then: | ||
pipeline.notifications == [slackPipes] | ||
|
||
1 * front50Service.getApplicationNotifications("myapp") >> { | ||
assert MDC.get(AuthenticatedRequest.SPINNAKER_USER) == "[email protected]" | ||
assert MDC.get(AuthenticatedRequest.SPINNAKER_ACCOUNTS) == "someAccount,anotherAccount" | ||
return notifications | ||
} | ||
1 * echoService.recordEvent(_) | ||
} | ||
} |