From a62dd664b3445ce6f3092525c9f95abbce5dfb53 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 26 Sep 2023 16:23:25 -0300 Subject: [PATCH] Fix tests in GS64 --- .../StargateApplicationTest.class.st | 10 ++++++- ...JWTBearerAuthenticationFilterTest.class.st | 2 +- .../QualifiedLanguageRange.class.st | 27 +++++++++++-------- source/Stargate-Model/WebOrigin.class.st | 6 +++++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/source/Stargate-API-Skeleton-Tests/StargateApplicationTest.class.st b/source/Stargate-API-Skeleton-Tests/StargateApplicationTest.class.st index 03e080a..3c556ee 100644 --- a/source/Stargate-API-Skeleton-Tests/StargateApplicationTest.class.st +++ b/source/Stargate-API-Skeleton-Tests/StargateApplicationTest.class.st @@ -18,6 +18,14 @@ StargateApplicationTest class >> defaultTimeLimit [ ^5 minute ] +{ #category : #private } +StargateApplicationTest >> assert: string isLineEndingInsensitiveEqualsTo: anotherString [ + + self + assert: ( string withLineEndings: String lf ) + equals: ( anotherString withLineEndings: String lf ) +] + { #category : #private } StargateApplicationTest >> baseUrl [ @@ -275,7 +283,7 @@ StargateApplicationTest >> testPrintHelpOn [ help := String streamContents: [ :stream | PetStoreApplication printHelpOn: stream ]. - self assert: help equals: ('NAME + self assert: help isLineEndingInsensitiveEqualsTo: ('NAME pet-store [<1s>] - A RESTful API for Pet stores SYNOPSYS pet-store --pet-store.stargate.public-url=% --pet-store.stargate.port=% --pet-store.stargate.operations-secret=% diff --git a/source/Stargate-Model-Tests/JWTBearerAuthenticationFilterTest.class.st b/source/Stargate-Model-Tests/JWTBearerAuthenticationFilterTest.class.st index 9681326..a004ff1 100644 --- a/source/Stargate-Model-Tests/JWTBearerAuthenticationFilterTest.class.st +++ b/source/Stargate-Model-Tests/JWTBearerAuthenticationFilterTest.class.st @@ -86,7 +86,7 @@ JWTBearerAuthenticationFilterTest >> testInvalidCredentials [ filter := self newFilter. self - assertResponseFor: ( self newHttpRequestWithJWTBearerAuthenticationFor: '' ) + assertResponseFor: ( self newHttpRequestWithJWTBearerAuthenticationFor: 'notasecret' ) isUnauthorizedAfterApplying: filter. self diff --git a/source/Stargate-Model/QualifiedLanguageRange.class.st b/source/Stargate-Model/QualifiedLanguageRange.class.st index e9c1058..c270670 100644 --- a/source/Stargate-Model/QualifiedLanguageRange.class.st +++ b/source/Stargate-Model/QualifiedLanguageRange.class.st @@ -15,17 +15,22 @@ Class { QualifiedLanguageRange class >> fromString: aString [ ^ ( aString substrings: ';' ) - ifEmpty: [ InstanceCreationFailed signal: 'Cannot create a qualified language range with an empty string' ] - ifNotEmpty: [ :tokens | - | quality languageRange | - - languageRange := LanguageRange fromString: tokens first trimBoth. - quality := tokens withoutFirst - detect: [ :parameter | parameter beginsWith: 'q=' ] - ifFound: [ :qParameter | ( qParameter withoutFirst: 2 ) asNumber ] - ifNone: [ 1.0 ]. - self qualifying: languageRange with: quality - ] + ifEmpty: [ + InstanceCreationFailed signal: 'Cannot create a qualified language range with an empty string' ] + ifNotEmpty: [ :tokens | + | quality languageRange | + + languageRange := LanguageRange fromString: tokens first trimBoth. + quality := tokens withoutFirst + detect: [ :parameter | parameter beginsWith: 'q=' ] + ifFound: [ :qParameter | + ( qParameter withoutFirst: 2 ) + ifEmpty: [ InstanceCreationFailed signal: 'Invalid quality parameter value' ] + ifNotEmpty: [ :qValue | qValue asNumber ] + ] + ifNone: [ 1.0 ]. + self qualifying: languageRange with: quality + ] ] { #category : #'instance creation' } diff --git a/source/Stargate-Model/WebOrigin.class.st b/source/Stargate-Model/WebOrigin.class.st index b026da3..7e10fa9 100644 --- a/source/Stargate-Model/WebOrigin.class.st +++ b/source/Stargate-Model/WebOrigin.class.st @@ -47,6 +47,12 @@ WebOrigin >> = aWebOrigin [ ^ self asString = aWebOrigin asString ] +{ #category : #converting } +WebOrigin >> asString [ + + ^ self printString +] + { #category : #converting } WebOrigin >> asUrl [