alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Play Framework/Scala example source code file (DebugConfigurationSpec.scala)

This example Play Framework source code file (DebugConfigurationSpec.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Play Framework (and Scala) source code examples by using tags.

All credit for the original source code belongs to Play Framework; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Play Framework tags/keywords

api, debugconfiguration, debugconfigurationspec, lib, library, none, play framework, some, specification, ssl, ssldebugconfig, web service, ws

The DebugConfigurationSpec.scala Play Framework example source code

/*
 *
 *  * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
 *
 */
package play.api.libs.ws.ssl.debug

import org.specs2.mutable._
import play.api.libs.ws.ssl.SSLDebugConfig

object DebugConfigurationSpec extends Specification {

  sequential // global settings, must be sequential

  // Loggers not needed, but useful to doublecheck that the code is doing what it should.
  // ./build test-only play.api.libs.ws.ssl.debug.DebugConfigurationSpec
  val internalDebugLogger = org.slf4j.LoggerFactory.getLogger("play.api.libs.ws.ssl.debug.FixInternalDebugLogging")
  val certpathDebugLogger = org.slf4j.LoggerFactory.getLogger("play.api.libs.ws.ssl.debug.FixCertpathDebugLogging")

  def setLoggerDebug(slf4jLogger: org.slf4j.Logger) {
    val logbackLogger = slf4jLogger.asInstanceOf[ch.qos.logback.classic.Logger]
    logbackLogger.setLevel(ch.qos.logback.classic.Level.DEBUG)
  }

  "configure" should {

    "turn on java.security.debug code" in {
      //setLoggerDebug(certpathDebugLogger)

      Option(System.getProperty("java.security.debug")) must beLike {
        case Some(value) => value must be empty
        case None => ok
      }

      val debugConfig = SSLDebugConfig(certpath = true)
      val config = new DebugConfiguration()
      config.configure(debugConfig)

      System.getProperty("java.security.debug") must contain("certpath")
    }.after {
      System.clearProperty("java.security.debug")
    }

    "turn off java.security.debug code" in {
      System.setProperty("java.security.debug", "certpath")

      val debugConfig = SSLDebugConfig(certpath = false)
      val config = new DebugConfiguration()
      config.configure(debugConfig)

      System.getProperty("java.security.debug") must not contain("certpath")
    }.after {
      System.clearProperty("java.security.debug")
    }

    "turn on javax.ssl.debug code" in {
      //setLoggerDebug(internalDebugLogger)

      Option(System.getProperty("javax.net.debug")) must beLike {
        case Some(value) => value must be empty
        case None => ok
      }

      val debugConfig = SSLDebugConfig(ssl = true)
      val config = new DebugConfiguration()
      config.configure(debugConfig)

      System.getProperty("javax.net.debug") must contain("ssl")
    }.after {
      System.clearProperty("javax.net.debug")
    }

    "turn off javax.ssl.debug code" in {
      System.setProperty("javax.net.debug", "ssl")

      val debugConfig = SSLDebugConfig(ssl = false)
      val config = new DebugConfiguration()
      config.configure(debugConfig)

      System.getProperty("javax.net.debug") must not contain("ssl")
    }.after {
      System.clearProperty("javax.net.debug")
    }
  }

}

Other Play Framework source code examples

Here is a short list of links related to this Play Framework DebugConfigurationSpec.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.