text: # Copyright IBM Corp. 2016 All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #      http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  
  
  import bdd_test_util
  import bootstrap_util
  
  @given(u'the orderer network has organizations')
  def step_impl(context):
      assert 'table' in context, "Expected table of orderer organizations"
      directory = bootstrap_util.getDirectory(context)
      for row in context.table.rows:
          org = directory.getOrganization(row['Organization'], shouldCreate = True)
          org.addToNetwork(bootstrap_util.Network.Orderer)
  
  
  @given(u'user requests role of orderer admin by creating a key and csr for orderer and acquires signed certificate from organization')
  def step_impl(context):
      assert 'table' in context, "Expected table with triplet of User/Orderer/Organization"
      directory = bootstrap_util.getDirectory(context)
      for row in context.table.rows:
          directory.registerOrdererAdminTuple(row['User'], row['Orderer'], row['Organization'])
  
  @given(u'user requests role for peer by creating a key and csr for peer and acquires signed certificate from organization')
  def step_impl(context):
      assert 'table' in context, "Expected table with triplet of User/Peer/Organization"
      directory = bootstrap_util.getDirectory(context)
      for row in context.table.rows:
          directory.registerOrdererAdminTuple(row['User'], row['Peer'], row['Organization'])
  
  @given(u'the peer network has organizations')
  def step_impl(context):
      assert 'table' in context, "Expected table of peer network organizations"
      directory = bootstrap_util.getDirectory(context)
      for row in context.table.rows:
          org = directory.getOrganization(row['Organization'], shouldCreate = True)
          org.addToNetwork(bootstrap_util.Network.Peer)
  
  @given(u'a ordererBootstrapAdmin is identified and given access to all public certificates and orderer node info')
  def step_impl(context):
      directory = bootstrap_util.getDirectory(context)
      assert len(directory.ordererAdminTuples) > 0, "No orderer admin tuples defined!!!"
  
  @given(u'the ordererBootstrapAdmin creates the genesis block for chain "{ordererSystemChainId}" for network config policy "{networkConfigPolicy}" and consensus "{consensusType}" and peer organizations')
  def step_impl(context, ordererSystemChainId, networkConfigPolicy, consensusType):
      genesisBlock = bootstrap_util.createGenesisBlock(context, ordererSystemChainId, networkConfigPolicy, consensusType)
      bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock)
      bootstrap_util.PeerCompositionCallback(context)
  
  @given(u'the orderer admins inspect and approve the genesis block for chain "{chainId}"')
  def step_impl(context, chainId):
      pass
  
  @given(u'the orderer admins use the genesis block for chain "{chainId}" to configure orderers')
  def step_impl(context, chainId):
      pass
      #raise NotImplementedError(u'STEP: Given the orderer admins use the genesis block for chain "**TEST_CHAINID**" to configure orderers')