Skip to content

Commit

Permalink
Merge pull request #33 from MsysTechnologiesllc/piyush/update_travis
Browse files Browse the repository at this point in the history
[MSYS-837] Update Travis for Ruby multiple version and add Chefstyle to Travis
  • Loading branch information
tas50 authored Jun 11, 2018
2 parents 2aef539 + c0f177b commit 0bde5c0
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ Lint/IneffectiveAccessModifier:
Enabled: false
Lint/ShadowedException:
Enabled: false
Layout/AlignHash:
Enabled: true
EnforcedLastArgumentHashStyle: ignore_implicit
Layout/EndOfLine:
Enabled: false
33 changes: 26 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
sudo: false
cache: bundler
language: ruby
cache: bundler
dist: trusty
sudo: false

# Early warning system to catch if Rubygems breaks something
before_install:
- gem install bundler
- bundle --version
- gem update --system
- gem --version

rvm:
- 2.3.1
- 2.2.0
- 2.3.3
- 2.4.1
- 2.5.1
- ruby-head

matrix:
allow_failures:
- rvm: ruby-head

script:
- bundle exec rake spec
- bundle exec rake style

branches:
only:
- master
before_install:
- gem install bundler
script: bundle exec rake spec
- master
2 changes: 1 addition & 1 deletion lib/win32/certstore/mixin/crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class CERT_CONTEXT < FFI::Struct
safe_attach_function :CertDeleteCertificateFromStore, [PCCERT_CONTEXT], BOOL
# To retrieve specific certificates from certificate store
safe_attach_function :CertFindCertificateInStore, [HCERTSTORE, DWORD, DWORD, DWORD, LPVOID, PCCERT_CONTEXT], PCCERT_CONTEXT

safe_attach_function :PFXExportCertStoreEx, [HCERTSTORE, CRYPT_INTEGER_BLOB, LPCTSTR, LPVOID, DWORD], BOOL
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/win32/certstore/mixin/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'date'
require "date"

module Win32
class Certstore
Expand Down
1 change: 1 addition & 0 deletions lib/win32/certstore/mixin/shell_out.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def shell_out_command(*command_args)
end
cmd
end

# Run a command under powershell with the same API as shell_out. The
# options hash is extended to take an "architecture" flag which
# can be set to :i386 or :x86_64 to force the windows architecture.
Expand Down
15 changes: 8 additions & 7 deletions lib/win32/certstore/store_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def cert_list(store_handler)
cert_name = memory_ptr
cert_list = []
begin
while (pcert_context = CertEnumCertificatesInStore(store_handler, pcert_context)) && (not pcert_context.null?) do
while (pcert_context = CertEnumCertificatesInStore(store_handler, pcert_context)) && (not pcert_context.null?)
cert_args = cert_get_name_args(pcert_context, cert_name, CERT_NAME_FRIENDLY_DISPLAY_TYPE)
if CertGetNameStringW(*cert_args)
cert_list << cert_name.read_wstring
Expand All @@ -92,7 +92,7 @@ def cert_delete(store_handler, certificate_thumbprint)
cert_delete_flag = false
begin
cert_args = cert_find_args(store_handler, cert_rdn)
if (pcert_context = CertFindCertificateInStore(*cert_args) and !pcert_context.null?)
if (pcert_context = CertFindCertificateInStore(*cert_args)) && !pcert_context.null?
cert_delete_flag = CertDeleteCertificateFromStore(CertDuplicateCertificateContext(pcert_context)) || lookup_error
end
CertFreeCertificateContext(pcert_context)
Expand All @@ -119,10 +119,10 @@ def cert_validate(certificate_thumbprint)
def cert_search(store_handler, search_token)
raise ArgumentError, "Invalid search token" if !search_token || search_token.strip.empty?
cert_rdn = memory_ptr
certificate_list =[]
certificate_list = []
counter = 0
begin
while (pcert_context = CertEnumCertificatesInStore(store_handler, pcert_context) and !pcert_context.null?)
while (pcert_context = CertEnumCertificatesInStore(store_handler, pcert_context)) && !pcert_context.null?
cert_property = get_cert_property(pcert_context)
if cert_property.include?(search_token)
certificate_list << [cert_property[CERT_NAME_FRIENDLY_DISPLAY_TYPE], cert_property[CERT_NAME_RDN_TYPE]]
Expand All @@ -147,7 +147,7 @@ def cert_find_args(store_handler, cert_rdn)
[store_handler, X509_ASN_ENCODING, 0, CERT_FIND_ISSUER_STR, cert_rdn.to_wstring, nil]
end

# Match certificate CN exist in cert_rdn
# Match certificate CN exist in cert_rdn
def is_cn_match?(cert_rdn, certificate_name)
cert_rdn.read_wstring.match(/(^|\W)#{certificate_name}($|\W)/i)
end
Expand All @@ -171,7 +171,7 @@ def cert_get_name_args(pcert_context, cert_name, search_type)

# Remove extra space and : from thumbprint
def update_thumbprint(certificate_thumbprint)
certificate_thumbprint.gsub(/[^A-Za-z0-9]/, '')
certificate_thumbprint.gsub(/[^A-Za-z0-9]/, "")
end

# Verify OpenSSL::X509::Certificate object
Expand All @@ -187,7 +187,7 @@ def der_cert(cert_obj)

# Get certificate pem
def get_cert_pem(thumbprint)
get_data = powershell_out!(cert_ps_cmd(thumbprint))
get_data = powershell_out!(cert_ps_cmd(thumbprint))
get_data.stdout
end

Expand All @@ -205,6 +205,7 @@ def format_pem(cert_pem)
def build_openssl_obj(cert_pem)
OpenSSL::X509::Certificate.new(cert_pem)
end

# Create empty memory pointer
def memory_ptr
FFI::MemoryPointer.new(2, 256)
Expand Down
2 changes: 1 addition & 1 deletion spec/win32/unit/certstore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
expect { store.valid?(thumbprint) }.to raise_error(ArgumentError, "Invalid certificate thumbprint.")
end
end

context "When passing thumbprint is nil" do
let (:store_name) { "root" }
let (:thumbprint) { nil }
Expand Down

0 comments on commit 0bde5c0

Please sign in to comment.