Skip to content

Commit

Permalink
Merge pull request #14 from njsmith/appveyor
Browse files Browse the repository at this point in the history
[ci] attempt to add appveyor support
  • Loading branch information
njsmith committed Aug 3, 2017
2 parents df64e63 + 0d17e93 commit b5ebca8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
25 changes: 25 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
skip_tags: true

os: Visual Studio 2015

environment:
matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python36-x64"

build_script:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;;%PATH%"
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
- "pip install ."
- "pip install -Ur test-requirements.txt"
- "pip install codecov"

test_script:
# This is pretty lazy -- we don't go into an empty dir or anything.
# I think pytest will test the installed version? But I dunno the
# coverage will actually work right if just given as "trustme"
- "python -u -m pytest -W error -ra -v -s tests --cov=trustme --cov=tests --cov-config=.coveragerc"
- "codecov -F windows"
2 changes: 1 addition & 1 deletion ci/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ else
pytest -W error -ra -s ../tests --cov="$INSTALLDIR" --cov=../tests --cov-config="../.coveragerc"

pip install codecov
codecov
codecov -F $(uname | tr A-Z a-z)
fi
1 change: 1 addition & 0 deletions newsfragments/10.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't crash on Windows
1 change: 1 addition & 0 deletions newsfragments/11.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test on Windows
14 changes: 7 additions & 7 deletions trustme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import datetime
import ssl
from base64 import urlsafe_b64encode
Expand Down Expand Up @@ -41,18 +43,16 @@ def _smells_like_pyopenssl(ctx):


def _cert_builder_common(subject, issuer, public_key):
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(1, 0, 0)
forever = today.replace(year=today.year + 1000)
return (
x509.CertificateBuilder()
.subject_name(subject)
.issuer_name(issuer)
.public_key(public_key)
# This is inclusive so today should work too, but let's pad it a
# bit.
.not_valid_before(yesterday)
.not_valid_after(forever)
.not_valid_before(datetime.datetime(2000, 1, 1))
# OpenSSL on Windows freaks out if you try to give it a date after
# ~3001-01-19
# https://github.com/pyca/cryptography/issues/3194
.not_valid_after(datetime.datetime(3000, 1, 1))
.serial_number(x509.random_serial_number())
.add_extension(
x509.SubjectKeyIdentifier.from_public_key(public_key),
Expand Down

0 comments on commit b5ebca8

Please sign in to comment.