Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Testing is Failing #22

Closed
urda opened this issue Jun 18, 2017 · 3 comments
Closed

Integration Testing is Failing #22

urda opened this issue Jun 18, 2017 · 3 comments
Assignees
Labels

Comments

@urda
Copy link
Owner

urda commented Jun 18, 2017

NistBeacon is seeing some integration issues with the service at this time. Some records are failing to verify properly.

Reproduction Steps:

  1. make integration
  2. Observe failed test(s)

Expected behavior:

Test should not fail

Observed behavior:

Tests are failing!

$ make integration
py.test ./tests/integration/
================================================= test session starts =================================================
platform darwin -- Python 3.5.2, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /Users/purda/github/nistbeacon, inifile:
plugins: cov-2.5.1
collected 5 items

tests/integration/nistbeacon/test_nistbeacon.py F....

======================================================= FAILURES =======================================================
_______________________________________ TestNistIntegration.test_get_last_record _______________________________________

self = <tests.integration.nistbeacon.test_nistbeacon.TestNistIntegration testMethod=test_get_last_record>

    def test_get_last_record(self):
        actual = NistBeacon.get_last_record()

>       self.assertTrue(actual.valid_signature)
E       AssertionError: 0 is not true

tests/integration/nistbeacon/test_nistbeacon.py:38: AssertionError
========================================== 1 failed, 4 passed in 2.71 seconds ==========================================

nistbeacon version: master branch of project
python version: Python 3.5.2
OS and version: macOS 10.12.5

Installed packages:

alabaster==0.7.10
appnope==0.1.0
argh==0.26.2
astroid==1.4.9
Babel==2.4.0
bleach==2.0.0
certifi==2017.4.17
chardet==3.0.4
coverage==4.4.1
decorator==4.0.11
docutils==0.13.1
editdistance==0.3.1
entrypoints==0.2.3
html5lib==0.999999999
idna==2.5
imagesize==0.7.1
ipykernel==4.6.1
ipyparallel==6.0.2
ipython==6.1.0
ipython-genutils==0.2.0
ipywidgets==6.0.0
isort==4.2.15
jedi==0.10.2
Jinja2==2.9.6
jsonschema==2.6.0
jupyter-client==5.0.1
jupyter-core==4.3.0
lazy-object-proxy==1.3.1
livereload==2.5.1
MarkupSafe==1.0
mccabe==0.6.1
mistune==0.7.4
nbconvert==5.2.1
nbformat==4.3.0
nose==1.3.7
notebook==5.0.0
numpy==1.11.1
pandocfilters==1.4.1
pathtools==0.1.2
pep8==1.7.0
pexpect==4.2.1
pickleshare==0.7.4
port-for==0.3.1
prompt-toolkit==1.0.14
ptyprocess==0.5.1
py==1.4.34
pycrypto==2.6.1
Pygments==2.2.0
pylint==1.6.5
pytest==3.1.2
pytest-cov==2.5.1
python-dateutil==2.6.0
pytz==2017.2
PyYAML==3.12
pyzmq==16.0.2
qtconsole==4.3.0
requests==2.18.1
simplegeneric==0.8.1
six==1.10.0
snowballstemmer==1.2.1
Sphinx==1.6.2
sphinx-autobuild==0.6.0
sphinx-rtd-theme==0.2.4
sphinxcontrib-websupport==1.0.1
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
urllib3==1.21.1
watchdog==0.8.3
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==2.0.0
wrapt==1.10.10
@urda urda added the bug label Jun 18, 2017
@urda urda self-assigned this Jun 18, 2017
@urda urda mentioned this issue Jun 18, 2017
@urda
Copy link
Owner Author

urda commented Jun 20, 2017

I think this test (TestNistIntegration.test_get_last_record) will correct itself once the signatureValue issues have been addressed in #26

@urda
Copy link
Owner Author

urda commented Aug 27, 2017

Attaching the two files that NIST sent my way for work.

pubkey.pem

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAryY9m2YHOui12tk93ntMZAL2uvlXr7j
Taxx5WJ1PM6SJllJ3IopuwUQGLxUEDNinFWE2xlF5sayoR+CRZGDG6Hjtw2fBRcsQKiIpaws6Cd
usRaRMM7Wjajm3vk96gD7Mwcqo+uxuq9186UeNPLeAxMmFlcQcSD4pJgKrZKgHtOk0/t2kz9cgJ
343aN0LuV7w91LvfXwdeCtcHM4nyt3gV+UyxAe6wPoOSsM6Px/YLHWqAqXMfSgEQrd920LyNb+V
gNcPyqhLySDyfcUNtr1BS09nTcw1CaE6sTmtSNLiJCuWzhlzsjcFh5uMoElAaFzN1ilWCRk/02/
B/SWYPGxWIQIDAQAB
-----END PUBLIC KEY-----

verify_f

#this shell script verifies a NIST Beacon pulse, call is sh verify_f <POSIX time>
# e.g. sh verify_f 1495771320

function verify()
{
  t=$1
  curl -s https://beacon.nist.gov/rest/record/$t -o rec.xml

  xpath rec.xml '/record/version/text()' > beacon.bin 2>/dev/null
  printf "%.8x" `xpath rec.xml '/record/frequency/text()' 2>/dev/null` | xxd -r -p -g0 >> beacon.bin
  printf "%.16x" `xpath rec.xml '/record/timeStamp/text()' 2>/dev/null` | xxd -r -p -g0 >> beacon.bin
  xpath rec.xml '/record/seedValue/text()' 2>/dev/null | xxd -r -p -g0 >> beacon.bin 
  xpath rec.xml '/record/previousOutputValue/text()' 2>/dev/null | xxd -r -p -g0 >> beacon.bin

  printf "%.8x" `xpath rec.xml '/record/statusCode/text()' 2>/dev/null` | xxd -r -p -g0 >> beacon.bin

  signature=`xpath rec.xml '/record/signatureValue/text()' rec.xml 2>/dev/null`
  len=${#signature}
  for((i=${len}-2; i>=0; i=i-2)); do rev="$rev${signature:$i:2}"; done
  echo ${rev} | xxd -r -p -g0 > beacon.sig

  #/usr/bin/openssl x509 -pubkey -noout -in beacon.cer  > beaconpubkey.pem

  /usr/bin/openssl dgst -sha512 -verify pubkey.pem -signature beacon.sig beacon.bin  > ver.out

  input="/Users/peralta/Desktop/BeaconStuff/monitor/ver.out"
  while IFS= read -r var
  do
	  if [ "$var" = "Verification Failure" ]
	  then
      echo "$t : Bad signature." 
      echo "$t : BAD" > status_file
    else 
      echo "$t : signature is good."
	  fi
  done < "$input"
  rm rec.xml
  rm beacon.bin
  rm beacon.sig
#  rm beaconpubkey.pem
  rm ver.out
}

verify $1

@urda
Copy link
Owner Author

urda commented Sep 11, 2017

Fixed and released.

@urda urda closed this as completed Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant